< Day Day Up > |
Recipe 7.2. Changing Runlevels After Bootup7.2.1 ProblemSomewhere during the installation of your Linux system, you selected either "boot to text mode" or "boot to graphical mode." Maybe you didn't quite understand what these options meant—or maybe you did, but now you want a nice graphical interface instead of a boring text-only console. Or you're having problems with the graphical interface, and want to drop to a runlevel with minimal services for troubleshooting. 7.2.2 SolutionUse init. First, check what runlevel you are in: # /sbin/runlevel
N 5 The N means you have not previously booted to a different runlevel. If you had, the number of the runlevel would be displayed. You must be root to change the runlevel: # /sbin/init 3 This will stop all runlevel 5 services, then start up the runlevel 3 services. It's like doing a partial reboot. All users will be logged out. Sometimes you need to change to runlevel 1 to get out of trouble: # /sbin/init 1 This stops X and drops you to a root shell, with limited services and no X. On Red Hat, you don't need to supply the root password after dropping to runlevel 1, so don't give any sudo users init access. 7.2.3 DiscussionIn Red Hat, Fedora, Mandrake, and Slackware, changing runlevels is one way to kill an X session, because runlevel 3 boots to a text console. However, it's rather drastic, as it stops and restarts all services and boots out all logged-in users. Why change runlevels with init? Here are some good reasons:
Bad reasons include:
There are other, better ways to manage switching between X sessions and console sessions, as you'll see in Recipe 7.4, Recipe 7.4. telinit works too, as it's simply a hard link to init ("tell init"—more clever geek wordplay): $ ls -al /sbin/telinit
lrwxrwxrwx 1 root root 4 Oct 31 07:51 /sbin/telinit -> init 7.2.4 See Also
|
< Day Day Up > |