Linux change the runlevel for a server without rebooting

by Vivek Gite · 3 comments

Q. How do I change the runlevel for a Linux server without rebooting my server? I am using Gentoo Linux.

A. Almost all Linux distribution use init program to change runlevel. init is the parent of all processes. Its primary role is to create processes from a script stored in the file
/etc/inittab . This file usually has entries which cause init to spawn gettys on each line that users can log in. It also controls autonomous processes required by any particular system.

To change runlevel from 3 to 1 you need to type command as follows:
# init 1
OR
$ sudo init 1

Where 1 is runlevel number, other possible runlevel values are:
=> 0 - Shutdown server
=> 1 - Take server to single-user mode
=> 2 - Start X Window (used by Debian)
=> 3 - Full multi-user text mode
=> 5 - Start X Window
=> 6 - Reboot server

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 3 comments… read them below or add one }

1 Peko 04.06.09 at 6:32 pm

Hi Vivek,

Just typos : X is spelled X Window – Capital W, and without an “s”

so not “Start X windows” … but “Start X Window”

Thumbs up anyway

– Peko

2 Vivek Gite 04.06.09 at 7:00 pm

No problem. The FAQ has been updated.

3 Jim H. 08.13.09 at 10:46 pm

Another way to do this is by using “telinit”

Telinit allows you to spawn a session at a different runlevel than your current session – and return to it when you are done.

Example:
I have a Fedora box that I use primarily as a Samba file server on my network – and I have it set to auto-start in runlevel 3 – no graphics – to preserve processor bandwidth for actual file handling. Since I do most of my SMB maintainance through SWAT, the text login is just fine.

Occasionally though, I want to use a graphical login – so I login to the text login and then sudo telinit 5. That spawns a graphical session I can log into, and then when I exit, I’m right back at the runlevel 3 terminal session.

It’s handy – especially if you need to pop into a graphical session every now and then – without clobbering your existing user context.

What say ye?

Jim

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All