Processes, Daemons Runlevels.doc

advertisement
CSIS 82
Tutorial: Processes, Runlevels and Daemons
Gagne Ch5&Ch6
System/Process Monitoring Chapter 5
ps
list processes
ps ax
(‘ax’ are the parameters passed) lists current running processes,
including processes owned by other users.
ps aux
To display the owner (user) of the processes along with the processes
ps aux | grep vi
look for vi processes or users running vi...
ps aux | grep vi | more
one page at a time
top
in Gnome
free
free –m
displays currently running processes, arranged by memory/CPU usage
‘top’ is interactive and real-time, to exit top, press the [q] key.
Main Menu => System Tools => System Monitor or type gnome-system-monitor
displays total amount of physical memory and swap space for the system & what
is used, free, shared, in kernel buffers, and cached.
shows the same information in megabytes, which are easier to read
Advanced Process Monitoring
ps alxww | more
column F=process flag, UID=userID, PID=processID, PPID=parentID
PRI=priority, NI=nice number
man ps
read about all the options for ps
pstree
shows tree of processes and the children they spawned/forked
ps axf
f will show forest view in ps as well, also PID and running state…
running state codes S=sleeping, R=running or in runqueue, T=traced/suspended
D=uninterruptible sleep (bad), Z=zombie (dead)
All this information can be used to improve system performance
Process Management Examples
ls –R / > listall
a long running process for demonstration purposes (what does it do?)
^C
abort process
ls –R / > listall 2>/dev/null &
&=run in background, best way to run long processes
ps ax
observe your process, what state?
ls –R / > listall
again, for demo
^Z
halt process
ps ax
shows ls –R process with T (traced/suspended)
bg
reruns halted process in background
kill
kill -1 PID#
kill -15 PID#
kill -9 PID#
send a signal (not always kill) to a process
SIGHUP (hangup) used with inetd daemon, hangup, reread config, restart
SIGTERM (wrap it up and close down) nicely. or use kill –TERM PID#
last resort, aborts without cleanup, effective, but can be dangerous
man 7 signal
list of signals and effects
TRY: xclock –digital –update 1 &, then kill –STOP PID# (like ^Z for bg process), kill –CONT PID#
Daemons and Run Levels, Chapter 6
daemon
A program that after being spawned (either at boot or by a shell command) disconnects
from the terminal and runs in the background. If you log out the program continues to
run in the background.
inetd
syslogd
Lessons for network connections
watches, monitors, and logs information
init
PID=1, master process, reads config file and start processes defined there
more /etc/inittab
look at runlevel your system boots at (should be 5)
ls –l /etc/rc.d/rc5.d
what services get started at runlevel 5
adding a service to your boot script: (I think! Distribution dependent)
put service call in rc.local script file
put rc.local script in /etc/init.d
(path /etc/init.d/rc.local)
link rc.local to your desired runlevel using default s99local file link
ln –s /etc/init.d/rc.local /etc/rc3.d/s99local
(an easy way to create a new script is to modify an existing one)
Add xclock service to your runlevel 5 startup
Switching between Runlevels
/etc/rc.d/init.d/named stop
Stops a specific initialization script called named
init 5
if you are already at run level 3, you'll start the processes for Ron level 5
Caution – may impact other users!
/sbin/runlevel What run level you are currently are at ( and previous one) N means same
Managing services with chkconfig
chkconfig
Adds, lists, deletes services to your run level symbolic links
chkconfig --list inet
Shows which run levels will activate inet
chkconfig --del apmd
completely stop a service from starting automatically (--add to add)
chkconfig --list apmd
It shows apmd off for all run levels
chkconfig --level 3 apmd on
Activates apmd for run level 3
chkconfig --level 345 apmd on
Activates apmd for run level 345
Graphical
ntsysv
ntsysv 345
tksysv
ksysv
turns on service for your runlevel
turns on service for 3,4,5 runlevel
mouse driven
KDE only, lets you start, stop, or restart services, and also gives you information on what
a service does—very useful for beginners!
Download