SlideShare a Scribd company logo
Booting Linux &
Runlevels
Understanding the Boot Process
& the different runlevels.
By John Troon
Extracting Information about the
Boot Process
● To view information logged by the Linux kernel
and modules stored in the kernel ring buffer.
● dmesg
● dmesg | less
● dmesg > boot.messages
● cat /var/log/dmesg
● system logger ( syslogd )
Locating & Interpreting Boot
Messages
● Use less and Its search functions
● Look for Hardware type names (SCSI/USB etc)
● Look for Hardware Chipset names
● Study the output from a working System
The Boot Process
 Going to the nitty gritty details of the boot process is complex.
Below is a high-level view of the boot process.
● Power the machine & CPU runs the firmware.
●
The firmware performs some tasks.
●
Boot-loader takes over from the firmware & loads a kernel.
●
Linux kernel takes over,initializing devices, mounting the root
partition & executes /sbin/init
●
The initial program gets the process ID (PID) of 1. Commonly,
/sbin/init reads the /etc/inittab
http://www.linuxdevcenter.com/pub/a/linux/excerpts/linux_kernel/ho
w_computer_boots.html
Dealing with Runlevels and the
Initialization Process
● Linux relies on runlevels (0-6) to determine what features are available.
● 0 - A transitional runlevel, on/off (shuts down).
● 1,s, or S - Single-user mode. Used for low-level system maintenance
● 2 - On Debian and its derivatives, a full multi-user mode with X.
Undefined in others.
● 3 – In most distributions, a full multi-user mode with a console.
● 4 - Usually undefined by default and therefore available for
customization.
● 5 – In most distributions, the same behavior as runlevel 3 with the
addition of having X.
● 6 - Also a transitional runlevel. Used to reboot the system.
Identifying the Services in a Runlevel
● There are two main ways to affect what
programs run when you enter a new SysV
runlevel.
1) add or delete entries in your /etc/inittab file
2) the SysV Startup Scripts
Distributions based on Upstart and systemd often
provide startup scripts that are named and work
much like on SysV-based computers; however, whe
the computer boots, it may use other startup
methods, as described later, in “Using Alternative
Boot Systems.”
Managing Runlevel Services
● # chkconfig –list
● # chkconfig --list nfs-common
● # chkconfig --level 23 nfs-common on
● # chkconfig --add nfs-common
Checking Your Runlevel
1) Checking and changingyour default runlevel.
# grep :initdefault: /etc/inittab
Edit the initdefault line in /etc/inittab & change
the runlevel field to the value you want.
2) Determining Your Current Runlevel : # runlevel
The fi rst character is the previous runlevel.
When the character is N , this means the
system hasn’t switched runlevels since booting.
Changing Runlevels on a Running
System
● Changing Runlevels with init or telinit
The init process is the fi rst process run by the
Linux kernel, but you can also use it to have the
system reread the /etc/inittab fi le and
implement changes it fi nds there or to
changeto a new runlevel.
● # init 1 - reserved for single-user mode
● # init 6 - reboot the system
A variant of init is telinit
● This program can take a runlevel number just like init to
change to that runlevel.
● It can also take the Q or q option to have the tool reread
/etc/inittab and implement any changes it finds there.
● Thus, if you’ve made a change to the runlevel in
/etc/inittab, you can immediately implement that change by
typing telinit q .
● The Upstart and systemd tools provide init and telinit
commands that work much as they do on SysV-based
computers.
Changing Runlevels with shutdown
● shutdown is invoked with a time:
# shutdown now
● The now parameter causes the change to occur
immediately. Other possible time formats include hh:mm ,
for a time in 24-hour format.
● -r reboots, -H halts, -P powers it off
● shutdown -r +10 to reboot the system in 10 min
● shutdown -h +15 “system going down for maintenance”
● shutdown -c “never mind” -c option to cancel it.
halt, reboot, and powerof
Three additional shortcut commands are halt ,
reboot , and poweroff .
In reality, reboot and poweroff are usually symbolic
links to halt . This command behaves differently
depending on the name with which it’s called.
As you might expect, these commands halt the
system (shut it down without powering it off), reboot
it, or shut it down and (on hardware that supports
this feature) turn off the power, respectively.
EXERCISE 5.1
● Page 248
● Changing Runlevels
Question(s)?
John Troon
Email: troon@linuxmail.org
Twitter: @johntroony

