SlideShare una empresa de Scribd logo
1 de 12
Junior Level Linux Certification
Exam Objectives
Key Knowledge Areas
Run jobs in the foreground and background.
Signal a program to continue running after logout.
Monitor active processes.
Select and sort processes for display.
Send signals to processes.
Objective 3: GNU and Unix Commands
Create, monitor and kill processes Weight: 4
Terms and Utilities
& bg
fg jobs
kill nohup
ps top
free uptime
killall
2
Create, monitor and kill processes
Job control - Ability to selectively suspend execution of processes and continue their execution later.
A job is a process or a pipeline of processes that were started by the shell.
Job control
3
job which receives keyboard input is called the foreground job.
•When a foreground process is running, it receives keyboard input and signals.
•Processes started are run in foreground by default and continue until they exit.
To run a process in background – input command followed by special character &
•Processes running in the background may still send output to the terminal.
•They do not receive keyboard input unless they are brought to the foreground.
When bash starts a background job, it prints a line with:
- job number and - process ID of last process in pipeline
Create, monitor and kill processes
Job control - Ability to selectively suspend execution of processes and continue their execution later.
A job is a process or a pipeline of processes that were started by the shell.
Job control
4
job which receives keyboard input is called the foreground job.
•When a foreground process is running, it receives keyboard input and signals.
•Processes started are run in foreground by default and continue until they exit.
To run a process in background – input command followed by special character &
•Processes running in the background may still send output to the terminal.
•They do not receive keyboard input unless they are brought to the foreground.
When bash starts a background job, it prints a line with:
- job number and - process ID of last process in pipeline
Create, monitor and kill processes
command jobs displays current list of jobs either running or stopped.
jobs
5
foo:~ $ dd if=/dev/zero of=/dev/null bs=1 &
[1] 1181
foo:~ $ cat /dev/urandom | grep hello &
[2] 1183
foo:~ $ jobs
[1]- Running dd if=/dev/zero of=/dev/null bs=1 &
[2]+ Running cat /dev/urandom | grep hello &
Ex:
Create, monitor and kill processes
Control jobs
6
key sequences entered to foreground processes:
Key Signal Meaning Usage
Ctrl+C SIGINT Interrupt Interrupt the program running in the foreground
Ctrl+Z SIGSTOP Suspend Suspend the program running in the foreground
cmds entered to control background processes.
Command Meaning Usage
fg foreground Run the background job in the foreground. If it has suspended, restart it.
bg background Restart a suspended job.
fg makes most recently executed job a foreground job.
You can specify a specific job number. (Ex. fg 2 will make job 2 run in the foreground)
bg makes most recently executed job continue to run in background.
You can make a specific job run in the background by specifying a job number (Ex. bg 2)
Create, monitor and kill processes
Control jobs
7
kill command
kill job based on job number (instead of PID) using percentage sign to specify the job number
foo:~ $ jobs
[1]- Running dd if=/dev/zero of=/dev/null bs=1 &
[2]+ Running cat /dev/urandom | grep hello &
foo:~ $ kill %1
foo:~ $
[1]- Terminated dd if=/dev/zero of=/dev/null bs=1
foo:~ $ jobs
[2]+ Running cat /dev/urandom | grep hello &
foo:~ $ kill %2
foo:~ $
[2]+ Terminated cat /dev/urandom | grep hello
Ex:
Create, monitor and kill processes
Disconnected processes
8
commands nohup and setsid
- used to run processes disconnected from terminal that started them.
nohup sets the signal mask for the process it starts to ignore the SIGHUP signal.
SIGHUP signal is sent to each process when the shell exits. - happens when you exit a session on console, or via network connection.
•nohup writes the output to a file - nohup.out
•nohup is generally used - When you know that the process you are going to run should continue to
run after your session ends.
Create, monitor and kill processes
Monitoring processes
9
ps – process status
options supported by ps are somewhat complex.
GNU version supports: Unix98 options (letters); BSD options (dash); GNU options (two dashes).
To ... Unix98 BSD
- Show all processes ps -ax ps -A ps -e
- Show full info ps -u (user format) ps -f (full listing)
- Show full info for all processes ps -uax ps -ef ps -Af
foo:~ $ ps -f
UID PID PPID C STIME TTY TIME CMD
georgem 987 612 0 20:32 pts/2 00:00:00 /bin/bash
georgem 3398 987 0 21:11 pts/2 00:00:00 ps -f
foo:~ $ ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
georgem 987 0.0 1.7 4676 2040 pts/2 S 20:32 0:00 /bin/bash
georgem 3399 0.0 0.5 2524 696 pts/2 R 21:11 0:00 ps u
Ex:
ps -w – display in wide format
ps -f – display in forest of processes, similar to output of pstree.
Create, monitor and kill processes
Monitoring processes
10
top – displays processes that use up the most CPU or memory.
Ex:
Create, monitor and kill processes
Signals
11
Processes in Linux do not communicate with each other directly, but send each other signals
via kernel.
most common signal sent is SIGTERM,
means Terminate, unless you know what to do
signal(7) man page.
Ex:
http://linux.about.com/od/commands/l/blcmdl7_signal.htm
Fim de sessão
12

Más contenido relacionado

La actualidad más candente

101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
Acácio Oliveira
 
Perf stat windows
Perf stat windowsPerf stat windows
Perf stat windows
Accenture
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
meashi
 
Slide lpi mudancas lpic1
Slide lpi mudancas lpic1Slide lpi mudancas lpic1
Slide lpi mudancas lpic1
Roberto Castro
 

La actualidad más candente (20)

101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
Unix system calls
Unix system callsUnix system calls
Unix system calls
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commands
 
Perf stat windows
Perf stat windowsPerf stat windows
Perf stat windows
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
 
Linux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA'sLinux monitoring and Troubleshooting for DBA's
Linux monitoring and Troubleshooting for DBA's
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring Course 102: Lecture 17: Process Monitoring
Course 102: Lecture 17: Process Monitoring
 
Linux final exam
Linux final examLinux final exam
Linux final exam
 
Slide lpi mudancas lpic1
Slide lpi mudancas lpic1Slide lpi mudancas lpic1
Slide lpi mudancas lpic1
 
Piping into-php
Piping into-phpPiping into-php
Piping into-php
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 

Similar a 101 3.5 create, monitor and kill processes

InstructionsInstructions for numberguessernumberGuesser.html.docx
InstructionsInstructions for numberguessernumberGuesser.html.docxInstructionsInstructions for numberguessernumberGuesser.html.docx
InstructionsInstructions for numberguessernumberGuesser.html.docx
dirkrplav
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ewout2
 
Basic command for linux
Basic command for linuxBasic command for linux
Basic command for linux
gt0ne
 

Similar a 101 3.5 create, monitor and kill processes (20)

InstructionsInstructions for numberguessernumberGuesser.html.docx
InstructionsInstructions for numberguessernumberGuesser.html.docxInstructionsInstructions for numberguessernumberGuesser.html.docx
InstructionsInstructions for numberguessernumberGuesser.html.docx
 
3.5 create, monitor and kill processes v2
3.5 create, monitor and kill processes v23.5 create, monitor and kill processes v2
3.5 create, monitor and kill processes v2
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
LP-Unit3.docx
LP-Unit3.docxLP-Unit3.docx
LP-Unit3.docx
 
Process managment
Process  managmentProcess  managment
Process managment
 
101 3.5 create, monitor and kill processes v2
101 3.5 create, monitor and kill processes v2101 3.5 create, monitor and kill processes v2
101 3.5 create, monitor and kill processes v2
 
System Administration: Linux Process
System Administration: Linux ProcessSystem Administration: Linux Process
System Administration: Linux Process
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in background
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Control
 
operating system (process)
operating system (process)operating system (process)
operating system (process)
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
 
Linux commands part3
Linux commands part3Linux commands part3
Linux commands part3
 
Operating System Practice : Meeting 6- process and manajemen proces-b-slide
Operating System Practice : Meeting 6- process and manajemen proces-b-slideOperating System Practice : Meeting 6- process and manajemen proces-b-slide
Operating System Practice : Meeting 6- process and manajemen proces-b-slide
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Basic command for linux
Basic command for linuxBasic command for linux
Basic command for linux
 
BPF Tools 2017
BPF Tools 2017BPF Tools 2017
BPF Tools 2017
 
bcc/BPF tools - Strategy, current tools, future challenges
bcc/BPF tools - Strategy, current tools, future challengesbcc/BPF tools - Strategy, current tools, future challenges
bcc/BPF tools - Strategy, current tools, future challenges
 

Más de Acácio Oliveira

Más de Acácio Oliveira (20)

Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptxSecurity+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
Security+ Lesson 01 Topic 24 - Vulnerability Scanning vs Pen Testing.pptx
 
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptxSecurity+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
Security+ Lesson 01 Topic 25 - Application Security Controls and Techniques.pptx
 
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptxSecurity+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
Security+ Lesson 01 Topic 21 - Types of Application Attacks.pptx
 
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptxSecurity+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
Security+ Lesson 01 Topic 19 - Summary of Social Engineering Attacks.pptx
 
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptxSecurity+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
Security+ Lesson 01 Topic 23 - Overview of Security Assessment Tools.pptx
 
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptxSecurity+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
Security+ Lesson 01 Topic 20 - Summary of Wireless Attacks.pptx
 
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptxSecurity+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
Security+ Lesson 01 Topic 22 - Security Enhancement Techniques.pptx
 
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptxSecurity+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
Security+ Lesson 01 Topic 15 - Risk Management Best Practices.pptx
 
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptxSecurity+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
Security+ Lesson 01 Topic 13 - Physical Security and Environmental Controls.pptx
 
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptxSecurity+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
Security+ Lesson 01 Topic 14 - Disaster Recovery Concepts.pptx
 
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptxSecurity+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
Security+ Lesson 01 Topic 06 - Wireless Security Considerations.pptx
 
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
Security+ Lesson 01 Topic 04 - Secure Network Design Elements and Components....
 
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptxSecurity+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
Security+ Lesson 01 Topic 02 - Secure Network Administration Concepts.pptx
 
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptxSecurity+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
Security+ Lesson 01 Topic 01 - Intro to Network Devices.pptx
 
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
Security+ Lesson 01 Topic 08 - Integrating Data and Systems with Third Partie...
 
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptxSecurity+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
Security+ Lesson 01 Topic 07 - Risk Related Concepts.pptx
 
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptxSecurity+ Lesson 01 Topic 05 - Common Network Protocols.pptx
Security+ Lesson 01 Topic 05 - Common Network Protocols.pptx
 
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptxSecurity+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
Security+ Lesson 01 Topic 11 - Incident Response Concepts.pptx
 
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptxSecurity+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
Security+ Lesson 01 Topic 12 - Security Related Awareness and Training.pptx
 
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptxSecurity+ Lesson 01 Topic 17 - Types of Malware.pptx
Security+ Lesson 01 Topic 17 - Types of Malware.pptx
 

Último

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
 

Último (20)

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...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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...
 
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
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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
 

101 3.5 create, monitor and kill processes

  • 1. Junior Level Linux Certification
  • 2. Exam Objectives Key Knowledge Areas Run jobs in the foreground and background. Signal a program to continue running after logout. Monitor active processes. Select and sort processes for display. Send signals to processes. Objective 3: GNU and Unix Commands Create, monitor and kill processes Weight: 4 Terms and Utilities & bg fg jobs kill nohup ps top free uptime killall 2
  • 3. Create, monitor and kill processes Job control - Ability to selectively suspend execution of processes and continue their execution later. A job is a process or a pipeline of processes that were started by the shell. Job control 3 job which receives keyboard input is called the foreground job. •When a foreground process is running, it receives keyboard input and signals. •Processes started are run in foreground by default and continue until they exit. To run a process in background – input command followed by special character & •Processes running in the background may still send output to the terminal. •They do not receive keyboard input unless they are brought to the foreground. When bash starts a background job, it prints a line with: - job number and - process ID of last process in pipeline
  • 4. Create, monitor and kill processes Job control - Ability to selectively suspend execution of processes and continue their execution later. A job is a process or a pipeline of processes that were started by the shell. Job control 4 job which receives keyboard input is called the foreground job. •When a foreground process is running, it receives keyboard input and signals. •Processes started are run in foreground by default and continue until they exit. To run a process in background – input command followed by special character & •Processes running in the background may still send output to the terminal. •They do not receive keyboard input unless they are brought to the foreground. When bash starts a background job, it prints a line with: - job number and - process ID of last process in pipeline
  • 5. Create, monitor and kill processes command jobs displays current list of jobs either running or stopped. jobs 5 foo:~ $ dd if=/dev/zero of=/dev/null bs=1 & [1] 1181 foo:~ $ cat /dev/urandom | grep hello & [2] 1183 foo:~ $ jobs [1]- Running dd if=/dev/zero of=/dev/null bs=1 & [2]+ Running cat /dev/urandom | grep hello & Ex:
  • 6. Create, monitor and kill processes Control jobs 6 key sequences entered to foreground processes: Key Signal Meaning Usage Ctrl+C SIGINT Interrupt Interrupt the program running in the foreground Ctrl+Z SIGSTOP Suspend Suspend the program running in the foreground cmds entered to control background processes. Command Meaning Usage fg foreground Run the background job in the foreground. If it has suspended, restart it. bg background Restart a suspended job. fg makes most recently executed job a foreground job. You can specify a specific job number. (Ex. fg 2 will make job 2 run in the foreground) bg makes most recently executed job continue to run in background. You can make a specific job run in the background by specifying a job number (Ex. bg 2)
  • 7. Create, monitor and kill processes Control jobs 7 kill command kill job based on job number (instead of PID) using percentage sign to specify the job number foo:~ $ jobs [1]- Running dd if=/dev/zero of=/dev/null bs=1 & [2]+ Running cat /dev/urandom | grep hello & foo:~ $ kill %1 foo:~ $ [1]- Terminated dd if=/dev/zero of=/dev/null bs=1 foo:~ $ jobs [2]+ Running cat /dev/urandom | grep hello & foo:~ $ kill %2 foo:~ $ [2]+ Terminated cat /dev/urandom | grep hello Ex:
  • 8. Create, monitor and kill processes Disconnected processes 8 commands nohup and setsid - used to run processes disconnected from terminal that started them. nohup sets the signal mask for the process it starts to ignore the SIGHUP signal. SIGHUP signal is sent to each process when the shell exits. - happens when you exit a session on console, or via network connection. •nohup writes the output to a file - nohup.out •nohup is generally used - When you know that the process you are going to run should continue to run after your session ends.
  • 9. Create, monitor and kill processes Monitoring processes 9 ps – process status options supported by ps are somewhat complex. GNU version supports: Unix98 options (letters); BSD options (dash); GNU options (two dashes). To ... Unix98 BSD - Show all processes ps -ax ps -A ps -e - Show full info ps -u (user format) ps -f (full listing) - Show full info for all processes ps -uax ps -ef ps -Af foo:~ $ ps -f UID PID PPID C STIME TTY TIME CMD georgem 987 612 0 20:32 pts/2 00:00:00 /bin/bash georgem 3398 987 0 21:11 pts/2 00:00:00 ps -f foo:~ $ ps u USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND georgem 987 0.0 1.7 4676 2040 pts/2 S 20:32 0:00 /bin/bash georgem 3399 0.0 0.5 2524 696 pts/2 R 21:11 0:00 ps u Ex: ps -w – display in wide format ps -f – display in forest of processes, similar to output of pstree.
  • 10. Create, monitor and kill processes Monitoring processes 10 top – displays processes that use up the most CPU or memory. Ex:
  • 11. Create, monitor and kill processes Signals 11 Processes in Linux do not communicate with each other directly, but send each other signals via kernel. most common signal sent is SIGTERM, means Terminate, unless you know what to do signal(7) man page. Ex: http://linux.about.com/od/commands/l/blcmdl7_signal.htm