Linux change the runlevel for a server without rebooting

by on November 9, 2006 · 6 comments· LAST UPDATED April 6, 2009

in

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 6 comments… read them below or add one }

1 Peko April 6, 2009 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

Reply

2 nixCraft April 6, 2009 at 7:00 pm

No problem. The FAQ has been updated.

Reply

3 Jim H. August 13, 2009 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

Reply

4 A different Jim H. January 4, 2011 at 5:03 pm

telinit looks very cool! I was actually looking for the init command, that I hadn’t used in so long I forgot it, but that’s a nice little extra that I sure could have used a couple years ago. I had a manager at one time that wanted a GUI on all of our Linux servers because he wasn’t as comfortable with the command line (being from a Windows background). I would have loved not having to run X full time even though he hardly ever touched those boxes. Thanks for the tip!

Other Jim

Reply

5 Anil April 17, 2011 at 4:38 am

How do I change the runlevel for a Linux server without rebooting my server? I am using ubuntu 10.4 version

Reply

6 deepak May 17, 2011 at 6:26 pm

i am facing a problem that the computer does not prompt for luks passphrase and moves on to the username and password.
how do i change the runlevel
where would i get to put the command
my files are stuck some where and i cannot locate them

Reply

Leave a Comment

Tagged as: , , , ,

Previous Faq:

Next Faq: