PROCESS MANAGMENT LINUX COMMANDS | TOP | PS | JOBS | KILL | PID | PSTREE



Linux File Process : A process is a task which is running or executing state in CPU

 

Process type

1: user processes : process runs by user like top etc

2: daemon processes : application or task specific process running in the background or hold for action like sshd , httpd etc

3: kernel processes : same as daemons but more powerful. These processes own & controlled by kernel itself  like systemd

 

State of a process

-running or executing state

-zombie state

-sleep state

-hold state

 

Commands to monitor or manage processes in linux:

 

1: ps

#list all the process in current user tty session

#use “man ps” for full review of “ps” commands

some common commands are:

ps -ef # (e) for all (f) for full format

so it will show you the all processes runnning in the linux machine with full format

 

ps -au “username”  # (a) for all (u) for user specific

so it will show all the process running under of username

 

ps -ax  # (x) is process without controlling tty

this will show all process without controlling tty sessions

 

option a & e is same but for  different flavour of linux/unix system

 

2: pstree

 

# ”pstree” is another command to view process in tree order

 

pstree -p username #shows process in tree manner running under username


3: top

Top commands show you the current running process in live state order. You can also view the CPU RAM utilization also , here you will get some another feature of ‘top’ command like kill any process ,change the priority of any process etc. For the just press ‘h’ key after running the ‘top‘ process

 

4: 'pidof' or 'pgrep' command

These commands are used to check the pid of any application or process like

~$ pidof firefox

~$ pgrep firefox

 

5: 'kill' command 

kill command used for kill any process at anytime.

 

kill -l #it will show you all the signal options of killing a process e.g “kill -9 Firefox” will kill a process without asking application to shutdown or harsh killing or “kill -15 Firefox” will kill process with asking the application to shutdown or soft killing

killall:

'killall' is the command to kill all process with specified option with it

e.g killall -u username #will kill all process running under username

 

pkill

#pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.

~$ pkill -HUP sshd #will send signal to sshd to reread it config file


6: change the process priority commands

1: nice #will change or modified the priority of any running command in which it will use e.g.

~$ nice -n -10 sudo cp filename /root #in this command we have change the priority of copy command with -10. range of priority number is between -19 to 20 where -19 is higher & 20 is lower priority number.

 

renice #will change the priority of current running process with specified option

~$ renice -n 15 -p 2334 #where we are changing the priority of process with its pid number

~$ renice -n -11 -u username #you can also use ‘-u’ with user specified option

 

OR you can use top command to renice the value of any process or pid.

 

just run top command >> then press r to renice the value >> then enter the process pid number & hit enter >> then give the renice value & hit enter.

 

 

7: Checking the jobs running in the background.

 

~$ jobs

 

 

Post a Comment

0 Comments