A process can be identified as a set of instructions loaded to the memory. Every process has UID and GID.
Who is the owner of the ‘firefox’ program?
Code: Select all
stat /usr/bin/firefox
stat $(which firefox)
Observe,
Get PID, Executed User, Real User, Common Name
Code: Select all
ps axo pid,euser,ruser,comm |grep firefox
ps axo pid,euser,ruser,comm |egrep ‘init|firefox’
Code: Select all
ps axo pid,%cpu,%mem,tty,euser,ruser,comm |less
find the parent process
Code: Select all
pstree |less
What is a Signal in Linux
This a UNIX concept which is used to inter-process communication. Using Signal can send a message directly to a process. There are many Signal types are available. Most frequently use signal are;
HUP (1) -> re-read the config file
KILL (9) -> Terminate immediately
TERM (15) -> Terminate gracefully
Further, observe
Code: Select all
man 7 signal
Code: Select all
kill
killall
pkill
pgrep
Observe:
1.
Code: Select all
$ pgrep crond
$ pgrep cupsd
# kill -HUP $(pgrep crond)
# kill -HUP $(pgrep cupsd)
$ pgrep crond -> has PID got changed?
$ pgrep cupsd -> has PID got changed?
# kill -9 $(pgrep cupsd)
$ pgrep cupsd
# service crond start
$ pgrep crond -> check the PID
Code: Select all
$ firefox &
$ killall firefox ->Observe the firefox
$ pkill firefox
Code: Select all
$ firefox
$ ctrl + z
$ jobs -> find the job id
$ bg %1 -> resume the background process 1
$ fg %1
$ kill %1
Start Stop Services
All init script of the process are usually in /etc unless if you have given a installing prefix when compiling the packages.
How to use;
Code: Select all
/etc/init.d/servicename start|stop|reload|restart|status
Code: Select all
service servicename start|stop|reload|restart|status
Start Stop service while Boot and Shutdown time
At the booting process kernel start the init process, which is the master process of the system. Then read the /etc/inittab to decide the default runlevel.
Observ:
Code: Select all
cat /etc/inittab
|
# Default runlevel. The runlevels used are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (same as 3, do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault: # default runlevel
According to the runlevel defined the appropriate directory is used to run the initial script.
Code: Select all
|- rc0.d
|
|- rc1.d
|
|- rc2.d
|
/etc/rc.d/|- rc3.d
|
|- rc4.d
|
|- rc5.d
|
|- rc6.d
Observ:
Code: Select all
ls -al /etc/rc.d/rc5.d
Code: Select all
K95cgconfig -> ../init.d/cgconfig
K95firstboot -> ../init.d/firstboot
S02lvm2-monitor -> ../init.d/lvm2-monitor
S07iscsid -> ../init.d/iscsid
Anatomy of the init scripts
Code: Select all
S 07 iscsid
S for start at boot _| | |_ init script
K dont start |_ prority level