BCE-C712 Linux System Administration

0 of 74 lessons complete (0%)

Starting up and Shutting Down

init and the inittab File

You don’t have access to this lesson

Please register or sign in to access the course content.

In Unix-like operating systems, init is the first process that gets started by the kernel during system initialization. It has a process ID (PID) of 1 and serves as the ancestor of all other processes. The init process is responsible for bringing the system to a working state, including starting system services and managing run levels.

/etc/inittab (pronounced “init tab”) is a configuration file used by the init process to determine the behavior of the system during startup and when transitioning between run levels. It is commonly found on older Unix systems that use the System V init system. However, newer systems, particularly those using systemd, may not use this file.

Here are some key points about /etc/inittab:

  1. Configuration Entries:
    • The file /etc/inittab contains entries that define how the system should behave in different run levels. Each entry is a line in the file.
  2. Run Levels:
    • The file specifies the default run level for the system. For example, it might designate run level 3 as the default, which is typically a multi-user mode with networking.
  3. Init Actions:
    • Entries in /etc/inittab can specify actions to be taken during various system events, such as when the system starts up, shuts down, or switches run levels.
  4. getty Processes:
    • init uses entries in /etc/inittab to spawn getty processes, which provide login prompts on virtual terminals.
  5. Comments and Blank Lines:
    • Lines starting with # are comments and are ignored by the init process. Blank lines are also ignored.
  6. Format:
    • Entries in /etc/inittab have a specific format, typically consisting of several fields separated by colons (:). The fields specify things like run level, action, process, and more.

As an example, a line in /etc/inittab might look like:

id:3:initdefault:

In this example, the line sets the default run level to 3.

It’s important to note that the use of /etc/inittab may be specific to older Unix-like systems, and more modern systems may use different initialization systems like systemd. As such, the specific behavior and configuration files can vary depending on the system you are using.

init Runlevels with Usecases

Remember to always exercise caution when changing run levels, especially in production environments, as it can potentially disrupt services and processes. Ensure you’ve saved any important work and have a backup before making major system changes. Additionally, be aware that on modern systems using systemd, different commands and utilities are typically used for managing services and system states.

  1. Maintenance or System Recovery:
    • When you need to perform maintenance tasks or recover from a system issue, you might switch to single-user mode (Run Level 1) to have minimal services running.
    sudo init 1
  2. Troubleshooting Network Issues:
    • If you’re experiencing networking problems, you might switch to multi-user mode with networking (Run Level 3) to have all essential networking services active without the graphical interface.
    sudo init 3
  3. Graphical User Interface Issues:
    • If you encounter problems with the graphical user interface, switching to multi-user mode with GUI (Run Level 5) can help you isolate and troubleshoot the issue.
    sudo init 5
  4. Performing System Updates or Upgrades:
    • When you need to update or upgrade the system, it’s often recommended to do so in single-user mode (Run Level 1) to minimize potential conflicts and ensure a clean update process.
    sudo init 1
  5. Restarting the System After Configuration Changes:
    • After making significant configuration changes, it may be necessary to reboot the system to apply the changes. You can do this using the reboot command.
    sudo init 6
  6. Shutting Down the System:
    • When you want to power off the system, you can switch to run level 0, which initiates the shutdown process.
    sudo init 0

Remember to always exercise caution when changing run levels, especially in production environments, as it can potentially disrupt services and processes. Ensure you’ve saved any important work and have a backup before making major system changes. Additionally, be aware that on modern systems using systemd, different commands and utilities are typically used for managing services and system states.