Chapter 8Chapter 8
Process ManagementProcess Management
Ref. Pge. 85
What is a process?What is a process?
●
A binary commandA binary command
●
Loaded into memoryLoaded into memory
●
Processed by CPUProcessed by CPU
●
Release memory when quitRelease memory when quit
●
Identified by PIDIdentified by PID
Process TreeProcess Tree
●
Every process is generated by parentEvery process is generated by parent
processprocess
●
Child process inherits environmentChild process inherits environment
from it's parentfrom it's parent
●
Child process returns a value to parentChild process returns a value to parent
when exitwhen exit
●
TheThe initinit is the root of process treeis the root of process tree
Process EnvironmentProcess Environment
●
PID/PPIDPID/PPID
●
UID/GIDUID/GID
●
Command NameCommand Name
●
VariablesVariables
●
ParametersParameters
●
File DescriptorsFile Descriptors
●
Data ...Data ...
Process Management UtilitiesProcess Management Utilities
●
pstreepstree
– Shows the whole process treeShows the whole process tree
– Common optionsCommon options
●
­p­p : with PID: with PID
●
­u­u : with user name: with user name
Process Management UtilitiesProcess Management Utilities
●
psps
– Shows process informationShows process information
– Common options (standard style)Common options (standard style)
●
­l­l : long format: long format
●
­e­e : every process: every process
– Common options (BSD style)Common options (BSD style)
●
aa : all process related to terminal: all process related to terminal
●
uu : user format: user format
●
xx : current user's process / all process with option: current user's process / all process with option aa
●
ww : whole line information: whole line information
Ref. Pge. 86
Process Management UtilitiesProcess Management Utilities
●
toptop
– Sorts process in order (default by CPU usage)Sorts process in order (default by CPU usage)
– Common options:Common options:
●
­d ­d nn : delay in: delay in nn seconds intervalseconds interval
●
­n ­n nn : refresh: refresh nn timestimes
●
­b­b : batch mode in pipe line: batch mode in pipe line
Ref. Pge. 90
Process UtilitiesProcess Utilities
– Common internal commands ofCommon internal commands of toptop::
●
<space> <space>  : refresh screen: refresh screen
●
h,?h,? : help: help
●
ss : delay second: delay second
●
rr : renice a process: renice a process
●
kk : kill a process: kill a process
●
F,OF,O : select sorting field: select sorting field
●
ii : toggle idle processes: toggle idle processes
●
qq : quit: quit
Process Management UtilitiesProcess Management Utilities
●
uptimeuptime
– Displays system running informationDisplays system running information
Job ControlJob Control
●
Foreground JobForeground Job
– Normal way to run a commandNormal way to run a command
– The job occupies the terminal till finishThe job occupies the terminal till finish
– Parent process stay in sleep statusParent process stay in sleep status
– Can be stopped by pressingCan be stopped by pressing ctrl­zctrl­z
●
Background JobBackground Job
– Ending withEnding with && when running a commandwhen running a command
– The shell prompt occurred for typing nextThe shell prompt occurred for typing next
commandcommand
– Parent process is still runningParent process is still running
Ref. Pge. 92
UsingUsing jobsjobs
●
jobsjobs
– Displays all background jobs in current shellDisplays all background jobs in current shell
– Common options:Common options:
●
­l­l : display PID: display PID
Job Control SwitchingJob Control Switching
●
fgfg
– Bring a background/stopped job to foregroundBring a background/stopped job to foreground
●
^z^z
– Stop a foreground jobStop a foreground job
●
bgbg
– Put a stopped job to backgroundPut a stopped job to background
foreground
background
stopped
^Z
bg
fg
fg
Process PriorityProcess Priority
●
Processes have different priorities toProcesses have different priorities to
consume the CPU time slices in two ways:consume the CPU time slices in two ways:
– PRI (priority)PRI (priority)
●
Higher value has more CPU timeHigher value has more CPU time
●
Dynamic adjusted by kernelDynamic adjusted by kernel
– NI (nice)NI (nice)
●
Higher value has less CPU timeHigher value has less CPU time
●
Adjusted by user: -20~19Adjusted by user: -20~19
Ref. Pge. 93
UsingUsing nicenice
●
nice [­nice [­NINI] command_line] command_line
●
nice [­n nice [­n NINI] command_line] command_line
– Runs command with specifiedRuns command with specified NINI valuevalue
– The default value is 10The default value is 10
UsingUsing renicerenice
●
renice <renice <New_NINew_NI> PID ...> PID ...
– Adjusts the NI value for a process by PIDAdjusts the NI value for a process by PID
– Regular users can only increase NI valueRegular users can only increase NI value
– Regular users can only adjust owning processesRegular users can only adjust owning processes
●
renice <renice <New_NINew_NI> ­u > ­u useruser
– Adjusts the NI value for all processes owned byAdjusts the NI value for all processes owned by
specified userspecified user
– Root onlyRoot only
Process SignalProcess Signal
●
Change the status of a running processChange the status of a running process
●
Common signals:Common signals:
No. Name Function
1 HUP reload configuration
2 INT interrupt a process
3 QUIT quit with some actions
9 KILL terminated immediately
15 TERM terminated normally
18 CONT continue a stopped process
19 STP stop a process
Ref. Pge. 94
UsingUsing killkill
●
kill [­sig] <%JID/PID> …kill [­sig] <%JID/PID> …
– Sends a signal to processes or jobsSends a signal to processes or jobs
– The default signal isThe default signal is TERMTERM
– Signal formats:Signal formats:
●
­­nn : the signal number: the signal number
●
­­namename : the signal name: the signal name
UsingUsing killallkillall
●
killall [­sig] cmd_name …killall [­sig] cmd_name …
– Sends a signal to processes by nameSends a signal to processes by name
– All processes by the command receive the signalAll processes by the command receive the signal
– Regular users can only send signals to owningRegular users can only send signals to owning
processesprocesses

More Related Content

PDF
Linux fundamental - Chap 01 io
PDF
Linux fundamental - Chap 11 boot
PDF
Linux fundamental - Chap 12 Hardware Management
PDF
Chap 17 advfs
PDF
Linux fundamental - Chap 09 pkg
PDF
Chap 19 web
PDF
Linux fundamental - Chap 10 fs
PDF
Linux fundamental - Chap 04 archive
Linux fundamental - Chap 01 io
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 12 Hardware Management
Chap 17 advfs
Linux fundamental - Chap 09 pkg
Chap 19 web
Linux fundamental - Chap 10 fs
Linux fundamental - Chap 04 archive

What's hot (20)

PDF
Importance of linux system fundamental in technical documentation reading
ODP
Linux kernel debugging(ODP format)
ODP
LSA2 - 02 Control Groups
ODP
LSA2 - 01 Virtualization with KVM
PPTX
First steps on CentOs7
ODP
SystemV vs systemd
PDF
Linux fundamental - Chap 15 Job Scheduling
PDF
Introduction of unit test on android kernel
PDF
Comparison of-foss-distributed-storage
PDF
Systemd cheatsheet
PDF
PHP at Density and Scale (Lone Star PHP 2014)
PPT
Kgdb kdb modesetting
PDF
Kernel Recipes 2015 - Porting Linux to a new processor architecture
PPTX
Linux Initialization Process (2)
PDF
Linux: LVM
PDF
Kernel Recipes 2015: Introduction to Kernel Power Management
PDF
Reconnaissance of Virtio: What’s new and how it’s all connected?
PDF
Haproxy - zastosowania
ODP
4. storage lvm
Importance of linux system fundamental in technical documentation reading
Linux kernel debugging(ODP format)
LSA2 - 02 Control Groups
LSA2 - 01 Virtualization with KVM
First steps on CentOs7
SystemV vs systemd
Linux fundamental - Chap 15 Job Scheduling
Introduction of unit test on android kernel
Comparison of-foss-distributed-storage
Systemd cheatsheet
PHP at Density and Scale (Lone Star PHP 2014)
Kgdb kdb modesetting
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Linux Initialization Process (2)
Linux: LVM
Kernel Recipes 2015: Introduction to Kernel Power Management
Reconnaissance of Virtio: What’s new and how it’s all connected?
Haproxy - zastosowania
4. storage lvm
Ad

Viewers also liked (10)

PDF
Windows7 Vs Linux
PDF
The linux command line for total beginners
PDF
Linux fundamental - Chap 06 regx
PDF
Linux fundamental - Chap 07 vi
PDF
Linux fundamental - Chap 03 file
PDF
Linux fundamental - Chap 13 account management
PDF
Linux fundamental - Chap 05 filter
PDF
Linux fundamental - Chap 02 perm
PDF
Making Linux do Hard Real-time
Windows7 Vs Linux
The linux command line for total beginners
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 07 vi
Linux fundamental - Chap 03 file
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 02 perm
Making Linux do Hard Real-time
Ad

Similar to Linux fundamental - Chap 08 proc (20)

PPT
3.5 create, monitor and kill processes v2
PDF
Trevor McDonald - Nagios XI Under The Hood
PPT
3.6 modify process execution priorities v2
PDF
Linux Internals - Part II
PPT
101 3.5 create, monitor and kill processes v2
PPT
101 3.6 modify process execution priorities v2
PDF
Tune System Performance - RHCSA (RH134).pdf
PDF
Pdf c1t tlawaxb
PDF
Process management
ODP
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
PDF
DockerCon EU '17 - Dockerizing Aurea
PPTX
operating system module 2 presentation notes
PDF
OSMC 2014: Naemon 1, 2, 3, N | Andreas Ericsson
PDF
Go replicator
PDF
Replication using PostgreSQL Replicator
PDF
Exploring Raspberry Pi
PDF
Creating a Mature Puppet System
PDF
Creating a mature puppet system
PDF
Control your service resources with systemd
PDF
Archivematica Technical Training Diagnostics Guide (September 2018)
3.5 create, monitor and kill processes v2
Trevor McDonald - Nagios XI Under The Hood
3.6 modify process execution priorities v2
Linux Internals - Part II
101 3.5 create, monitor and kill processes v2
101 3.6 modify process execution priorities v2
Tune System Performance - RHCSA (RH134).pdf
Pdf c1t tlawaxb
Process management
Nagios Conference 2014 - Eric Mislivec - Getting Started With Nagios Core
DockerCon EU '17 - Dockerizing Aurea
operating system module 2 presentation notes
OSMC 2014: Naemon 1, 2, 3, N | Andreas Ericsson
Go replicator
Replication using PostgreSQL Replicator
Exploring Raspberry Pi
Creating a Mature Puppet System
Creating a mature puppet system
Control your service resources with systemd
Archivematica Technical Training Diagnostics Guide (September 2018)

More from Kenny (netman) (14)

TXT
rpi_audio configuration steps
PDF
Rpi audio
PDF
Ha opensuse
PDF
Chap 18 net
PDF
About the Course
PDF
Linux fundamental - Chap 16 System Rescue
PDF
Linux fundamental - Chap 14 shell script
PDF
Linux fundamental - Chap 00 shell
PDF
Linux system security
PDF
Linux network monitoring hands-on pratice
PDF
Linux Network Monitoring
PDF
加密應用(GPG)
PDF
金鑰管理 (PKI)
PDF
Linux firewall
rpi_audio configuration steps
Rpi audio
Ha opensuse
Chap 18 net
About the Course
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 00 shell
Linux system security
Linux network monitoring hands-on pratice
Linux Network Monitoring
加密應用(GPG)
金鑰管理 (PKI)
Linux firewall

Recently uploaded (20)

PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
HVAC Specification 2024 according to central public works department
PDF
Climate and Adaptation MCQs class 7 from chatgpt
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PDF
International_Financial_Reporting_Standa.pdf
PPTX
Module on health assessment of CHN. pptx
PDF
Race Reva University – Shaping Future Leaders in Artificial Intelligence
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PPTX
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
PDF
My India Quiz Book_20210205121199924.pdf
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PPTX
Education and Perspectives of Education.pptx
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
B.Sc. DS Unit 2 Software Engineering.pptx
HVAC Specification 2024 according to central public works department
Climate and Adaptation MCQs class 7 from chatgpt
FORM 1 BIOLOGY MIND MAPS and their schemes
Environmental Education MCQ BD2EE - Share Source.pdf
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
International_Financial_Reporting_Standa.pdf
Module on health assessment of CHN. pptx
Race Reva University – Shaping Future Leaders in Artificial Intelligence
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
My India Quiz Book_20210205121199924.pdf
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Cambridge-Practice-Tests-for-IELTS-12.docx
Unit 4 Computer Architecture Multicore Processor.pptx
Education and Perspectives of Education.pptx
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf

Linux fundamental - Chap 08 proc

  • 1. Chapter 8Chapter 8 Process ManagementProcess Management Ref. Pge. 85
  • 2. What is a process?What is a process? ● A binary commandA binary command ● Loaded into memoryLoaded into memory ● Processed by CPUProcessed by CPU ● Release memory when quitRelease memory when quit ● Identified by PIDIdentified by PID
  • 3. Process TreeProcess Tree ● Every process is generated by parentEvery process is generated by parent processprocess ● Child process inherits environmentChild process inherits environment from it's parentfrom it's parent ● Child process returns a value to parentChild process returns a value to parent when exitwhen exit ● TheThe initinit is the root of process treeis the root of process tree
  • 4. Process EnvironmentProcess Environment ● PID/PPIDPID/PPID ● UID/GIDUID/GID ● Command NameCommand Name ● VariablesVariables ● ParametersParameters ● File DescriptorsFile Descriptors ● Data ...Data ...
  • 5. Process Management UtilitiesProcess Management Utilities ● pstreepstree – Shows the whole process treeShows the whole process tree – Common optionsCommon options ● ­p­p : with PID: with PID ● ­u­u : with user name: with user name
  • 6. Process Management UtilitiesProcess Management Utilities ● psps – Shows process informationShows process information – Common options (standard style)Common options (standard style) ● ­l­l : long format: long format ● ­e­e : every process: every process – Common options (BSD style)Common options (BSD style) ● aa : all process related to terminal: all process related to terminal ● uu : user format: user format ● xx : current user's process / all process with option: current user's process / all process with option aa ● ww : whole line information: whole line information Ref. Pge. 86
  • 7. Process Management UtilitiesProcess Management Utilities ● toptop – Sorts process in order (default by CPU usage)Sorts process in order (default by CPU usage) – Common options:Common options: ● ­d ­d nn : delay in: delay in nn seconds intervalseconds interval ● ­n ­n nn : refresh: refresh nn timestimes ● ­b­b : batch mode in pipe line: batch mode in pipe line Ref. Pge. 90
  • 8. Process UtilitiesProcess Utilities – Common internal commands ofCommon internal commands of toptop:: ● <space> <space>  : refresh screen: refresh screen ● h,?h,? : help: help ● ss : delay second: delay second ● rr : renice a process: renice a process ● kk : kill a process: kill a process ● F,OF,O : select sorting field: select sorting field ● ii : toggle idle processes: toggle idle processes ● qq : quit: quit
  • 9. Process Management UtilitiesProcess Management Utilities ● uptimeuptime – Displays system running informationDisplays system running information
  • 10. Job ControlJob Control ● Foreground JobForeground Job – Normal way to run a commandNormal way to run a command – The job occupies the terminal till finishThe job occupies the terminal till finish – Parent process stay in sleep statusParent process stay in sleep status – Can be stopped by pressingCan be stopped by pressing ctrl­zctrl­z ● Background JobBackground Job – Ending withEnding with && when running a commandwhen running a command – The shell prompt occurred for typing nextThe shell prompt occurred for typing next commandcommand – Parent process is still runningParent process is still running Ref. Pge. 92
  • 11. UsingUsing jobsjobs ● jobsjobs – Displays all background jobs in current shellDisplays all background jobs in current shell – Common options:Common options: ● ­l­l : display PID: display PID
  • 12. Job Control SwitchingJob Control Switching ● fgfg – Bring a background/stopped job to foregroundBring a background/stopped job to foreground ● ^z^z – Stop a foreground jobStop a foreground job ● bgbg – Put a stopped job to backgroundPut a stopped job to background
  • 14. Process PriorityProcess Priority ● Processes have different priorities toProcesses have different priorities to consume the CPU time slices in two ways:consume the CPU time slices in two ways: – PRI (priority)PRI (priority) ● Higher value has more CPU timeHigher value has more CPU time ● Dynamic adjusted by kernelDynamic adjusted by kernel – NI (nice)NI (nice) ● Higher value has less CPU timeHigher value has less CPU time ● Adjusted by user: -20~19Adjusted by user: -20~19 Ref. Pge. 93
  • 15. UsingUsing nicenice ● nice [­nice [­NINI] command_line] command_line ● nice [­n nice [­n NINI] command_line] command_line – Runs command with specifiedRuns command with specified NINI valuevalue – The default value is 10The default value is 10
  • 16. UsingUsing renicerenice ● renice <renice <New_NINew_NI> PID ...> PID ... – Adjusts the NI value for a process by PIDAdjusts the NI value for a process by PID – Regular users can only increase NI valueRegular users can only increase NI value – Regular users can only adjust owning processesRegular users can only adjust owning processes ● renice <renice <New_NINew_NI> ­u > ­u useruser – Adjusts the NI value for all processes owned byAdjusts the NI value for all processes owned by specified userspecified user – Root onlyRoot only
  • 17. Process SignalProcess Signal ● Change the status of a running processChange the status of a running process ● Common signals:Common signals: No. Name Function 1 HUP reload configuration 2 INT interrupt a process 3 QUIT quit with some actions 9 KILL terminated immediately 15 TERM terminated normally 18 CONT continue a stopped process 19 STP stop a process Ref. Pge. 94
  • 18. UsingUsing killkill ● kill [­sig] <%JID/PID> …kill [­sig] <%JID/PID> … – Sends a signal to processes or jobsSends a signal to processes or jobs – The default signal isThe default signal is TERMTERM – Signal formats:Signal formats: ● ­­nn : the signal number: the signal number ● ­­namename : the signal name: the signal name
  • 19. UsingUsing killallkillall ● killall [­sig] cmd_name …killall [­sig] cmd_name … – Sends a signal to processes by nameSends a signal to processes by name – All processes by the command receive the signalAll processes by the command receive the signal – Regular users can only send signals to owningRegular users can only send signals to owning processesprocesses