SlideShare a Scribd company logo
RedHat Enterprise Linux Essential
  Unit 10: Investigating and Managing
               Processes
Investigating and Managing Processes
Upon completion of this unit, you should be able to:

 Explain what a process is

 Describe how to manage processes

 Use job control tools
What is a Process?

 A process is a set of instructions loaded into memory

   Numeric Process ID (PID) used for identification

   UID, GID and SELinux context determines filesystem access

     • Normally inherited from the executing user
Listing Processes

 View Process information with ps
    Shows processes from the current terminal by default

    a includes processes on all terminals

    x includes processes not attached to terminals

    u prints process owner information

    f prints process parentage

    o PROPERTY,... prints custom information:
       • pid, comm, %cpu, %mem, state, tty, euser, ruser

    Process states – running, sleeping, uninterruptable sleep, zombie.
Finding Processes


 Most flexible: ps options | other commands
      ps axo comm,tty | grep ttyS0

      ps -ef

 By predefined patterns: pgrep

               $ pgrep -U root

               $ pgrep -G student

●    By exact program name: pidof

               $ pidof bash
Example with cpu




ps –Ao pcpu,pid,user,args | sort –k 1 –r |head -10
Signals

 Most fundamental inter-process communication
    Sent directly to processes, no user-interface required

    Programs associate actions with each signal

    Signals are specified by name or number when sent:
       • Signal 15, TERM (default) - Terminate cleanly   (stopping)

       • Signal 9, KILL - Terminate immediately          (kill)

       • Signal 1, HUP - Re-read configuration files     (reload)

       • Kill –l         list info for singal

       • man 7 signal shows complete list
Sending Signals to Processes

 By PID: kill [signal] pid ...

 By Name: killall [signal] comm ...

 By pattern: pkill [-signal] pattern
Scheduling Priority

 Scheduling priority determines access to the CPU

 Priority is affected by a process‘ nice value

 Values range from -20 to 19 but default to 0
    Lower nice value means higher CPU priority

 Viewed with ps -Ao comm,nice
      ex: firefox &

      ps –Ao comm,nice |grep firefox
Altering Scheduling Priority

 Nice values may be altered...
    When starting a process:

       $ nice -n 5 command

    After starting:

       $ renice 5 PID

       renice 5 –p PID

 Only root may decrease nice values
Interactive Process Management Tools

 CLI: top

 GUI: gnome-system-monitor

 Capabilities
    Display real-time process information

    Allow sorting, killing and re-nicing
Job Control
 Run a process in the background

    Append an ampersand to the command line: firefox &

 Temporarily halt a running program
    Use Ctrl-z or send signal 17 (STOP)

 Manage background or suspended jobs
    List job numbers and names: jobs

    Resume in the background: bg [%jobnum]

    Resume in the foreground: fg [%jobnum]

    Send a signal: kill [-SIGNAL] [%jobnum]
Scheduling a Process To Execute Later

 One-time jobs use at, recurring jobs use crontab


    Create         at time               crontab -e
    List           at -l                 crontab -l
    Details        at -c jobnum          N/A
    Remove         at -d jobnum          crontab -r
    Edit           N/A                   crontab -e



 Non-redirected output is mailed to the user

 root              can modify jobs for other users
Using at
 Setting an at job: at [options] time
    Options:
     -b                run command only when the system load is low
     -d job#           delete an at job from queue
     -f filename       read job from a specified file
     -l                list jobs for that user (all jobs for root)
     -m                mail user quen job completes
     -q queuename      send the jobs to a queue (a to z and A to Z)
    Time formats:
      now, 17:00, +3 hours, +2 minutes, +2 days, +3 months, 19:15 3.12.10,
     midnight, 4PM, 16:00 +3 days, mon, tomorrow …
 Show the at jobs queue of user: atq or at –l
 Deletes at jobs from the jobs queue: atrm job# [job#] …
Examples with at
 Create an simple at job to run in 5 minutes later
   $ at now+5 minutes
   echo “I am running in an at job” > /tmp/test_cron
   [Ctrl-D]
 Create an at job which read commands from a file and run at
  midnight
   $ at –f /tmp/myjob.sh midnight
 Using echo to run multiple commands with at
  $ echo „cd /tmp; ls –a > /tmp/test_cron ‟ | at now+2 minutes
 Listing all at jobs
  $ at –l
  $ atq
crontab commands

 Create/edit a user crontab: crontab –e

 Create a user crontab by reading from file:
  crontab –e filename

 Display user‟s crontab file: crontab –l

 Delete user‟s crontab file: crontab –r

 Edit a user‟s crontab file (for root only):
  crontab –e –u username
Crontab File Format

 Entry consists of five space-delimited fields followed by a
  command line

  01 * * * * root        cd /tmp && ls -laht
    One entry per line, no limit to line length

 Fields are minute, hour, day of month, month, and day of week

 Comment lines begin with #

 See man 5 crontab for details
Examples of user crontabs
 Run a command every hour from 8:00 to 18:00 everyday
  0    8-18     *        *         *       <command>
 Run a command every 4 hours on the half hour (i.e 6:30, 10:30, 14:30, 16:30)
  everyday
  30 6-16/4 *            *         *       <command>
 Run a command every day, Monday to Friday at 01:00, and doesn‟t report to
  syslog
  -0 1          *        *         1-5     <command>
 Run the command every Monday and Tuesday at 12:00, 12:10, 12:20, 12:30
  0,10,20,30    12       *         *       1,2     <command>
 Run a command every 10 minutes
  */10 *        *        *         *       <command>
    echo “00 21 * * 7 root rm -f /tmp/*.log” >> /etc/crontab
    crontab -e
       00 8-17 * * 1-5 du -sh $HOME >> /tmp/diskreport
Grouping Commands


 Two ways to group commands:
   Compound: date; who | wc -l
     • Commands run back-to-back

   Subshell: (date; who | wc -l) >> /tmp/trace
     • All output is sent to a single STDOUT and STDERR
Exit Status

 Processes report success or failure with an exit status
    0 for success, 1-255 for failure

    $? stores the exit status of the most recent command
    exit [num] terminates and sets status to num

 Example:

       $ ping -c1 -W1 localhost999 &> /dev/null

       $ echo $?

       2
Conditional Execution Operators

 Commands can be run conditionally based on exit status
    && represents conditional AND THEN

    || represents conditional OR ELSE

 Examples:
      $ grep -q no_such_user /etc/passwd || echo 'No such user'

      No such user

      $ ping localhost &> /dev/null 

      >   && echo “localhost is up"      

      >   || echo ‘localhost is unreachable’
      localhost is up
The test Command

 Evaluates boolean statements for use in conditional execution
    Returns 0 for true

    Returns 1 for false

 Examples in long form:
       test "$A" = "$B" && echo "string" || echo "not equal"

       $ test "$A" -eq "$B" && echo "Integers are equal“

 Examples in shorthand notation:
       $ [ "$A" = "$B" ] && echo "Strings are equal"

       $ [ "$A" -eq "$B" ] && echo "Integers are equal"
File Tests

 File tests:
    -f tests to see if a file exists and is a regular file

    -d tests to see if a file exists and is a directory

    -x tests to see if a file exists and is executable

 [ -f ~/lib/functions ] && source ~/lib/functions
File Tests (cont’)

Options   Mean
-d file   True if the file is a directory.
-e file   True if the file exists.
-f file   True if the file exists and is a regular file.
-h file   True if the file is a symbolic link.
-L file   True if the file is a symbolic link.
-r file   True if the file exists and is readable by you.
-s file   True if the file exists and is not empty.
-w file   True if the file exists and is writable by you.
-x file   True if the file exists and is executable by you.
-O file   True if the file is effectively owned by you.
-G file   True if the file is effectively owned by your group.
Scripting: if Statements
 Execute instructions based on the exit status of a command
if ping -c1 -w2 station1 &> /dev/null; then

     echo 'Station1 is UP'

elif grep "station1" ~/maintenance.txt &> /dev/null; then

     echo 'Station1 is undergoing maintenance'

else

     echo 'Station1 is unexpectedly DOWN!'

     exit 1

fi
Unit 10 investigating and managing

More Related Content

What's hot

Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
Mohammad Rafiee
 
Distributed Operating Systems
Distributed Operating SystemsDistributed Operating Systems
Distributed Operating Systems
Ummiya Mohammedi
 
Linux file system
Linux file systemLinux file system
Linux file system
Md. Tanvir Hossain
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronization
Shakshi Ranawat
 
Cs8493 unit 5
Cs8493 unit 5Cs8493 unit 5
Cs8493 unit 5
Kathirvel Ayyaswamy
 
Linux operating system ppt
Linux operating system pptLinux operating system ppt
Linux operating system ppt
Achyut Sinha
 
Operating system 25 classical problems of synchronization
Operating system 25 classical problems of synchronizationOperating system 25 classical problems of synchronization
Operating system 25 classical problems of synchronization
Vaibhav Khanna
 
The linux file system structure
The linux file system structureThe linux file system structure
The linux file system structure
Teja Bheemanapally
 
OS UNIT – 2 - Process Management
OS UNIT – 2 - Process ManagementOS UNIT – 2 - Process Management
OS UNIT – 2 - Process Management
Gyanmanjari Institute Of Technology
 
Distributed Operating System
Distributed Operating SystemDistributed Operating System
Distributed Operating System
SanthiNivas
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
VIKAS TIWARI
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
Nikhil Jain
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
KunalKewat1
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
Dhaval Sakhiya
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and output
Sanidhya Chugh
 
Operating system lecture1
Operating system lecture1Operating system lecture1
Operating system lecture1
AhalyaSri
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
Kevin OBrien
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
Piyush Rochwani
 
Introduction to Operating System
Introduction to Operating SystemIntroduction to Operating System
Introduction to Operating System
priya_sinha02
 

What's hot (20)

Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
 
Distributed Operating Systems
Distributed Operating SystemsDistributed Operating Systems
Distributed Operating Systems
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronization
 
Cs8493 unit 5
Cs8493 unit 5Cs8493 unit 5
Cs8493 unit 5
 
Linux operating system ppt
Linux operating system pptLinux operating system ppt
Linux operating system ppt
 
Operating system 25 classical problems of synchronization
Operating system 25 classical problems of synchronizationOperating system 25 classical problems of synchronization
Operating system 25 classical problems of synchronization
 
The linux file system structure
The linux file system structureThe linux file system structure
The linux file system structure
 
OS UNIT – 2 - Process Management
OS UNIT – 2 - Process ManagementOS UNIT – 2 - Process Management
OS UNIT – 2 - Process Management
 
Distributed Operating System
Distributed Operating SystemDistributed Operating System
Distributed Operating System
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File SystemLesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Linux Operating System
Linux Operating SystemLinux Operating System
Linux Operating System
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Linux scheduling and input and output
Linux scheduling and input and outputLinux scheduling and input and output
Linux scheduling and input and output
 
Operating system lecture1
Operating system lecture1Operating system lecture1
Operating system lecture1
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Introduction to Operating System
Introduction to Operating SystemIntroduction to Operating System
Introduction to Operating System
 

Similar to Unit 10 investigating and managing

lec4.docx
lec4.docxlec4.docx
lec4.docx
ismailaboshatra
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
Teja Bheemanapally
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
Teja Bheemanapally
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
Sagar Kumar
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talk
Prince Raj
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
Deepak Singhal
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
Kedar Bhandari
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
hazhamina
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
Pinaki Mahata Mukherjee
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
tastedone
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Sudharsan S
 
Group13
Group13Group13
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
Acácio Oliveira
 
Linux
LinuxLinux
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
Acácio Oliveira
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
Utkarsh Sengar
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
Navin Thapa
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
Isham Rashik
 

Similar to Unit 10 investigating and managing (20)

lec4.docx
lec4.docxlec4.docx
lec4.docx
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux tech talk
Linux tech talkLinux tech talk
Linux tech talk
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Group13
Group13Group13
Group13
 
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
 
Linux
LinuxLinux
Linux
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
 
Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet Linux Commands - Cheat Sheet
Linux Commands - Cheat Sheet
 

More from root_fibo

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network client
root_fibo
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing files
root_fibo
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
root_fibo
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystem
root_fibo
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration tools
root_fibo
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
root_fibo
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i o
root_fibo
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
root_fibo
 
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editorUnit 5 vim an advanced text editor
Unit 5 vim an advanced text editor
root_fibo
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
root_fibo
 
Unit2 help
Unit2 helpUnit2 help
Unit2 help
root_fibo
 

More from root_fibo (11)

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network client
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing files
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystem
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration tools
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i o
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editorUnit 5 vim an advanced text editor
Unit 5 vim an advanced text editor
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
 
Unit2 help
Unit2 helpUnit2 help
Unit2 help
 

Recently uploaded

GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 

Recently uploaded (20)

GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 

Unit 10 investigating and managing

  • 1. RedHat Enterprise Linux Essential Unit 10: Investigating and Managing Processes
  • 2. Investigating and Managing Processes Upon completion of this unit, you should be able to:  Explain what a process is  Describe how to manage processes  Use job control tools
  • 3. What is a Process?  A process is a set of instructions loaded into memory  Numeric Process ID (PID) used for identification  UID, GID and SELinux context determines filesystem access • Normally inherited from the executing user
  • 4. Listing Processes  View Process information with ps  Shows processes from the current terminal by default  a includes processes on all terminals  x includes processes not attached to terminals  u prints process owner information  f prints process parentage  o PROPERTY,... prints custom information: • pid, comm, %cpu, %mem, state, tty, euser, ruser  Process states – running, sleeping, uninterruptable sleep, zombie.
  • 5. Finding Processes  Most flexible: ps options | other commands ps axo comm,tty | grep ttyS0 ps -ef  By predefined patterns: pgrep $ pgrep -U root $ pgrep -G student ● By exact program name: pidof $ pidof bash
  • 6. Example with cpu ps –Ao pcpu,pid,user,args | sort –k 1 –r |head -10
  • 7. Signals  Most fundamental inter-process communication  Sent directly to processes, no user-interface required  Programs associate actions with each signal  Signals are specified by name or number when sent: • Signal 15, TERM (default) - Terminate cleanly (stopping) • Signal 9, KILL - Terminate immediately (kill) • Signal 1, HUP - Re-read configuration files (reload) • Kill –l list info for singal • man 7 signal shows complete list
  • 8. Sending Signals to Processes  By PID: kill [signal] pid ...  By Name: killall [signal] comm ...  By pattern: pkill [-signal] pattern
  • 9. Scheduling Priority  Scheduling priority determines access to the CPU  Priority is affected by a process‘ nice value  Values range from -20 to 19 but default to 0  Lower nice value means higher CPU priority  Viewed with ps -Ao comm,nice ex: firefox & ps –Ao comm,nice |grep firefox
  • 10. Altering Scheduling Priority  Nice values may be altered...  When starting a process: $ nice -n 5 command  After starting: $ renice 5 PID renice 5 –p PID  Only root may decrease nice values
  • 11. Interactive Process Management Tools  CLI: top  GUI: gnome-system-monitor  Capabilities  Display real-time process information  Allow sorting, killing and re-nicing
  • 12. Job Control  Run a process in the background  Append an ampersand to the command line: firefox &  Temporarily halt a running program  Use Ctrl-z or send signal 17 (STOP)  Manage background or suspended jobs  List job numbers and names: jobs  Resume in the background: bg [%jobnum]  Resume in the foreground: fg [%jobnum]  Send a signal: kill [-SIGNAL] [%jobnum]
  • 13. Scheduling a Process To Execute Later  One-time jobs use at, recurring jobs use crontab Create at time crontab -e List at -l crontab -l Details at -c jobnum N/A Remove at -d jobnum crontab -r Edit N/A crontab -e  Non-redirected output is mailed to the user  root can modify jobs for other users
  • 14. Using at  Setting an at job: at [options] time  Options: -b run command only when the system load is low -d job# delete an at job from queue -f filename read job from a specified file -l list jobs for that user (all jobs for root) -m mail user quen job completes -q queuename send the jobs to a queue (a to z and A to Z)  Time formats: now, 17:00, +3 hours, +2 minutes, +2 days, +3 months, 19:15 3.12.10, midnight, 4PM, 16:00 +3 days, mon, tomorrow …  Show the at jobs queue of user: atq or at –l  Deletes at jobs from the jobs queue: atrm job# [job#] …
  • 15. Examples with at  Create an simple at job to run in 5 minutes later $ at now+5 minutes echo “I am running in an at job” > /tmp/test_cron [Ctrl-D]  Create an at job which read commands from a file and run at midnight $ at –f /tmp/myjob.sh midnight  Using echo to run multiple commands with at $ echo „cd /tmp; ls –a > /tmp/test_cron ‟ | at now+2 minutes  Listing all at jobs $ at –l $ atq
  • 16. crontab commands  Create/edit a user crontab: crontab –e  Create a user crontab by reading from file: crontab –e filename  Display user‟s crontab file: crontab –l  Delete user‟s crontab file: crontab –r  Edit a user‟s crontab file (for root only): crontab –e –u username
  • 17. Crontab File Format  Entry consists of five space-delimited fields followed by a command line 01 * * * * root cd /tmp && ls -laht  One entry per line, no limit to line length  Fields are minute, hour, day of month, month, and day of week  Comment lines begin with #  See man 5 crontab for details
  • 18. Examples of user crontabs  Run a command every hour from 8:00 to 18:00 everyday 0 8-18 * * * <command>  Run a command every 4 hours on the half hour (i.e 6:30, 10:30, 14:30, 16:30) everyday 30 6-16/4 * * * <command>  Run a command every day, Monday to Friday at 01:00, and doesn‟t report to syslog -0 1 * * 1-5 <command>  Run the command every Monday and Tuesday at 12:00, 12:10, 12:20, 12:30 0,10,20,30 12 * * 1,2 <command>  Run a command every 10 minutes */10 * * * * <command> echo “00 21 * * 7 root rm -f /tmp/*.log” >> /etc/crontab crontab -e 00 8-17 * * 1-5 du -sh $HOME >> /tmp/diskreport
  • 19. Grouping Commands  Two ways to group commands:  Compound: date; who | wc -l • Commands run back-to-back  Subshell: (date; who | wc -l) >> /tmp/trace • All output is sent to a single STDOUT and STDERR
  • 20. Exit Status  Processes report success or failure with an exit status  0 for success, 1-255 for failure  $? stores the exit status of the most recent command  exit [num] terminates and sets status to num  Example: $ ping -c1 -W1 localhost999 &> /dev/null $ echo $? 2
  • 21. Conditional Execution Operators  Commands can be run conditionally based on exit status  && represents conditional AND THEN  || represents conditional OR ELSE  Examples: $ grep -q no_such_user /etc/passwd || echo 'No such user' No such user $ ping localhost &> /dev/null > && echo “localhost is up" > || echo ‘localhost is unreachable’ localhost is up
  • 22. The test Command  Evaluates boolean statements for use in conditional execution  Returns 0 for true  Returns 1 for false  Examples in long form: test "$A" = "$B" && echo "string" || echo "not equal" $ test "$A" -eq "$B" && echo "Integers are equal“  Examples in shorthand notation: $ [ "$A" = "$B" ] && echo "Strings are equal" $ [ "$A" -eq "$B" ] && echo "Integers are equal"
  • 23. File Tests  File tests:  -f tests to see if a file exists and is a regular file  -d tests to see if a file exists and is a directory  -x tests to see if a file exists and is executable  [ -f ~/lib/functions ] && source ~/lib/functions
  • 24. File Tests (cont’) Options Mean -d file True if the file is a directory. -e file True if the file exists. -f file True if the file exists and is a regular file. -h file True if the file is a symbolic link. -L file True if the file is a symbolic link. -r file True if the file exists and is readable by you. -s file True if the file exists and is not empty. -w file True if the file exists and is writable by you. -x file True if the file exists and is executable by you. -O file True if the file is effectively owned by you. -G file True if the file is effectively owned by your group.
  • 25. Scripting: if Statements  Execute instructions based on the exit status of a command if ping -c1 -w2 station1 &> /dev/null; then echo 'Station1 is UP' elif grep "station1" ~/maintenance.txt &> /dev/null; then echo 'Station1 is undergoing maintenance' else echo 'Station1 is unexpectedly DOWN!' exit 1 fi