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.

echo $$

Here list of commands related to processes in Linux.

  1. ps – list the processes
  2. top – more detailed information about the processes
  3. kill pid – kills the process by id
  4. killall processname – kills process by name
  5. pstree command – shows the process tree

ps command in Linux

ps command lists down the processes started in current shell.

ps -f

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.

ps -aux

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.

kill -l

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.

You may also like...