techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 960
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Nov 18, 04, 19:47    Linux Runlevels explained
Linux has a what are known as runlevels. In windows you basically always are in runlevel 5, for all practical purposes, and there's really no other choice. Linux gives you a choice. What a surprise, no?

Some more serious Unix/Linux guys I met always set their machines to run in level 3, that's the basic command line mode, direct access to the kernel, no x window system running if I understand it right.

At times it can be useful to switch runlevels.

To do this live, simply type in this command [hit enter after each]:
su
[type in password]
telinit 3 [or: init 3]
[if you want to enter runlevel 3, to fix a configuration file, run some utility if you're having problem with the GUI desktop, and for many other reasons]. For serious servers of course there's no real need to use runlevel 5 at all, just uses up system resources.

In run level 3, if you wanted to modify a configuration file, you could use the command:
pico /yourfolder/config_file

Pico is a nice simple command line text editor, a good one for newbies. Emacs and vi are much more powerful, but also very hard to learn. One step at a time. If pico isn't available, nano is excellent, that's my personal choice, it's very easy to use, unlike the fabled vi or emacs.

:: Quote ::
Linux systems today generally use eight runlevels. Runlevels define what services or processes should be running on the system. The init process can run the system in one of eight runlevels. The system runs only one of the eight runlevels at a time. The main runlevels are from 0 � 6.

Runlevel - System State
  • 0 - Halt the system
  • 1 - Single-user mode
  • 2 - Multi-user mode (without NFS)
  • 3 - Multi-user mode
  • 4 - unused
  • 5 - Multi-user mode, graphical login
  • 6 - Reboot the system

Runlevels 1 and 2 are generally used for debugging purposed only, and are not used during normal operations. Most desktop linux distributions boot into runlevel 5, which starts up the Graphical Login Prompt. Most servers boot into runlevel 3, which starts the text based login prompt.

Linux runlevels can be changed on the fly using the init tool. If you want to switch from text based operations to the Graphical Interface, you just have to type in telinit 5 in the root prompt. This will bring up the Graphical Interface in your system.

Each runlevel can be configured by the system administrator. The "/etc/inittab" file has information on which runlevel to start the system at and lists the processes to be run at each runlevel.

Each runlevel has its own directory structure where you can define the order in which the services start. These directories are located in the /etc/rc.d/ directory, under which you have rc1.d, rc2.d, rc3.d�. rc6.d directories where the number from 0 through 6 that corresponds to the runlevel. Inside each directory are symbolic links that point to master initscripts found in /etc/init.d or /etc/rc.d/init.d.

You can also change the runlevel at boot time. If your system uses LILO as the boot manager, you can append the runlevel to the boot command :
LILO: linux 3 or
LILO: linux 5

If your system uses GRUB, you can change the boot runlevel by pressing the `e� key to edit the boot configuration. append the runlevel to the end of the boot command as shown:
kernel /vmlinuz ro root=/dev/hda1 5
src: vinuthomas.com under Creative Commons license.


And so on, step by step we'll get into this thing.

The main advantage of being able to switch runlevels is that if you're in runlevel 5, and it's not working, you can jump down to 3, fix the problem, like in this case hopefully, then jump back up. No reboots, begins to give you a sense that unlike with Windows, you have a series of options to move to when you run into problems.

Runlevel 3 is where you want to be to do things like full system upgrades with apt, if you are ugrading kde for example, never do that while in runlevel 5, gui mode, that can cause all kinds of unpleasant and hard to fix errors.

You can read more on runlevels at debianhelp.

Most linux stability problems I've seen so far are due to software, or the desktop systems, the kernel itself is very solid as a rule.
Display posts from previous:   

All times are GMT - 8 Hours