SlideShare a Scribd company logo
1 of 14
Download to read offline
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

What's hot

Module 13 - Troubleshooting
Module 13 - TroubleshootingModule 13 - Troubleshooting
Module 13 - Troubleshooting
T. J. Saotome
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 
Bash shell
Bash shellBash shell
Bash shell
xylas121
 

What's hot (20)

Dns
DnsDns
Dns
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
Cn ipv4 addressing
Cn ipv4 addressingCn ipv4 addressing
Cn ipv4 addressing
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Ipc in linux
Ipc in linuxIpc in linux
Ipc in linux
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
Module 13 - Troubleshooting
Module 13 - TroubleshootingModule 13 - Troubleshooting
Module 13 - Troubleshooting
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Linux Boot Process
Linux Boot ProcessLinux Boot Process
Linux Boot Process
 
HSRP ccna
HSRP ccna HSRP ccna
HSRP ccna
 
DNS - Domain Name System
DNS - Domain Name SystemDNS - Domain Name System
DNS - Domain Name System
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Samba server
Samba serverSamba server
Samba server
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Dhcp
DhcpDhcp
Dhcp
 
Linux: LVM
Linux: LVMLinux: LVM
Linux: LVM
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Bash shell
Bash shellBash shell
Bash shell
 
An Introduction To Linux
An Introduction To LinuxAn Introduction To Linux
An Introduction To Linux
 

Similar to Linux : Booting and runlevels

101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot
Acácio Oliveira
 
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfWrite a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
sravi07
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
Etsuji Nakai
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
stilliegeorgiana
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
denneymargareta
 

Similar to Linux : Booting and runlevels (20)

101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot
 
2- System Initialization in Red Hat
2- System Initialization in Red Hat2- System Initialization in Red Hat
2- System Initialization in Red Hat
 
LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager LISA15: systemd, the Next-Generation Linux System Manager
LISA15: systemd, the Next-Generation Linux System Manager
 
linux monitoring and performance tunning
linux monitoring and performance tunning linux monitoring and performance tunning
linux monitoring and performance tunning
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfWrite a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
 
Linux startup
Linux startupLinux startup
Linux startup
 
Optimizing Linux Servers
Optimizing Linux ServersOptimizing Linux Servers
Optimizing Linux Servers
 
Pdf c1t tlawaxb
Pdf c1t tlawaxbPdf c1t tlawaxb
Pdf c1t tlawaxb
 
UNIX Notes
UNIX NotesUNIX Notes
UNIX Notes
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Lec 3
Lec 3 Lec 3
Lec 3
 
Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)Linux Server Deep Dives (DrupalCon Amsterdam)
Linux Server Deep Dives (DrupalCon Amsterdam)
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
Linux
LinuxLinux
Linux
 
UNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdfUNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdf
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

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