List running processes
A process is an instance of a running program. When you run a command in the terminal, a program is run and a process is created for it. Each process has a process id (PID) and it’s associated with a particular user and group account.
The ps (short for process status) command is used to list processes currently running on your Raspbian system. It can accept a lot of options that can come in handy when troubleshooting your system.
Used without any options, ps displays only processes started from the current terminal:
The output above doesn’t provide many useful information. We need to run the ps command with various options in order to get more info about our system. For example, to get information about all processes running on our system, we can use the ps -A command:
The output above gives us some useful information, such as the PIDs of the running processes and the commands used to start them. But the most commonly used options with the ps command are a, u and x (ps aux). Used with these options, the ps command will display all processes running on our system, along with information such as the username of the process′s owner, CPU loads, the starting time of the process, the command that initiated the process, etc:
Consider the following line from output:
Here is a description of each column:
- USER – the user who owns the process (the user pi in this case).
- PID – process ID of the process (2570).
- %CPU – the CPU time used divided by the time the process has been running.
- %MEM – the ratio of the process’s resident set size to the physical memory on the machine.
- VSZ – virtual memory usage of entire process (in KiB).
- RSS – resident set size, the non-swapped physical memory that a task has used (in KiB).
- TTY – controlling tty (terminal).
- STAT – multi-character process state.
- START – starting time or date of the process.
- TIME – cumulative CPU time.
- COMMAND – the command used to start the process (tail -f /var/log/messages).