Tuesday, 9 December 2014

Process Management from Linux Command Line


Process Management from Linux Command Line


Running a foreground application you can use terminal or icon from launcher




you can use command <app name> bg to keep running it in background
i.e.. artha bg

or you can bring any background running application on screen by doing same type <app name> fg
i.e.. artha fg

Top


Top command provide a system stat view, The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a
list of processes or threads currently being managed by the Linux kernel.


kill

kill - The kill command will kill a process using the kill signal and PID given by the user. To use the SIGKILL signal with "kill", type one of the following for a process with a PID of 0710.

To view all the current processes from your teminal type command

ps -A


scroll around and choose the process which you want to kill and notice its Pid
(PID- its is the process Id, every process running in Linux have a certain Id its mostly a integer value.)
Use the following command to kill that particular process:-
kill -9 <pid> for example kill -9 0710


If you want to know pid of specific application then use this command pidof <appname>

i.e.. pidof firefox 

kill -SIGKILL 0710

kill -L

List the available signal choices in a nice table.
kill -9 -1

Kill all processes you can kill.

killall - The killall command kills all process with a particular name .
killall -9 firefox

pkill 

pkill- This command is a lot like killall except it allows partial names. So, "pkill -9 unity"

ps -aux | less


As the list of processes can be very long, the output of ps -aux can be piped (means transferred) to the less command, which lets it be viewed one screenful at a time. The list can be advanced one screen forward by pressing the SPACE bar and one screen backward by pressing the b key in above command.

The pstree command can also be a useful tool for finding offending processes. this command displays the names of all processes on the system in the form of a tree diagram, thatshow showing all of their parent/child inter-relationships. When used with its -p option, pstree also shows the PIDs of the processes, i.e.,
pstree -p | less

pstree can simplify terminating a series of related processes (i.e., a process and all of its descendants) because it makes it immediately clear which process is the parent; all that is necessary is to kill the parent in order to also terminate all of its descendant processes. That is, it is not necessary to manually search through a list of processes to find and individually terminate each one as would be necessary using ps.

Because Unix-like operating systems and many of their application programs are inherently very robust (i.e., stable and resistant to crashing), it is not necessary to use the kill command as often as it is to terminate programs or reboot on some other operating systems. May be anytime you want to close a application but its not responding then you can simply use this kill command to kill it instead.




Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX

standards require that "ps -aux" print all processes owned by a user

named "x", as well as printing all processes that would be selected by

the -a option. If the user named "x" does not exist, this ps may

interpret the command as "ps aux" instead and print a warning.

To see every process on the system:-
ps -e ps -ef ps -eF ps -ely

To see every process on the system using BSD syntax:-
ps ax ps axu

To print a process tree:-
ps -ejH ps axjf

To get info about threads:-
ps -eLf ps axms

To get security info:-

ps -eo euser,ruser,suser,fuser,f,comm,label ps axZ ps -eM

To see every process running as root (real & effective ID) in user

format:
ps -U root -u root u

Nice 

nice - run a program with modified scheduling priority
nice -n 'Nice value' process name

nice -n 19 firefox
 type man nice in terminal to know more.

No comments:

Post a Comment

Proper way to install nvidia 390 fix error

Proper way to install nvidia 390 if you see any error in the process look below; command  sudo apt purge --autoremove '*nvidia*&#...