Linux

Tech Tip: Change runlevels without rebooting


There are a number of different ways you can boot into Linux. The most common is to boot into runlevel 5, or multiuser GUI. This fires up X Display Manager (XDM), KDE Display Manager (KDM), or whatever GUI login manager you've defined and allows you to log into your desktop environment of choice.

Another common runlevel is runlevel 3, which is multiuser text. This starts Linux but does not start X, allowing you to log in at a text console. Admins typically use this in server situations when they don't want the overhead of running X.

Finally, runlevel 1 is a single-user mode that admins often use for performing system maintenance or repair.

The /etc/inittab file determines what runlevel Linux boots into by default. The following line from inittab indicates that runlevel 5 is the default runlevel to start.

id:5:initdefault:

Most often, if users want to log into X when booted in runlevel 3, they use the startx command, but this isn't always desirable. This command loads the default window manager for the user's account, but you may also wish to start the login manager.

Users will often edit inittab and reboot. This isn't required, however, and you can change runlevels without rebooting by using the telinit command.

If you've booted into runlevel 3, you can easily change to runlevel 5 by executing the following as root:

# telinit 5

This will start any services associated with runlevel 5 and start X. You can use the same command to switch to runlevel 3 from runlevel 5. Using telinit in this fashion can be extremely useful when configuring or debugging your X setup.

0 comments

Editor's Picks