You are on page 1of 41

r 

i  


|    
    j     
V  
ÿ Define and describe various Linux ë  and

ÿ Define and analyze process control
ÿ Assign process ë 

ÿ Îxplain process     and process  


|    
    j     
i  
  i 
ÿ A ë   is an executable file, for example: /bin/bash
ÿ A ë  is an 
 of a program being executed.
Process is also called

ÿ A process may execute more than one program during its
lifetime
ÿ The kernel arranges for each process to have a share of the
CPU and automatically switches from executing one process
to executing another

|    
    j     
i  
  i 
ÿ Îvery process has a priority associated with it
ÿ Îach time a context switch is made (i.e., a new process is to
be run) the kernel searches a queue of these processes and
selects the one with the  
ë 

ÿ A user or programmer can   a process's ë 
using
the O or O  command but  
 ë    
 
ë 

|    
    j     
|  
i V  
ÿ èive types of processes on Linux system:
Daemon
Parent
Child
Orphan
Zombie or defunct

|    
    j     
-


ÿ Daemon processes are Linux processes that support system
functions. They are normally started up when multi-user mode is
entered at boot time
ÿ The key attribute of a daemon process is the fact that it is not
attached to a terminal; this is shown on a ë listing as a question
mark (?) in the terminal (TTY) column
ÿ Daemons typically Õ
 
such as a signal, a file being
created, data input from a serial line or network, or a time out.
 

 
Õ ë  




ë 

|    
    j     
-


ÿ Zombie processes are those processes that have
finished but the parent process does not clean it up
ÿ The only way to remove zombies in this situation is to
terminate the parent process (see the kill command)
and restart the application

|    
    j     
X      i 
ÿ Îvery process is identified by a unique number, process
ID (PID); and each process has an owner and a group,
the effective UID and GID, that define the processes'
access to the system

|    
    j     
X      i 
ÿ The kernel maintains a large amount of information
about each process :
ÿ i -i- A positive integer value that uniquely
identifies the process in the system ,PIDs are allocated in
sequence automatically
ÿ 2       
 process's virtual memory
ÿ §  -

|    
    j     
r   i 
ÿ Command èormat :
ë ë O 

Options :
 Print information about  process
on the system.
 Generate a   
.
 Generate a  


|    
    j     
´  

§- i-ii- r |2 22 2 r-

root 1 0 80 16:46:44 ? 0:40 /etc/init


root 2 0 27 16:46:44 ? 0:00 pageout
aster 1292 1 80 06:48:51 console 0:01 -ksh
henry 231 1 80 06:48:51 pts/1 0:01 bash

|    
    j     
|    |  
i 
´    

ïï 
  ë
ï 
  ë 
ï 
  ë

´  


ïï  ë
ï  ë 
ï  ë

|    
    j     
½  r


ÿ The ë provides an ongoing look at processor activity in real
time
ÿ It displays a listing of the most CPU-intensive
 on the
system, and can provide an interactive interface for
manipulating processes: sort the tasks by CPU usage, memory
usage, and runtime
ÿ ›oth Gnome and KDÎ have GUI versions of top: ë and ë
respectively. Users familiar with the Windows Task Manager
will recognize ë as a clone of this Windows feature

|    
    j     
i i   

ÿ When assigning ë 
to a process, the kernel
supplies something called a    . Nice numbers
range from -20 (highest) to +19 (lowest). Processes
started by a user have a nice value of 0

|    
    j     
O  r


ÿ The O  command to modify the nice numbers on processes





ÿ Uegular users can only adjust nice values from 0 to 19, while
super users can adjust nice values from -20 to 19. If no
adjustment value is given, then the process is assigned a
value of 10
ÿ If no commands are specified, then O  displays the current
scheduling priorities

|    
    j     
O  r


ÿ Command format :
O ë O O
ÿ Îxamples:
ƒO ïO ë Set nice number is 2
ƒO ïO ë Set nice number is -2
ƒO OïO ë Set nice number is -2

|    
    j     
O  r


ÿ The O  command to modify the nice numbers on
processes that      
ÿ There is some syntactical difference between nice and
renice, mainly that renice does not require the use of
two dashes (i.e. ï) to signify a negative nice number

|    
    j     
O  r


ÿ Command format :
O ë      ë 


ÿ Îxamples:
ƒO ïï  Set nice number is -2 to PID=203
ƒO  O Set nice number is 5 to all
processes started by henry

|    
    j     
| 
ÿ ardware-related program faults (Divide by zero),
press Ctrl+C, « can cause signals
ÿ System administrators usually  

 ë 
 ë .
ÿ There are a number of standard signals. You can use
  or O O to list all signals supported
by the system

|    
    j     
| 
ÿ ( refer to ´O O )

r



SIGUP 1 angup detected on controlling terminal or
death of controlling process
SIGINT 2 Interrupt from keyboard (Ctrl+C pressed)
SIGKILL 9 Kill signal
SIGTÎUM 15 Terminate program


