2.7. Exercises and Summary

2.7.1. Review Questions

  1. What is the PID for /sbin/init?

  2. Which tool will print the current runlevel?

  3. Which tool will switch from one runlevel to another?

  4. How can you force init to read its configuration file?

    1. killall -HUP init

    2. kill -1 1

    3. init restart

    4. init q

Table 2.5. Files

FilesDescription
/etc/init.d/directory containing all the scripts used to stop and start services at boot time
/etc/inittabSee inittab(5). The inittab file describes which processes are started at boot-up and during normal operation. init distinguishes multiple runlevels, each of which can have its own set of processes that are started

Table 2.6. Commands

CommandsDescription
initSee init(8). init is the parent of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab
shutdownSee shutdown(8). It brings the system down in a secure way. All logged-in users are notified that the system is going down, and login(1) is blocked. It is possible to shut the system down immediately or after a specified delay. All processes are first notified that the system is going down by the signal SIGTERM. This gives programs like vi(1) the time to save the file being edited, mail and news processing programs a chance to exit cleanly, etc. shutdown does its job by signalling the init process, asking it to change the runlevel

2.7.2. References

Take a look at the boot(7) manpage, it covers most of what we did in this module.

2.7.3. Exercises

  1. Use init to change your current runlevel (eg swtich between runlevel 3 and 5).

    - Print your current runlevel?

  2. Edit /etc/inittab

    • replace the shutdown command with shutdown -r -k -t1 now

    • save the file and make init reread its configuration file (eg run: killall -HUP init)

    • similarly, enable the Ctrl+Alt+Del in runlevel 3 only

  3. Edit /etc/inittab to add a new login prompt on tty9.

  4. Use dmesg to read the chipset of your ethernet card.

  5. Investigate differences between shutdown, halt and reboot.

    - Which option to shutdown will force an fsck at the next boot?

  6. Use the tools chkconfig or ntsysv to disable the sshd daemon in runlevel 2,3,4, and 5

    Verify that the symbolic links in the rc2.d, rc3.d, rc4.d and rc5.d directories have changed.

  7. Reboot the system. At the boot prompt give the appropriate init= parameter to skip /sbin/init and start a simple bash session.