

$ ps -eo pid,ppid,cmd,%mem,%cpu -sort=-%mem | head Find top running processes by highest memory and CPU usage in Linux. If your system isn’t working as it should be, for instance, if it’s unusually slow, you can perform some system troubleshooting as follows.Ģ6. Find Process Uptime Troubleshoot Linux System Performance The output below shows the HTTPD service has been running for 1 hour, 48 minutes, and 17 seconds. Find all PIDs of all instances of a process, useful when writing scripts that need to read PIDs from an std output or file. To select a specific process by its name, use the -C flag, this will also display all its child processes. $ ps -p 1154 -o comm=įind Process using PID Display Parent and Child ProcessesĢ2. $ ps -p 1154 -o pid,ppid,fgroup,ni,lstart,etimeĢ1. Below is another example of a custom output format showing file system group, nice value, start time, and elapsed time of a process. The command below allows you to view the PID, PPID, user name, and command of a process. To list all format specifiers, include the L flag. Using the -o or –format options, ps allows you to build user-defined output formats as shown below.ġ8. List Process Threads Specify Custom Output Format To print all threads of a process, use the -L flag, this will show the LWP ( lightweight process) as well as NLWP ( number of the lightweight processes) columns. List Tree View of Process Print Process Threadsġ7. $ ps -ef -forest | grep -v grep | grep sshd You can also print a process tree for a given process like this. A process tree shows how processes on the system are linked to each other processes whose parents have been killed are adopted by the init (or systemd). To select processes by tty, use the -t flag as follows.ġ5. List Processes by PIDs Display Processes by TTYġ4. You can list processes by PID as follows. To list all processes owned by effective group name (or session), type. If you want to list all processes owned by a certain group (real group ID ( RGID) or name), type. $ ps -U root -u rootĭisplay Root User Running Processes Display Group Processesĩ. The command below enables you to view every process running with root user privileges (real & effective ID) in user format. Print All Processes Running as Root (Real and Effective ID)Ĩ. To select a user’s processes by effective user ID ( EUID) or name, use the -u option. To display a user’s processes by real user ID ( RUID) or name, use the -U flag. You can select all processes owned by you (runner of the ps command, root in this case), type: $ ps -xĦ. List Processes in Long List Format Display User Running Processesĥ. To perform a full-format listing, add the -f or -F flag. Display every active process on a Linux system in generic (Unix/Linux) format. List Current Running Processes Print All Processes in Different FormatsĢ.

If you run the ps command without any arguments, it displays processes for the current shell.
