How to View All Running Processes in Linux

How to View All Running Processes in Linux

You can use the ps command. It can display relevant information about the currently running process, including the process's PID. Both Linux and UNIX support the ps command, which displays information about all running processes.

The ps command provides a snapshot of the current process. If you want the status to refresh automatically, you can use the top command.

ps Command

Enter the following ps command to display all running processes:

# ps aux | less

in,

-A: Display all processes

a: Display all processes in the terminal including those of other users

x: Display processes without a controlling terminal

Task: View every process in the system.

# ps -A
# ps -e

Task: View processes running as non-root

# ps -U root -u root -N

Task: View the processes run by user vivek

ps -u vivek

Task: top command

The top command provides a dynamic real-time view of a running system. Type top in the command prompt:

# top

Output:

Press q to exit, press h to enter help.

Task: Display a tree view of the process.

pstree displays the running processes in a tree format. The root node of the tree is pid or init. If a username is specified, the process tree will be rooted at processes owned by that user.

$ pstree

Sample output:


Task: Use ps to print the process tree

# ps -ejH
# ps axjf

Task: Get thread information

Enter the following command:

# ps -eLf
# ps axms

Mission: Get security information

Enter the following command:

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

Task: Save process snapshot to file

Enter the following command:

# top -b -n1 > /tmp/process.log

You can also email the results to yourself:

# top -b -n1 | mail -s 'Process snapshot' [email protected]

Use the pgrep command. pgrep can find currently running processes and list the process IDs that meet the conditions. For example, to display the process ID of Firefox:

Task: Find Process

$ pgrep firefox

The following command will display the process named sshd and owned by root.

$ pgrep -u root sshd

Say hello to htop and atop

htop is an interactive process viewer similar to top, but with vertical and horizontal scrolling to view all processes and their command lines. Process related operations (killing, renicing) do not require input of PID. To install htop enter command:

# apt-get install htop

or

# yum install htop

Type htop in the command prompt:

# htop

atop tool

atop is an interactive monitoring tool for viewing Linux system load. It shows the usage of key hardware resources (from a performance perspective) at the system level, such as CPU, memory, disk, and network.

It can also show which processes are causing a certain load based on CPU and memory load at the process level; and can show disk and network load per process if the kernel patch has been installed. Enter the following command to start atop:

This is the end of this article about how to view all running processes in Linux. For more information about viewing running processes in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 4 ways to view processes in LINUX (summary)
  • Linux method example to view all information of the process
  • How to view process stack information in Linux
  • How to view the processes that currently occupy the most CPU or memory in Linux
  • How to view ports, processes and kill processes in Linux
  • How to view the number of file handles opened by a process and how to modify them in Linux
  • How to view the number of handles occupied by system processes under Linux
  • In-depth understanding of viewing process memory usage under Linux
  • Check which processes occupy the swap partition in Linux to implement a script
  • How to check which program/process occupies a port in Linux/window
  • How to view the process number and program name of the port occupied in Linux

<<:  JavaScript functional programming basics

>>:  MySQL's method of dealing with duplicate data (preventing and deleting)

Recommend

CentOS 6.4 MySQL 5.7.18 installation and configuration method graphic tutorial

The specific steps of installing mysql5.7.18 unde...

Summary of webpack's mobile adaptation solution

Table of contents rem vw Adapt to third-party UI ...

html option disable select select disable option example

Copy code The code is as follows: <select> ...

MySQL scheduled task example tutorial

Preface Since MySQL 5.1.6, a very unique feature ...

Implementation of mysql decimal data type conversion

Recently, I encountered a database with the follo...

The best explanation of HTTPS

Good morning everyone, I haven’t updated my artic...

MySQL 8.0 New Features - Introduction to Check Constraints

Table of contents Preface Check Constraints Creat...

Record a pitfall of MySQL update statement update

background Recently, I executed a DML statement d...

Front-end state management (Part 2)

Table of contents 1. Redux 1.1. Store (librarian)...

A brief analysis of how to upgrade PHP 5.4 to 5.6 in CentOS 7

1. Check the PHP version after entering the termi...

Theory: The two years of user experience

<br />It has been no more than two years sin...

td width problem when td cells are merged

In the following example, when the width of the td...