Wednesday 19 April 2017

What’s a run-level?

A runlevel is a preset operating state on a Unix-like operating system.  
The are differences in the runlevels according to the operating system. Seven runlevels are supported in the standard Linux kernel (i.e., core of the operating system). They are:

0 - System halt.
1 - Single user.
2 - Multiple users with no NFS.
3 - Multiple users under the command line.
4 - User-definable.
5 - Multiple users under a GUI.
6 - Reboot

 Details:::::::::::::::
  • Runlevel 0 - The halt runlevel. This is the runlevel at which the system shuts down. For obvious reasons it is unlikely you would want this as your default runlevel.
  • Runlevel 1 – Causes the system to start up in a single user mode under which only the root user can log in. In this mode the system does not start any networking, X windowing or multi-user services. This run level is ideal for system administrators to perform system maintenance or repair activities.
  • Runlevel 2 - Boots the system into a multi-user mode with text based console login capability. This runlevel does not, however, start the network.
  • Runlevel 3 - Similar to runlevel 2 except that networking services are started. This is the most common runlevel for server based systems that do not require any kind of graphical desktop environment.
  • Runlevel 4 - Undefined runlevel. This runlevel can be configured to provide a custom boot state.
  • Runlevel 5 - Boots the system into a networked, multi-user state with X Window System capability. By default the graphical desktop environment will start at the end of the boot process. This is the most common run level for desktop or workstation use.
  • Runlevel 6 - Reboots the system. Another runlevel that, for obvious reasons, you are unlikely to want as your default. 


Configuring the Default RHEL 6 Runlevel

The default runlevel for an RHEL system is defined within the /etc/inittab file. To identify the current default level or change the default to a different setting, load this file into an editor (keeping in mind that root privileges will be required).
The relevant section of a sample /etc/inittab file is as follows:
# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
The key line in the example above is the initdefault setting:
id:3:initdefault:
This tells the init process that the default run level for the system is runlevel 3. To change to a different run level simply change the number to the desired runlevel and save the /etc/inittab file.


Changing the Current Runlevel from within a Running RHEL 6 System

The current runlevel of a running RHEL system can be changed using the init command combined with the new target runlevel. For the sake of an example, assume that an RHEL system is currently running at runlevel 3. In order to change to level 5 (thereby activating the desktop environment), the following init command would need to be executed at the command-line prompt:

init 5
 
The desktop environment will then start up and the login screen will be displayed.

Identifying Services that Start at Each Runlevel

There are number of ways to identify which services get started without having to delve into the /etc/rc.d sub-directories. The command line tool chkconfig (usually located in the /sbin directory) can be used to list which services get started at boot time. To list all service settings run the following command:
/sbin/chkconfig --list
This will display a long list of services showing whether or not they are started up at various runlevels. You may want to narrow the search down using the grep tool. For example to list the entry for the sshd daemon, execute the following command:
/sbin/chkconfig --list | grep sshd
When run, the above command should result in something output similar to the following:
sshd           0:off   1:off   2:on   3:on    4:on   5:on    6:off
The above output indicates that the sshd service is started automatically at runlevels 2, 3, 4, and 5. Alternatively you may just be interested to know which services get started for runlevel 3:
/sbin/chkconfig --list | grep '3:on'


Changing the Services for a Runlevel

In addition to listing services, chkconfig can also be used to change the settings for a particular runlevel. If, for example, we wanted the httpd service to start up at runlevel 5 we would issue the following command:
/sbin/chkconfig --level 5 httpd on
A number of graphical tools are also available for administering services. On RHEL you can select the System -> Administration -> Services or System -> Administration -> Server Settings -> Services menu option or run the following command:
system-config-services



 

Popular Posts

Recent Posts

Unordered List

Categories

Text Widget

Powered by Blogger.

Home - PageNavi (show/hide)

Ads

Pages