Process related commands in Linux
A process is nothing but a binary file that is currently executing (running). For example – When you execute ls command in Linux, the /bin/ls binary starts running. Every process has a parent process associated with it except the init process. When you execute any command in shell, the process that is created is a child process of a shell and a shell process is the parent of that process.
You can find the process id of shell by executing below command.
Here list of commands related to processes in Linux.
- ps – list the processes
- top – more detailed information about the processes
- kill pid – kills the process by id
- killall processname – kills process by name
- pstree command – shows the process tree
ps command in Linux
ps command lists down the processes started in current shell.
To list down all processes of specific user, you can use below syntax.
ps -u <User_Name>
To list down all processes in a system, you can use below command.
top command in Linux
top command shows all processes in the system. It also shows cpu usage, memory usage, status of process, user of process etc.
kill command in Linux
kill command terminates the process by id. Below command will kill process with id 1233
kill -9 1233
here -9 means kill forcefully. Terminate signal is sent to the process. To view all signals, you can use below command.
killall command in Linux
killall command terminates the process by name. Below command will kill all nano processes.
killall -9 nano
pstree command in Linux
pstree command shows the process tree of the system. We can easily find the parent and child of each process using pstree.