More Related Content

PPTX
Linux Run Level
PPTX
File permissions
PDF
Linux systems - Linux Commands and Shell Scripting
PPTX
Filepermissions in linux
PPT
Linux command ppt
PPTX
User management
PDF
netfilter and iptables
PDF
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Linux Run Level
File permissions
Linux systems - Linux Commands and Shell Scripting
Filepermissions in linux
Linux command ppt
User management
netfilter and iptables
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication

What's hot (20)

PPTX
QCM de question sur examen red hat 7.pptx
PPTX
Users and groups
PPT
Storage Management in Linux OS.ppt
PDF
netLec5.pdf
ODP
Linux commands
PDF
Hypervisors
PPTX
Semaphore
PPTX
Introducción a shell script
PPTX
PostgreSQL Database Slides
PPT
Basic 50 linus command
PPT
Linux Administration
PDF
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
PPT
Basic command ppt
DOC
Some basic unix commands
PPTX
Linux User Management
PPTX
Process management in linux
PDF
Operating systems system structures
PDF
Tp n 4 linux
PDF
Basic linux commands
PDF
QCM de question sur examen red hat 7.pptx
Users and groups
Storage Management in Linux OS.ppt
netLec5.pdf
Linux commands
Hypervisors
Semaphore
Introducción a shell script
PostgreSQL Database Slides
Basic 50 linus command
Linux Administration
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Basic command ppt
Some basic unix commands
Linux User Management
Process management in linux
Operating systems system structures
Tp n 4 linux
Basic linux commands
Ad

Similar to Linux : Booting and runlevels (20)

PPT
101 1.3 runlevels , shutdown, and reboot
PPTX
2- System Initialization in Red Hat
PDF
LISA15: systemd, the Next-Generation Linux System Manager
PDF
linux monitoring and performance tunning
PPT
Linux Booting Process
PDF
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
PPTX
Linux startup
ODP
Optimizing Linux Servers
PDF
Pdf c1t tlawaxb
PPTX
UNIX Notes
PDF
OS - Process Concepts
PDF
Lec 3
PDF
Linux Server Deep Dives (DrupalCon Amsterdam)
PDF
Your first dive into systemd!
DOCX
Project Guide for Modifying Kernel Source
DOCX
Programming Assignment #2CSci 430 Spring 2019Dates.docx
DOCX
Programming Assignment #2CSci 430 Spring 2019Dates.docx
PPT
PDF
UNIT - 3 PPT(Part- 1)_.pdf
PDF
Operating System-Concepts of Process
101 1.3 runlevels , shutdown, and reboot
2- System Initialization in Red Hat
LISA15: systemd, the Next-Generation Linux System Manager
linux monitoring and performance tunning
Linux Booting Process
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Linux startup
Optimizing Linux Servers
Pdf c1t tlawaxb
UNIX Notes
OS - Process Concepts
Lec 3
Linux Server Deep Dives (DrupalCon Amsterdam)
Your first dive into systemd!
Project Guide for Modifying Kernel Source
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
UNIT - 3 PPT(Part- 1)_.pdf
Operating System-Concepts of Process
Ad

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Machine learning based COVID-19 study performance prediction
PPTX
sap open course for s4hana steps from ECC to s4
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
NewMind AI Weekly Chronicles - August'25 Week I
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Approach and Philosophy of On baking technology

