Friday, January 30, 2009

Turn on/off startup of services with chkconfig

Commonly known, but I always put stuff in here for when I forget the syntax.

I especially hate webmins

chkconfig --level 4 webmin off

a brief understanding of runlevels: (from: http://www.yolinux.com/TUTORIALS/LinuxTutorialInitProcess.html)

Runlevel "3" will boot to text or console mode and "5" will boot to the graphical login mode ( "4" for slackware)

Runlevel Scripts Directory
(Red Hat/Fedora Core)
State
0 /etc/rc.d/rc0.d/ shutdown/halt system
1 /etc/rc.d/rc1.d/ Single user mode
2 /etc/rc.d/rc2.d/ Multiuser with no network services exported
3 /etc/rc.d/rc3.d/ Default text/console only start. Full multiuser
4 /etc/rc.d/rc4.d/ Reserved for local use. Also X-windows (Slackware/BSD)
5 /etc/rc.d/rc5.d/ XDM X-windows GUI mode (Redhat/System V)
6 /etc/rc.d/rc6.d/ Reboot
s or S
Single user/Maintenance mode (Slackware)
M
Multiuser mode (Slackware)

One may switch init levels by issuing the init command with the appropriate runlevel. Use the command "init #" where # is one of s,S,0,1,3,5,6. The command telinit does the same.

The scripts for a given run level are run during boot and shutdown. The scripts are found in the directory /etc/rc.d/rc#.d/ where the symbol # represents the run level. i.e. the run level "3" will run all the scripts in the directory /etc/rc.d/rc3.d/ which start with the letter "S" during system boot. This starts the background processes required by the system. During shutdown all scripts in the directory which begin with the letter "K" will be executed. This system provides an orderly way to bring the system to different states for production and maintenance modes.

If you installed all demons (background processes), Linux will run them all. To avoid slowing down your machine, remove unneeded services from the start-up procedure. You can start/stop individual demons by changing to the directory:

  • /etc/rc.d/init.d/ (Red Hat/Fedora )
  • /etc/init.d/ (S.u.s.e.)
  • /etc/init.d/ (Ubuntu / Debian)
and issuing the command and either the start, stop, status, restart or reload option i.e. to stop the web server:
  • cd /etc/rc.d/init.d/
    (or /etc/init.d/ for S.u.s.e. and Ubuntu / Debian)
  • httpd stop

Use the command ps -aux to view all process on your machine.

TIP: List state and run level of all services which can be started by init: chkconfig --list
or
service --status-all | grep running (Red Hat/Fedora Core based systems)

0 Comments:

Post a Comment

<< Home