Contolling startup scripts using chkconfig. chkconfig examples Linux.

An update to this post if your distro is using upstart or any other service for start up i.e openrc, systemd this might not or wont work!

Alot of distros are migrating from system V init at time of edit (so this may be out dated, Debian/Ubuntu (upstart), RHEL6/CentOS6 (upstart). chkconfig will/might still be available but isnt guaranteed to work! If your using upstart alot may still work as it still sits on top off system V init, it all depends on distro though and what parts are handled by upstart and which are still handled by system V init).

chkconfig examples Linux a guide to controlling which services start during boot.

Listing current chkconfig settings.

chkconfig --list

Add a service to the chkconfig startup list if not already there. In this example vsftpd.

chkconfig --add vsftpd

To set the service to start during boot (Will add to runlevels 2,3,4 and 5).

chkconfig vsftpd on

To add to a specific runlevel 3 in this example.

chkconfig --level 3 vsftpd on

To disable a service on boot will turn to off for all runlevels.

chkconfig vsftpd off

To disable at a specific runlevel.

chkconfig --level 3 vsftpd off

To chkconfig remove a service from the chkconfig setup.

chkconfig  --del vsftpd

Linux runlevels.

Linux has 6 different runlevels all which have there seperate configuration.

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

runlevels may vary from distro to distro but this is usually only levels 2 and 4 which are usually reserved.

To change the current runlevel from command line

init runlevel

Examples

reboot the system.

init 6

Start a gui when booted into terminal (switching from runlevel 3 to runlevel 5).

init 5

Shutdown the system.

init 0

Linux, Virtual & Dedicated Servers , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

three + fourteen =