Linux : Booting and runlevels

  • 1. Booting Linux & Runlevels Understanding the Boot Process & the different runlevels. By John Troon
  • 2. Extracting Information about the Boot Process ● To view information logged by the Linux kernel and modules stored in the kernel ring buffer. ● dmesg ● dmesg | less ● dmesg > boot.messages ● cat /var/log/dmesg ● system logger ( syslogd )
  • 3. Locating & Interpreting Boot Messages ● Use less and Its search functions ● Look for Hardware type names (SCSI/USB etc) ● Look for Hardware Chipset names ● Study the output from a working System
  • 4. The Boot Process  Going to the nitty gritty details of the boot process is complex. Below is a high-level view of the boot process. ● Power the machine & CPU runs the firmware. ● The firmware performs some tasks. ● Boot-loader takes over from the firmware & loads a kernel. ● Linux kernel takes over,initializing devices, mounting the root partition & executes /sbin/init ● The initial program gets the process ID (PID) of 1. Commonly, /sbin/init reads the /etc/inittab http://www.linuxdevcenter.com/pub/a/linux/excerpts/linux_kernel/ho w_computer_boots.html
  • 5. Dealing with Runlevels and the Initialization Process ● Linux relies on runlevels (0-6) to determine what features are available. ● 0 - A transitional runlevel, on/off (shuts down). ● 1,s, or S - Single-user mode. Used for low-level system maintenance ● 2 - On Debian and its derivatives, a full multi-user mode with X. Undefined in others. ● 3 – In most distributions, a full multi-user mode with a console. ● 4 - Usually undefined by default and therefore available for customization. ● 5 – In most distributions, the same behavior as runlevel 3 with the addition of having X. ● 6 - Also a transitional runlevel. Used to reboot the system.
  • 6. Identifying the Services in a Runlevel ● There are two main ways to affect what programs run when you enter a new SysV runlevel. 1) add or delete entries in your /etc/inittab file 2) the SysV Startup Scripts Distributions based on Upstart and systemd often provide startup scripts that are named and work much like on SysV-based computers; however, whe the computer boots, it may use other startup methods, as described later, in “Using Alternative Boot Systems.”
  • 7. Managing Runlevel Services ● # chkconfig –list ● # chkconfig --list nfs-common ● # chkconfig --level 23 nfs-common on ● # chkconfig --add nfs-common
  • 8. Checking Your Runlevel 1) Checking and changingyour default runlevel. # grep :initdefault: /etc/inittab Edit the initdefault line in /etc/inittab & change the runlevel field to the value you want. 2) Determining Your Current Runlevel : # runlevel The fi rst character is the previous runlevel. When the character is N , this means the system hasn’t switched runlevels since booting.
  • 9. Changing Runlevels on a Running System ● Changing Runlevels with init or telinit The init process is the fi rst process run by the Linux kernel, but you can also use it to have the system reread the /etc/inittab fi le and implement changes it fi nds there or to changeto a new runlevel. ● # init 1 - reserved for single-user mode ● # init 6 - reboot the system
  • 10. A variant of init is telinit ● This program can take a runlevel number just like init to change to that runlevel. ● It can also take the Q or q option to have the tool reread /etc/inittab and implement any changes it finds there. ● Thus, if you’ve made a change to the runlevel in /etc/inittab, you can immediately implement that change by typing telinit q . ● The Upstart and systemd tools provide init and telinit commands that work much as they do on SysV-based computers.
  • 11. Changing Runlevels with shutdown ● shutdown is invoked with a time: # shutdown now ● The now parameter causes the change to occur immediately. Other possible time formats include hh:mm , for a time in 24-hour format. ● -r reboots, -H halts, -P powers it off ● shutdown -r +10 to reboot the system in 10 min ● shutdown -h +15 “system going down for maintenance” ● shutdown -c “never mind” -c option to cancel it.
  • 12. halt, reboot, and powerof Three additional shortcut commands are halt , reboot , and poweroff . In reality, reboot and poweroff are usually symbolic links to halt . This command behaves differently depending on the name with which it’s called. As you might expect, these commands halt the system (shut it down without powering it off), reboot it, or shut it down and (on hardware that supports this feature) turn off the power, respectively.
  • 13. EXERCISE 5.1 ● Page 248 ● Changing Runlevels