|    
    j     
Sending Signals to Processes
ÿ The  and ë commands can help you to send
signals to processes

|    
    j     
w

r


ÿ Provides a direct way to terminate unwanted command
processes
ÿ Command èormat
w


 

ÿ Terminating a Process :
1. Type  to find out the PIDs for the processes.
2. Type w

followed by the PIDs.

|    
    j     
è   2
  i 
´  O
i     
ïï O     
ïï ë     O
ï  ë    ë

´w



´ w

 i ö

|    
    j     
w

r


ÿ Command èormat
w


 ëë  

ë 
 ë    
  

|    
    j     
    | 

ÿ The shell can register signal handlers using the ë


command. Traps are used mostly within programs and
scripts:
ë$ O  O

 O List of ), separated by µ;¶ and  



ë   

O List of signal name(s) or signal number(s)

|    
    j     
    | 

ÿ Set traps :
ƒë Oë O  
ƒë Oë Oï
ƒëï 

ÿ Ueset traps :
ƒëï

|    
    j     
|   i 
ÿ The  command

ÿ The O command

|    
    j     
¦½ r


ÿ Îxecute commands 
ë  
 or run the commands

   .
ë O ! "!"
ÿ  reads commands from  O or file (with  option) and
executes them using user¶shell
ÿ  and  of this command   

 
who run the command by default
ÿ ( Îxamples )

|    
    j     
¦½ 

ÿ Uun  ë   once at 6:15 p.m tomorrow:
´¦½  ½  
"ë
"
ÿ The ^D indicates that the user typed Ctrl-D on the
keyboard, sending the end-of-file character to
terminate the at command

|    
    j     
¦½ 

ÿ Uun commands that are listed in the file  

at 9 p.m. two days from now:

´G 
 ë#ï

|    
    j     
„    -  ¦½  

  List jobs, it¶s an alias for 

£ Uemoves jobs, it¶s an alias for 

 Like 

£ Like 

ƒ ¦½

$ï    ï 

ƒ ¦½  

ƒ ¦½
|    
    j     
2   O½¦ r


ÿ Use O to run jobs at ë   
 
ÿ List cron table with:
O   
ÿ Îdit the current cron table with:
O  
ÿ Uemove the cron table with:
O  

|    
    j     
crontab èile Structure
ÿ Îach line in in a crontable includes commands and information to determine
when to run the command :
! O"!"!"!O"!"! ¦O"
Ü Space/tab separated fields (columns)
Ü Use comma-separated list or range of values in each field

 O Minute (0 through 59)

 our (0 through 23)

 Day of the month (1 through 31)

O Month (1 through 12 or Jan through Dec)

 Day of the week (0 through 6 [where 0 is Sunday] or sun


through sat)
O Command (any valid command, including spaces and standard
›ourne shell syntax)

|    
    j     
crontab èile Structure
ÿ èields with µ*¶ will match any values
ÿ Lines that begin with the pound sign (#) are 

  and are ignored by  
ÿ èor more details about file structure:
ƒO O

|    
    j     
crontab èile
ÿ Typically, system administrators use crontab to
  ë
the system (truncate log files, remove out-of-date or
unused files, etc.) and ë     ë 
 such
as file system backups or accounting programs
ÿ Îach user has a personal list of commands kept in the
crontab file, stored in  ë O directory

|    
    j     
Îxamples
ÿ To execute  ë   once per day at 6:15 a.m , use
this    entry:
%%%ë

ÿ To execute at 6:15 and 18:15 on the 1st and 15th of


the month, use:
   %%ë

|    
    j     
Îxamples
ÿ § 
          
 
%% &  O  
'
ïï%'(ëë›  
 %%  O ) ë
  %%   O O) ë

|    
    j     

    ¦½   O½¦

ÿ Control and configuration files are kept in /etc

)  Users allowed to use 

)O Users denied use of  (only used if no


) )
O)  Users allowed to use O

O)O Users denied use of O

O  System O table

|    
    j     

    ¦½   O½¦
ÿ These files are simply lists of account names.
ÿ If the Õ file exists, only those users listed in the Õfile may
use the service. If the Õ file does not exist but the  file
does, only those users not listed in the  file may use the
service.
ÿ èor  , if neither file exists, all users have access to  .
ÿ èor  , if neither file exists, only root has access to  . An empty

 file allows access to all users and is the default.

|    
    j     

    ¦½   O½¦
ÿ All crontabs are stored in the cron spool directory
 ë O
ÿ All at jobs are stored in the cron spool directory
 ë 
ÿ Do not edit the files in the spool directories. Use the 
and O utilities to make changes

|    
    j     
Summary
ÿ Define and describe various Linux ë  and

ÿ 
ÿ Define and analyze process control
ÿ Assign process ë 

ÿ Îxplain process     and process  


|    
    j     

You might also like