Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
The /etc/inittab
file is a configuration file in older Linux systems that is used by the init process (System V-style init) to define the default runlevel and control how processes are spawned at boot time. However, it is essential to note that many modern Linux distributions, such as those using systemd
, have deprecated the use of /etc/inittab
and replaced it with more advanced initialization systems. This tutorial will focus on older Linux systems that still use the /etc/inittab
file.
Here's a tutorial on the /etc/inittab
file:
Structure of /etc/inittab
file:
The /etc/inittab
file consists of multiple lines, each with the following format:
id:runlevels:action:process
id
: A unique identifier for the entry (usually 1-4 characters)runlevels
: A list of runlevels (0-6, S or s) to which the entry appliesaction
: The action to be taken when the entry is processedprocess
: The command to be executed when the action is performedFor example:
l2:2:wait:/sbin/login
Read the /etc/inittab
file:
Use the cat
or less
command to read the /etc/inittab
file:
cat /etc/inittab
or
less /etc/inittab
Common Actions:
initdefault
: Sets the default runlevel for the systemsysinit
: Executes the specified process early in the boot process, usually for system initialization taskswait
: Executes the specified process and waits for its completion before proceeding to the next entryrespawn
: Executes the specified process and restarts it when it terminatesonce
: Executes the specified process once, without respawning itEdit the /etc/inittab
file:
To modify the /etc/inittab
file, open it with your preferred text editor as the root user:
sudo nano /etc/inittab
or
sudo vim /etc/inittab
Make the desired changes, save the file, and exit the editor.
Apply changes to the /etc/inittab
file:
To apply the changes made to the /etc/inittab
file without rebooting, use the telinit
command to notify the init process to re-examine the /etc/inittab
file:
sudo telinit q
By understanding the purpose and configuration of the /etc/inittab
file, you can manage the init process in older Linux systems that still rely on System V-style init. Remember that modern Linux distributions have replaced /etc/inittab
with other mechanisms like systemd
, so this tutorial may not be applicable to the latest systems.
How to set default runlevel in Linux /etc/inittab:
The /etc/inittab
file in Linux defines the default runlevel. To set the default runlevel:
Open /etc/inittab
in a text editor and locate the line with initdefault
. Change the runlevel parameter to the desired runlevel, for example:
id:3:initdefault:
This sets the default runlevel to 3.
Viewing and editing inittab file in Linux:
To view and edit the /etc/inittab
file:
cat /etc/inittab
To edit:
sudo nano /etc/inittab
Setting initdefault parameter in /etc/inittab:
Set the initdefault
parameter to the desired runlevel. For example, to set runlevel 5 as the default:
id:5:initdefault:
Switching between runlevels using /etc/inittab:
To switch between runlevels, use commands like telinit
. For example, to switch to runlevel 3:
sudo telinit 3