Linux change the runlevel for a server without rebooting

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
$ 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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 6 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • Peko Apr 6, 2009 @ 18:32

    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

  • Jim H. Aug 13, 2009 @ 22:46

    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.

    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?


  • A different Jim H. Jan 4, 2011 @ 17:03

    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

  • Anil Apr 17, 2011 @ 4:38

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

  • deepak May 17, 2011 @ 18:26

    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

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum