Server harding shell script for RHEL 5.0
Dear All,
Following shell script is working on Centos, RHEL 4.0 but it won't work on RHEL 5.0. let explain Command chkconfig ntpd off work as single command but it create shell script and this command in shell script it won't work. Kindly suggest what step we want to take to run shell script on RHEL 5.0 ( permission 777, .sh,etc) chkconfig is not working in shell script --------------------------------------------------------------------- #!/bin/bash chkconfig autofs off chkconfig avahi-daemon off chkconfig avahi-dnsconfd off chkconfig bluetooth off chkconfig conman off chkconfig cups off chkconfig dhcdbd off chkconfig firstboot off chkconfig gpm off chkconfig haldaemon off chkconfig isdn off chkconfig iptables off chkconfig ip6tables off chkconfig irda off chkconfig irqbalance off chkconfig kdump off chkconfig kudzu off chkconfig mcstrans off chkconfig microcode_ctl off chkconfig multipathd off chkconfig netconsole off chkconfig netfs off chkconfig netplugd off chkconfig nfs off chkconfig nfslock off chkconfig nscd off chkconfig pcscd off chkconfig portmap off chkconfig rdisc off chkconfig rhnsd off chkconfig restorecond off chkconfig rpcgssd off chkconfig rpcidmapd off chkconfig rpcsvcgssd off chkconfig sendmail off chkconfig smartd off chkconfig winbind off chkconfig wpa_supplicant off chkconfig xfs off chkconfig ypbind off chkconfig yum-updatesd off chkconfig acpid on chkconfig anacron on chkconfig atd on chkconfig cpuspeed on chkconfig lvm2-monitor on chkconfig messagebus on chkconfig ntpd on chkconfig network on chkconfig oracle on chkconfig oracleasm on chkconfig readahead_early on chkconfig readahead_later on chkconfig syslog on chkconfig sshd on ------------------------------------------------------------ |
What is the error when you run the shell script?
When you run the chkconfig on terminal (without shell script), does it run fine? |
Error when executing script
Following error encounter after shell script run on server.
and direct command is run properly. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> chkconfig version 1.3.30.1 - Copyright (C) 1997-2000 Red Hat, Inc. This may be freely redistributed under the terms of the GNU Public License. usage: chkconfig --list [name] chkconfig --add <name> chkconfig --del <name> chkconfig [--level <levels>] <name> <on|off|reset|resetpriorities> |
Add following lines after
#!/bin/bash Code:
#chkconfig: 2345 95 20 I was facing almost similar problem but my error was different. I used sudo before chkconfig in shell script and it was working fine. To test the old script, I tried to run it in Korn Shell and it was working there but it was not working in BASH. But your error is different, I don't know it would work for you. |
Thank you -- I will confirm same
Dear Sir,
It is not working similar error message on same |
Well it clearly says you should "chkconfig --level 12345 $SERVICENAME off". Also note this isn't a "hardening" script in any way plus RHEL 5U0 is way outdated, they're at U9 for some time now.
|
Thank you -- I will confirm same
Thank you for good information
|
Actually, --level is optional; it defaults to the current set levels.
Have you by chance copied this script via an MS system; maybe its a line ending issue? As above, 5.0 is way out of date. Unless you absolutely have to have this version, use the latest 5.9 (or even 6.4). On 6.3 (Centos) it defaults to levels 2345 Code:
chkconfig --list|grep ntp |
All times are GMT -5. The time now is 06:14 AM. |