Linux+ Guide to Linux Certification, Third Edition

Slides:



Advertisements
Similar presentations
Job and Process Management
Advertisements

Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.
Essential System Administration 3rd Edition Chapter 2 The Unix Way(Cont.) University Of Palestine.
Introduction to Unix – CS 21 Lecture 10. Lecture Overview Midterm questions Jobs and processes description The foreground and background Controlling jobs.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
Chapter 13 Processes. What is a process? A process is a program in execution A process is created whenever an external command is executed Whenever the.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Controlling Processes & Periodic Processes WeeSan Lee
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
Now, return to the Unix Unix shells: Subshells--- Variable---1. Local 2. Environmental.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
Processes & Daemons Chapter IV / Part III. Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more.
CS 497C – Introduction to UNIX Lecture 27: - The Process Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
5 UNIX Processes. Introduction  Processes  How to list them  How to terminate them  Process priorities  Scheduling jobs  Signals.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Linux Operations and Administration
Linux+ Guide to Linux Certification, Second Edition
Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University.
Linux+ Guide to Linux Certification, Third Edition
Chapter 4 UNIX Common Shells Commands By C. Shing ITEC Dept Radford University.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
The Shell Chapter 7. Overview The Command Line Standard IO Redirection Pipes Running a Program in the Background Killing (a process!)
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
Process Control. Module 11 Process Control ♦ Introduction ► A process is a running occurrence of a program, including all variables and other conditions.
SUSE Linux Enterprise Server Administration (Course 3037) Chapter 6 Manage Linux Processes and Services.
Managing processes and services. 1. How Linux handles processes 2. Managing running processes 3. Scheduling processes.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
The kernel considers each program running on your system to be a process A process lives as it executes, with a lifetime that may be short or long A process.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Scis.regis.edu ● CS 468: Advanced UNIX Class 4 Dr. Jesús Borrego Regis University 1.
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
1 © 2000 John Urrutia. All rights reserved. Session 5 The Bourne Shell.
Linux Commands C151 Multi-User Operating Systems.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop VI Scheduling & Process Management Professional.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Second Edition
CSC414 “Introduction to UNIX/ Linux” Lecture 3
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
1 COP 4343 Unix System Administration Unit 8: – at – cron.
Processes Todd Kelley CST8207 – Todd Kelley1.
Chapter 6: Managing Processes
Chapter 11 – Processes and Services
System Administration
SUSE Linux Enterprise Desktop Administration
The Linux Command Line Chapter 10
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
CSC 140: Introduction to IT
Linux Shell Script Programming
Controlling Processes
Lab 6: Process Management
Lecture 6 Introduction to Process Management
LPI Linux Certification
Presentation transcript:

Linux+ Guide to Linux Certification, Third Edition Chapter 9 Managing Linux Processes

Objectives Categorize the different types of processes on a Linux system View processes using standard Linux utilities Explain the difference between common kill signals Describe how binary programs and shell scripts are executed Linux+ Guide to Linux Certification, 3e

Objectives (continued) Create and manipulate background processes Use standard Linux utilities to modify the priority of a process Schedule commands to execute in the future using the at daemon Schedule commands to execute repetitively using the cron daemon Linux+ Guide to Linux Certification, 3e

Linux Processes Program: structured set of commands stored in an executable file Executed to create a process Process: program running in memory and on CPU User process: process begun by user on a terminal Daemon process: system process Not associated with a terminal Linux+ Guide to Linux Certification, 3e

Linux Processes (continued) Process ID (PID): unique identifier assigned to a process Child process: process started by another process (parent process) Parent process: process that has started other processes (child processes) Parent Process ID (PPID): PID of the parent process The init daemon has a PID of 1 and a PPID of 0 Linux+ Guide to Linux Certification, 3e

Linux Processes (continued) Figure 9-1: Parent and child processes Linux+ Guide to Linux Certification, 3e

Linux Processes (continued) Figure 9-2: Process genealogy Linux+ Guide to Linux Certification, 3e

Viewing Processes ps command: view processes Most versatile and common process viewing utility No arguments: lists all processes running in current shell PID, terminal, command that started process, CPU time –f (full) option: more complete information User identifier (UID), PPID, start time, CPU utilization -e option: displays the entire list of processes across all terminals including daemons Linux+ Guide to Linux Certification, 3e

Viewing Processes (continued) Process flag: indicates particular features of the process Process state: current processor state of process Most processes sleeping (S) or running (R) Zombie process: process finished, but parent has not released child process’s PID Defunct process Process state is Z Linux+ Guide to Linux Certification, 3e

Viewing Processes (continued) Process priority (PRI): priority used by the kernel for the process Higher value means lower priority Nice value (NI): can be used to affect the process priority indirectly Higher value means a greater chance of low priority pstree command: displays the lineage of a process by tracing its PPIDs until the init daemon Linux+ Guide to Linux Certification, 3e

Viewing Processes (continued) Table 9-1: Common options to the ps command Linux+ Guide to Linux Certification, 3e

Viewing Processes (continued) top command: displays interactive screen listing processes Organized by processor time Processes using most processor time listed first Rogue process: faulty process Consumes excessive system resources top command can be used to change PRI or kill processes Rogue processes can be killed immediately when identified Linux+ Guide to Linux Certification, 3e

Killing Processes kill command: sends a kill signal to a process to terminate it 64 types of kill signals Affect processes in different ways -l option: displays list of kill signal names and associated numbers To kill a process, give kill signal and PID If no kill signal given, the default kill signal, SIGTERM, is used Linux+ Guide to Linux Certification, 3e

Killing Processes (continued) Table 9-2: Common administrative kill signals Linux+ Guide to Linux Certification, 3e

Killing Processes (continued) Trapping: ignoring a kill signal The SIGKILL signal cannot be trapped by any process Use only as last resort When parent process receives a kill signal, parent process terminates all child processes before terminating itself To kill several related processes send signal to parent process Kill parent process in order to kill zombie processes Linux+ Guide to Linux Certification, 3e

Killing Processes (continued) killall command: kills multiple processes of the same name in one command Takes kill signal number as an option Uses process name instead of PID If no kill signal given, the default kill signal, SIGTERM, is used Can use top command to kill processes Linux+ Guide to Linux Certification, 3e

Process Execution Three main types of executable commands Binary programs e.g., ls, find, grep Shell scripts Shell functions e.g., cd, exit Linux+ Guide to Linux Certification, 3e

Process Execution (continued) Forking: act of creating new BASH shell or subshell Carried out by fork function in BASH shell Subshell executes program or shell script using exec function Original shell waits for subshell to complete When done, subshell kills itself Control returns to original shell Linux+ Guide to Linux Certification, 3e

Process Execution (continued) Figure 9-3: Process forking Linux+ Guide to Linux Certification, 3e

Running Processes in the Background Foreground processes: BASH shell must wait for termination to display prompt and accept new commands Background processes: BASH shell does not wait for termination Append & metacharacter to command Upon execution, user receives BASH shell prompt immediately Linux+ Guide to Linux Certification, 3e

Running Processes in the Background (continued) jobs command: lists background job IDs for processes running in current shell To terminate background process: Send kill signal to PID Send kill signal to background job ID Prefix job ID with % character Linux+ Guide to Linux Certification, 3e

Running Processes in the Background (continued) foreground (fg) command: move a background process to the foreground Use Ctrl+z to pause a foreground process Assigns the process a background job ID background (bg) command: send an existing process to the background Provide background job ID as argument jobs command indicates the two most recent background processes By default, commands apply to most recent process Linux+ Guide to Linux Certification, 3e

Process Priorities Time slice: amount of time a process is given on a CPU More time slices mean more execution time on CPU Executes faster Usually measured in milliseconds Linux+ Guide to Linux Certification, 3e

Process Priorities (continued) PRI dictates number of time slices a process gets Low PRI is likely to get more time slices than high PRI Cannot change PRI value directly Set NI to indirectly affect priority Negative NI value, more time slices; positive NI value, less time slices Processes start with NI of 0 nice command: change a process’s priority as it starts Linux+ Guide to Linux Certification, 3e

Process Priorities (continued) Figure 9-4: The nice value scale Linux+ Guide to Linux Certification, 3e

Process Priorities (continued) renice command: alter NI of a process after it has been started Only root user may change NI to a negative value -u option: change the NI for all processes owned by the specified user or group May also change NI of running processes using top utility Linux+ Guide to Linux Certification, 3e

Scheduling Commands To schedule commands to execute in the future: at daemon (atd): system daemon that executes tasks at a future time cron daemon (crond): system daemon that executes tasks repetitively in the future Linux+ Guide to Linux Certification, 3e

Scheduling Commands with atd at command: schedule commands and tasks to run at a preset time Specify the time as an argument –l option: view a list of at job IDs (regular users see only their own jobs) atq command: alias to at -l –c option: view content of a specified at job –d option: delete the specified at job –f option: list commands to be scheduled by at from a shell script Linux+ Guide to Linux Certification, 3e

Scheduling Commands with atd (continued) Table 9-3: Common at commands Linux+ Guide to Linux Certification, 3e

Scheduling Commands with atd (continued) at daemon uses current shell’s environment for execution Shell environment and scheduled commands stored in /var/spool/at If stdout of scheduled command has not been redirected to a file, it is mailed to user Linux+ Guide to Linux Certification, 3e

Scheduling Commands with atd (continued) /etc/at.allow: file listing all users allowed to use the at daemon /etc/at.deny: file listing all the users not allowed to use the at daemon If both files exist, only /etc/at.allow file is processed On Fedora Linux systems, only /etc/at.deny file exists by default Initially left blank, all users allowed to use at daemon Linux+ Guide to Linux Certification, 3e

Scheduling Commands with crond Suitable for scheduling repetitive tasks Cron tables: configuration files specifying when commands should be executed Six fields separated by space or tab characters First five specify times to run the command Sixth absolute pathname to command to be executed Linux+ Guide to Linux Certification, 3e

Scheduling Commands with crond (continued) User cron tables: represent tasks scheduled by individual users System cron tables: contains system tasks /var/spool/cron: stores user cron tables /etc/crontab file: contains system cron tables /etc/cron.d directory: contains system cron tables Linux+ Guide to Linux Certification, 3e

Scheduling Commands with crond (continued) Figure 9-5: User cron table format Linux+ Guide to Linux Certification, 3e

Scheduling Commands with crond (continued) Figure 9-6: Sample user cron table entry Linux+ Guide to Linux Certification, 3e

User Cron Tables /etc/cron.allow: lists users allowed to use the cron daemon /etc/cron.deny: lists users not allowed to use the cron daemon If both files exist, only /etc/cron.allow file is processed On Fedora Linux systems, only /etc/cron.deny file exists by default Initially left blank, all users allowed to use cron daemon Linux+ Guide to Linux Certification, 3e

User Cron Tables (continued) crontab command: view and edit user cron tables –e option: edit cron tables in vi editor –l option: list a user cron table –r option: remove cron table and all scheduled jobs -u option: used by root user to edit, list, or remove a specified user’s cron table Linux+ Guide to Linux Certification, 3e

The System Cron Table System maintenance, backups, and CPU-intensive tasks often scheduled for non-business hours Often scheduled by cron daemon Entries in system cron table (/etc/crontab) Linux+ Guide to Linux Certification, 3e

The System Cron Table (continued) Initial section of cron table specifies execution environment Remainder similar to user cron table entries Cron tables located in the /etc/cron.d directory are run by the system as a specified user Can schedule administrative task by placing a shell script in the appropriate one of the following directories: /etc/cron.hourly/, /etc/cron.daily/, /etc/cron.weekly, and etc/cron.monthly/ Linux+ Guide to Linux Certification, 3e

Summary Processes are programs that are executing on the system User processes are run in the same terminal as the user who executed them, whereas daemon processes are system processes that do not run on a terminal Every process has a parent process associated with it and, optionally, several child processes Linux+ Guide to Linux Certification, 3e

Summary (continued) Process information is stored in the /proc filesystem; the ps, pstree and top commands can be used to view this information Zombie and rogue processes that exist for long periods of time use up system resources and should be killed to improve system performance You can send kill signals to a process using the kill, killall, and top commands Linux+ Guide to Linux Certification, 3e

Summary (continued) The BASH shell creates, or forks, a subshell to execute most commands Processes can be run in the background by appending an & to the command name The priority of a process can be affected indirectly by altering its nice value Commands can be scheduled to run at a later time using the at and cron daemons Linux+ Guide to Linux Certification, 3e