Here, there was no previous runlevel, and the current runlevel is 3.
To change the runlevel temporarily,
[root@example ~]# init RUNLEVEL
To permanently change the default runlevel of the machine, change /etc/inittab's
id:5:initdefault:
Change 5 to your preferred level.
If you're using RHEL or one of the clone distributions like CentOS, the default runlevel will be 3 for servers, and 5 for desktops where X should be started automatically.
If you're using Debian or its various offshoots, the default runlevel will be 2.
Ubuntu has moved to the upstart task selection program, so it may lack /etc/inittab and will use runlevel 2 by default. Create one if you want to change the default runlevel, or you can pass the runlevel as part of startup through grub.
To change the runlevel of a daemon:
If you're using RHEL or another RPM-based distro, chkconfig will probably be the most convenient way.
[root@example ~]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@example ~]# chkconfig ntpd on
[root@example ~]# chkconfig ntpd off
[root@example ~]# chkconfig --level 2,5 ntpd on
If you're using Debian, I usually manually change the status of a daemon per runlevel.
[root@example ~]# ls /etc/rc2.d/*ntp*
/etc/rc2.d/S23ntp
[root@example ~]# cd /etc/rc2.d/
[root@example rc2.d]# mv K23ntpd S23ntpd
If the symlink for the daemon begins with K, it's stopped at that runlevel. If it starts with S, it is started at that runlevel.
2 is going to be system dependent. On RedHat based systems (RH, YDL, Fedora, etc) then you'll use chkconfig to configure everything. As an example, to have apache start at runlevels 3, 4, and 5, you would run:
chkconfig --levels 345 httpd on
On a gentoo system you would use the rc-update tool, and run these commands:
For RHEL, look for the following line in /etc/inittab
id:5:initdefault:
The number in this line if the default run level. You can set it to the following options:
# 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)
Daemons are usually started from scripts in /etc/rc.d/ or /etc/init.d
There are symlinks to the corresponding startscript from a runlevel specific directory (e.g. /etc/rc0.d to /etc/rc6.d)
In short: create a link from the respective directory in /etc/rc.d to the startscript of the daemon. The location of the link determins the runlevel.
To see the previous and current runlevel,
Here, there was no previous runlevel, and the current runlevel is 3.
To change the runlevel temporarily,
To permanently change the default runlevel of the machine, change /etc/inittab's
Change 5 to your preferred level.
If you're using RHEL or one of the clone distributions like CentOS, the default runlevel will be 3 for servers, and 5 for desktops where X should be started automatically.
If you're using Debian or its various offshoots, the default runlevel will be 2.
Ubuntu has moved to the upstart task selection program, so it may lack /etc/inittab and will use runlevel 2 by default. Create one if you want to change the default runlevel, or you can pass the runlevel as part of startup through grub.
To change the runlevel of a daemon:
If you're using RHEL or another RPM-based distro, chkconfig will probably be the most convenient way.
If you're using Debian, I usually manually change the status of a daemon per runlevel.
If the symlink for the daemon begins with K, it's stopped at that runlevel. If it starts with S, it is started at that runlevel.
You're really asking two questions.
1 is answered by Mark (His Answer)
2 is going to be system dependent. On RedHat based systems (RH, YDL, Fedora, etc) then you'll use chkconfig to configure everything. As an example, to have apache start at runlevels 3, 4, and 5, you would run:
On a gentoo system you would use the rc-update tool, and run these commands:
I really like sysv-rc-conf
If you have ubuntu : sudo apt-get install sysv-rc-conf
For RHEL, look for the following line in /etc/inittab
The number in this line if the default run level. You can set it to the following options:
There are a few different places. However, the following should cover most of the them:
check in /etc/inittab use the "chkconfig" command to update the rcX.d directories with symbolic links to the /etc/init.d entries.
Daemons are usually started from scripts in /etc/rc.d/ or /etc/init.d There are symlinks to the corresponding startscript from a runlevel specific directory (e.g. /etc/rc0.d to /etc/rc6.d)
In short: create a link from the respective directory in /etc/rc.d to the startscript of the daemon. The location of the link determins the runlevel.
For the server part, i normally use telinit
<
runlevel>
or you can do init<
runlevel>