Chapter 4. Tuning the operating system 101
Draft Document for Review May 4, 2007 11:35 am 4285ch04.fm
Changing runlevels
Whenever possible, do not run the graphical user interface on a Linux server. Normally, there
is no need for a GUI on a Linux server, as most Linux administrators will happily assure you.
All administrative tasks can be achieved efficiently via the command line, by redirecting the X
display, or through a Web browser interface. If you prefer a graphical interface, there are
several useful Web-based tools such as webmin, Linuxconf, and SWAT.
If a GUI must be used, start and stop it as needed rather than running it all the time. In most
cases the server should be running at runlevel 3, which does not start the X Server when the
machine boots up. If you want to restart the X Server, use startx from a command prompt.
1. Determine which run level the machine is running by using the runlevel command.
This prints the previous and current run level. For example, N 5 means that there was no
previous run level (N) and that the current run level is 5.
2. To switch between run levels, use the init command. (For example, to switch to
runlevel 3, enter the init 3 command.
The run levels that are used in Linux are:
0Halt (Do not set initdefault to this or the server will shut down immediately after
finishing the boot process.)
1Single user mode
2Multiuser, without NFS (the same as 3, if you do not have networking)
3Full multiuser mode
4Unused
5X11
6Reboot (Do not set initdefault to this or the server machine will continuously reboot
at startup.)
To set the initial runlevel of a machine at boot, modify the /etc/inittab file as shown in
Figure 4-3 with the line:
id:3:initdefault:
Tip: Even if the GUI is disabled locally on the server, you can still connect remotely and
use the GUI. To do this, use the -X parameter with the ssh command.