SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsDivye Kapoor
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linuxVarnnit Jain
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic CommandsHanan Nmr
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linuxshravan saini
 
Chapter01 Introduction To Windows Server 2003
Chapter01     Introduction To  Windows  Server 2003Chapter01     Introduction To  Windows  Server 2003
Chapter01 Introduction To Windows Server 2003Raja Waseem Akhtar
 
NFS(Network File System)
NFS(Network File System)NFS(Network File System)
NFS(Network File System)udamale
 
Linux history & features
Linux history & featuresLinux history & features
Linux history & featuresRohit Kumar
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linuxanandvaidya
 
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxXPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxThe Linux Foundation
 
Network File System in Distributed Computing
Network File System in Distributed ComputingNetwork File System in Distributed Computing
Network File System in Distributed ComputingChandan Padalkar
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scriptingVIKAS TIWARI
 

Was ist angesagt? (20)

Linux commands
Linux commandsLinux commands
Linux commands
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Filepermissions in linux
Filepermissions in linuxFilepermissions in linux
Filepermissions in linux
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Vi editor in linux
Vi editor in linuxVi editor in linux
Vi editor in linux
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
美团技术团队 - KVM性能优化
美团技术团队 - KVM性能优化美团技术团队 - KVM性能优化
美团技术团队 - KVM性能优化
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
Chapter01 Introduction To Windows Server 2003
Chapter01     Introduction To  Windows  Server 2003Chapter01     Introduction To  Windows  Server 2003
Chapter01 Introduction To Windows Server 2003
 
User management
User managementUser management
User management
 
NFS(Network File System)
NFS(Network File System)NFS(Network File System)
NFS(Network File System)
 
Linux history & features
Linux history & featuresLinux history & features
Linux history & features
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, XilinxXPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
XPDDS19 Keynote: Xen Dom0-less - Stefano Stabellini, Principal Engineer, Xilinx
 
Network File System in Distributed Computing
Network File System in Distributed ComputingNetwork File System in Distributed Computing
Network File System in Distributed Computing
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 

Ähnlich wie Unit 10 investigating and managing

Ähnlich wie 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
 

Mehr von root_fibo

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network clientroot_fibo
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing filesroot_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 scriptroot_fibo
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystemroot_fibo
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration toolsroot_fibo
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing toolsroot_fibo
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i oroot_fibo
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shellroot_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 editorroot_fibo
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and grouproot_fibo
 

Mehr von 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
 

Kürzlich hochgeladen

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Kürzlich hochgeladen (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

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