Difference between revisions of "Redhat - fedora service startup"
(Pushed from Themanclub.) |
(→adding new services) |
||
(2 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
+ | == run levels == | ||
+ | |||
+ | Service start and stop scrips are associated with run levels 0-6. Each has a corresponding directory in /etc/rc.d. For each run level, a script beginning with K stops the service, whereas a script beginning with S starts the service. | ||
+ | |||
== starting services on boot == | == starting services on boot == | ||
Line 14: | Line 18: | ||
# systemctl -a | # systemctl -a | ||
− | == | + | == chkconfig method == |
− | example: | + | |
− | # '''chkconfig | + | ===listing existing services=== |
+ | |||
+ | listing existing services and the run level start configurations | ||
+ | |||
+ | # chkconfig --list | ||
+ | |||
+ | example: | ||
+ | |||
+ | # chkconfig --list | grep sshd | ||
+ | sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off | ||
+ | |||
+ | corresponding start/stop scripts | ||
+ | |||
+ | # grep -r -m 1 sshd /etc/rc.d/* | sort -n | ||
+ | /etc/rc.d/init.d/sshd:# processname: sshd | ||
+ | /etc/rc.d/rc0.d/K25sshd:# processname: sshd | ||
+ | /etc/rc.d/rc1.d/K25sshd:# processname: sshd | ||
+ | /etc/rc.d/rc2.d/S55sshd:# processname: sshd | ||
+ | /etc/rc.d/rc3.d/S55sshd:# processname: sshd | ||
+ | /etc/rc.d/rc4.d/S55sshd:# processname: sshd | ||
+ | /etc/rc.d/rc5.d/S55sshd:# processname: sshd | ||
+ | /etc/rc.d/rc6.d/K25sshd:# processname: sshd | ||
+ | |||
+ | ===adding new services=== | ||
+ | |||
+ | adding a new service if isn't already listed. | ||
+ | |||
+ | |||
+ | # '''chkconfig --add <name>''' | ||
+ | |||
+ | name = service name as its start script appears in /etc/init.d/ or you will get an error | ||
+ | |||
+ | example | ||
+ | |||
+ | # '''chkconfig --add snmpd''' | ||
+ | error reading information on service badserviced: Invalid argument | ||
+ | |||
+ | example... | ||
+ | |||
+ | # '''chkconfig --add snmpd''' | ||
+ | |||
+ | check service just added, notice all run levels will be off by default | ||
+ | |||
+ | # '''chkconfig --list | grep nrpe''' | ||
+ | nrpe 0:off 1:off 2:off 3:off 4:off 5:off 6:off | ||
+ | |||
+ | ===setting the run levels=== | ||
+ | |||
+ | # chkconfig --level <levels> <name> on | ||
+ | |||
+ | example, setting levels 2-5... | ||
+ | |||
+ | # '''chkconfig --level 2345 snmpd on''' | ||
+ | |||
+ | ==misc info== | ||
+ | # '''chkconfig sshd on | ||
on fedora 17, the above command creates a symlink in a subdir of /etc/systemd/system/ | on fedora 17, the above command creates a symlink in a subdir of /etc/systemd/system/ | ||
+ | |||
+ | |||
[[category:redhat]] | [[category:redhat]] |
Latest revision as of 16:31, 13 October 2014
Contents |
run levels
Service start and stop scrips are associated with run levels 0-6. Each has a corresponding directory in /etc/rc.d. For each run level, a script beginning with K stops the service, whereas a script beginning with S starts the service.
starting services on boot
In order to start it automatically on every system boot, run
# systemctl enable sshd.service
Likewise, you can remove it from system startup
# systemctl disable sshd.service
If you would like to see a list of all available managed services, run
# systemctl -a
chkconfig method
listing existing services
listing existing services and the run level start configurations
# chkconfig --list
example:
# chkconfig --list | grep sshd sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
corresponding start/stop scripts
# grep -r -m 1 sshd /etc/rc.d/* | sort -n /etc/rc.d/init.d/sshd:# processname: sshd /etc/rc.d/rc0.d/K25sshd:# processname: sshd /etc/rc.d/rc1.d/K25sshd:# processname: sshd /etc/rc.d/rc2.d/S55sshd:# processname: sshd /etc/rc.d/rc3.d/S55sshd:# processname: sshd /etc/rc.d/rc4.d/S55sshd:# processname: sshd /etc/rc.d/rc5.d/S55sshd:# processname: sshd /etc/rc.d/rc6.d/K25sshd:# processname: sshd
adding new services
adding a new service if isn't already listed.
# chkconfig --add <name>
name = service name as its start script appears in /etc/init.d/ or you will get an error
example
# chkconfig --add snmpd error reading information on service badserviced: Invalid argument
example...
# chkconfig --add snmpd
check service just added, notice all run levels will be off by default
# chkconfig --list | grep nrpe nrpe 0:off 1:off 2:off 3:off 4:off 5:off 6:off
setting the run levels
# chkconfig --level <levels> <name> on
example, setting levels 2-5...
# chkconfig --level 2345 snmpd on
misc info
# chkconfig sshd on
on fedora 17, the above command creates a symlink in a subdir of /etc/systemd/system/