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

Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
Raghu nath
 

What's hot (20)

Linux Run Level
Linux Run LevelLinux Run Level
Linux Run Level
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux standard file system
Linux standard file systemLinux standard file system
Linux standard file system
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
User Administration in Linux
User Administration in LinuxUser Administration in Linux
User Administration in Linux
 
Linux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platformLinux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platform
 
Linux booting Process
Linux booting ProcessLinux booting Process
Linux booting Process
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
Linux fundamentals
Linux fundamentalsLinux fundamentals
Linux fundamentals
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
Linux distributions
Linux    distributionsLinux    distributions
Linux distributions
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Basics of-linux
Basics of-linuxBasics of-linux
Basics of-linux
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Introduction to Linux
Introduction to Linux Introduction to Linux
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

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...Stronger Together: Developing an Organizational Strategy for Accessible Desig...
Stronger Together: Developing an Organizational Strategy for Accessible Desig...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 

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