Linux Changing Run Levels

by nixcraft · 5 comments

Recently I was taking class for Linux sys admin course. Some one asked me "How do changing run levels affect us or our users?" I replied with following answer:
Well if you are moving to higher run levels, you may make additional services available to users, while moving to a lower run level will causes to services (daemons) to become unavailable. On production server run level 3 is the normally used and rarely changed. However some administrative tasks require the administrator to move system to run level 1 i.e single user mode.

Use the init command to change rune levels:

# init 1

Runlevel and usage:

  • Runlevel 0 is halt
  • Runlevel 1 is single-user
  • Runlevels 2-5 are multi-user (some distro uses RUN level 5 to start X [KDE/Gnome])
  • Runlevel 6 is for rebooting system

Typing init 3 will move system to run level 3:

# init 3

On most Linux server system default run level is 3 and on most Linux Desktop system default run level is 5. The default run level is defined by the initdefault line at the top of /etc/inittab. So if you wanna change default run level open file /etc/inittab and edit entry initdefault:

# vi /etc/inittab

Set initdefault to 5, so that you can boot to X next time when Linux comes up:

id:5:initdefault:

Save file and reboot to see changes.

getty is the program which opens a tty port, prompts for a login name and password (via /bin/login command). Your console displays a login/password prompt at run levels 1 through 6. You can use ALT+F1...ALT+F6 keys to switch console (use CTRL+ALT+F1..F6 under X windows).

However my experience so far is that students get confused with ssh and KDE/Gnome Desktop login.
SSH logins are handled by sshd server which starts at run level 2/3. KDE/Genome Desktop login are handled by GDM/XDM/KDM display manager which starts at run level 5 (however Debian Linux and some other distro can start them from run level 2 via special rc.d script located in /etc/init.d/gdm)

Related articles:

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!

{ 5 comments… read them below or add one }

1 matt 10.17.05 at 2:38 pm

you have some good content! i’m reading this blog since last 4+ months; althoug it is not updated daily like other blog/sites still it makes a good read as it is based upon Linux/UNIX sys admins hard core experince
considering only 1 or 2 perople contributes to this blog it is a good read and you have Good number of hits as well. Just wanna say good job man & keep it up

2 Anonymous 10.17.05 at 2:44 pm

my questions is very simple how do i find out current runlevel as well as last runlevel? since you take linux sys admin class you must have some info :D

–bha

3 cyberciti 10.17.05 at 6:31 pm

> how do i find out current runlevel as well as last runlevel?
Use who -r command
$ who -r
run-level 2 Oct 17 18:21 last=S

4 cyberciti 10.17.05 at 6:34 pm

Thanks matt :) We don’t update our blog everyday, as and when event occurs in our life it is get documented here.

I appreciate your post.

5 marco 09.03.08 at 2:27 am

you have a little typo: Genome

if the typo is fixed you can delete my comment.

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 post:

Next post: