managing processes csci n321 – system and network administration copyright © 2000, 2011 by scott...
TRANSCRIPT
![Page 1: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/1.jpg)
Managing Processes
CSCI N321 – System and Network Administration
Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University
![Page 2: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/2.jpg)
Section Overview
UNIX Processes
Running programs
Monitoring processes
Killing processes
![Page 3: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/3.jpg)
References
CQU 85321 System Administration Course
Chapter 5
![Page 4: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/4.jpg)
Programs & Processes
Program – file which can be run Binary executables Shell scripts
Process – A running program Loaded in physical memory Stored in virtual memory (swap)
![Page 5: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/5.jpg)
Virtual Memory
Extends amount of physical memoryUNIX Size of swap = amount of usable memory Physical memory (RAM) mirrored in swap
Linux: Memory = swap + RAMSwapping Moving pages to and from memory Page – block (unit) of RAM
![Page 6: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/6.jpg)
Swap AllocationBSD UNIX:
RAM:
Swap:
AT&T SVR4/Linux:
RAM:
Swap:
Which works better when?
Windows: C:\pagefile.sys (Grows as needed)
![Page 7: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/7.jpg)
Windows pagefile.sys Settings
![Page 8: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/8.jpg)
WaitWait
DoneDone
Process Lifecycle
NewNew ReadyReadyAdmittedAdmitted
SchedulerSchedulerDispatchesDispatches
InterruptInterrupt
RunRun
ExitExit
I/O I/O RequestRequestI/O CompletedI/O Completed
![Page 9: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/9.jpg)
Process Components
Sleeping Stopped
Address space mapStatus
OwnerBlocked Signals PriorityResources used
Running Runable
Zombie
![Page 10: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/10.jpg)
Process Ownership
Real User (User starting the process) UID: User ID Number GID: Group ID Number
Effective User (Permissions for process) EUID: Effective User ID Number EGID: Effective Group ID Number
![Page 11: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/11.jpg)
Process Lifecycle
Parent process “forks” a childProcess identifiers PID: Process ID Number PPID: Parent Process ID Number
Child finishes Sends status message to parent Zombie – waits for parent
acknowledgment Orphan – init (PID 1) becomes parent
![Page 12: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/12.jpg)
Running a command
Type in the command nameShell searched for the commandIf found, shell “forks” the commandHow is the command found? PATH environment variable which – Displays full path to command Beware of “.” in your PATH
![Page 13: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/13.jpg)
Background Jobs
Foreground process Returns control to shell after it
finished Most common usage
Background process Returns control to shell immediately “&” typed after command name Runs concurrently
![Page 14: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/14.jpg)
Daemons
Special programs which performs a some task without interventionStarted in the background (often at system startup)
Name of most ends in ‘d’
“Daemon” is actually a much older form of “demon”; daemons have no particular bias towards good or evil, but rather serve to help define a person's character or personality.
~Evi Nemeth
![Page 15: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/15.jpg)
fg, bg, & jobs
Can switch between modesSend signal to stop a processCommands fg – Run process in foreground bg – Run process in background jobs – List shell child processes
![Page 16: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/16.jpg)
Signals
Used to communicate with processesTerminal signals <Ctrl><c> - Terminate process <Ctrl><z> - Stop (suspend) process
kill [-signal] pid Sends signal to process PID Default is to terminate the process
![Page 17: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/17.jpg)
Common Signals
## NameName DescriptionDescription
1 HUP Hangup
2 INT Interrupt
3 QUIT Quit
9 KILL KILL
15 TERM Software Termination
STOP Stop
![Page 18: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/18.jpg)
Process Priority
How much CPU time granted relative to other processesnice – Sets the priority value at startrenice – Changes priorityRangesSystemSystem RangeRange
Solaris 0 to 39
RedHat -20 to 20
![Page 19: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/19.jpg)
System Load
Average number of “Runnable” processesMeasure of how busy the system isPerformance deteriorates at loads of 6+Good for creating a baselineuptime – Load average (5, 10, 15 minutes)
![Page 20: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/20.jpg)
Monitoring Processes (Linux)
ps BSD – Sorts by %CPU Usage SVR4 – Sorts by PID
top Full terminal screen display Sortable Can kill and renice processes
![Page 21: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/21.jpg)
Information from ps
PID
USER
PRI/NI - Priority/Nice levelRSS/SIZE - Resident/Total Memory usedSTAT - Process State%CPU/%MEM - % of System CPU/MemoryTIME - CPU time usedCommand
![Page 22: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/22.jpg)
/proc Filesystem
Pseudo filesystem Interface to memory-related kernel data structuresEach PID has it’s own directory cwd – Symlink to current working directory exe – Symlink to program cmdline – command line options environ – command line environment stat – process status
![Page 23: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/23.jpg)
Monitoring Processes (Windows)
Task Manager Graphical viewer Can also sort or kill processes
tasklist Command line Viewer Can view associated dll files
wmic process [options] Can view, start, and kill processes Remote connection capabilities
![Page 24: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/24.jpg)
SysInternals - Process Tools
Command Line tools Pslist – display running processes Pskill – Kill processes by name or PID Psexec – Run programs remotely
GUI Tools Procmon – Detailed process info RAMMap – View RAM usage VMMap – View Virtual Memory usage
![Page 25: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/25.jpg)
Runaway Processes
Can eat up your resourcesLists users and PIDs accessing a resource fuser lsof
Kill the process and clean up
![Page 26: Managing Processes CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University](https://reader035.vdocuments.site/reader035/viewer/2022062222/56649ea05503460f94ba3ea3/html5/thumbnails/26.jpg)
Elevating Access
Principle of Least Privilege su [-] <user> - “Switch user” Requires user password if not run as root ‘-’ runs a subshell owned by user
Microsoft runas (Automatic Popup Win7)Sudo – Run programs as superuser /etc/sudoers – who can run what visudo – Editor for /etc/sudoers sudo – Used to run commands as root Windows version available