= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
In This Chapter
Determining The Default Boot runlevel
Get A Basic Text Terminal Without Exiting The GUI
How To Set Which Programs Run At Each runlevel
© Peter Harrison, www.linuxhomenetworking.com
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
The way Linux boots up is very important information to know. You can alter it to change the type of login screen you get and also which programs get started.
When RedHat boots, the boot process will run a number of scripts located in subdirectories under directory /etc/rc.d. The boot process first runs the scripts found in /etc/rc.d/rc1.d which provides only the most basic functionality and the ability to only handle a single user. This stage is known as “single user mode”. After completing this first phase, the boot process will run scripts in only one of the other directories depending on the startup mode (aka. run level). These are listed below.
|
Mode/Run Level |
Directory |
Run Level Description |
|
0 1 2 3 4 5 6 |
/etc/rc.d/rc0.d /etc/rc.d/rc1.d /etc/rc.d/rc2.d /etc/rc.d/rc3.d /etc/rc.d/rc4.d /etc/rc.d/rc5.d /etc/rc.d/rc6.d
|
Halt Single-user mode Not used (user-definable) Full multi-user mode (No GUI interface) Not used (user-definable) Full multi-user mode (With GUI interface) Reboot
|
The default boot runlevel is set in the file /etc/inittab with the "initdefault" variable. When set it to “3”, the system boots up with the text interface on the VGA console; when set to “5”, you get the GUI. Here is a sample snippet of the file: (Delete the initdefault line you don't need)
# 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:
# Console Text Mode
id:5:initdefault: # Console GUI Mode
· Most home users boot up with a Windows like GUI (Run Level 5)
· Most techies will tend to boot up with a plain text based command line type interface (Run level 3)
· Changing "initdefault" from 3 to 5 or vice-versa will only have an effect upon your next reboot. See the section below on how to get a GUI login all the time until the next reboot.
You have two main options if your system comes up in a text terminal mode on the VGA console and you want to get the GUI:
· Manual Method: You can start the X terminal GUI application each time you need it by running the “startx” command at the VGA console. Remember that when you log out you will get the regular text based console again.
[root@bigboy tmp]# startx
· Automatic Method: You can have Linux automatically start the X terminal GUI console for every login attempt until your next reboot by using the init command. You will need to edit your “initdefault” variable in your /etc/inittab file as mentioned in the preceding section to keep this functionality even after you reboot.
[root@bigboy tmp]# init 5
You can open a GUI based window with a command prompt inside by doing the following:
o Click on the “Red Hat” Start button in the bottom left hand corner of the screen.
o Click on Systems Tools, then Terminal
Linux actually has seven virtual console sessions running on the VGA console.
o Sessions one through six are text sessions. If the GUI is running, it will run under session number seven.
o You can step through each text session by using the <CTL> <ALT> <F1> through <F6> key sequence. You'll get a new login prompt for each attempt.
o You can get the GUI login with the sequence <CTL> <ALT> <F7>, only in run level 5, or if the GUI is running after launching "startx"
The "init" command will allow you to change the current runlevel.
[root@bigboy tmp]# init 0
[root@bigboy tmp]# init 6
Most RedHat packages place a startup script in the directory /etc/init.d and place symbolic links (pointers) to this script in the appropriate /etc/rc.d/rc.X directory. The typical home/SOHO user doesn't have to be a scripting / symbolic linking guru to make sure everything works right because RedHat comes with a nifty utility called "chkconfig" to do it for you.
· Use this command to get a full listing of packages listed in /etc/init.d and the runlevels at which they will be "on" or "off"
[root@bigboy tmp]# chkconfig --list
keytable 0:off 1:on 2:on 3:on 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on
6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
wlan 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
random 0:off 1:off 2:on 3:on 4:on 5:on 6:off
...
...
You can use chkconfig to change runlevels for particular packages. Here we see Sendmail will start with a regular startup at runlevel 3 or 5. Let’s change it so that Sendmail doesn't startup at boot.
[root@bigboy tmp]# chkconfig --list | grep mail
sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off
[root@bigboy tmp]#
[root@bigboy tmp]# chkconfig --level 35 sendmail off
[root@bigboy tmp]#
[root@bigboy tmp]# chkconfig --list | grep mail
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@bigboy tmp]#
[root@bigboy tmp]# chkconfig --level 35 mail on
[root@bigboy tmp]# chkconfig --list | grep mail
sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off
[root@bigboy tmp]#
· In most cases you'll want to modify runlevels 3 and 5 simultaneously AND with the same values.
· Don't add/remove anything to other runlevels unless you absolutely know what you are doing. Don't experiment.
· Chkconfig doesn’t start the programs in the /etc/init.d directory, it just configures them to be started or ignored when the system boots up. The commands for starting and stopping the programs covered in this book are covered in each respective chapter.