Friday, April 17, 2015

Day 13: The Linux Command Line Ch10 Notes Cont


Chapter 10 - Processes Continued

Commands:
ps – Report a snapshot of current processes
top – Display tasks
jobs – List active jobs
bg – Place a job in the background
fg – Place a job in the foreground
kill – Send a signal to a process
killall – Kill processes by name
shutdown – Shutdown or reboot the system

Controlling Processes

CTRL-c
Interrupt process (many programs are ask to be terminated, but not all will terminate). 

&
Starting program followed by "&" puts the process in the background (making it hidden). This way we can work on the console while program is working for us in the background. 

$ jobs
Displays IDs of programs running in the background

$ fg %number 
(where number is job id)
Brings the process back to forground making it visible.

CTRL-z
Pauses the program. Program that is paused can be put in the forground using 'fg %number' or into background using 'bg %number'

$ bg %number
Places process in the background making it invisible.

Signals

The 'kill' command sends signals to program (TERM signal is send by default). The syntax is as shown below:

$ kill [-signal] PID

where PID is process id (check with ps aux or ps -e)
and signal is one of the following: