Posted on
Software

ps: View currently running processes

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Understanding and Installing the ps Command on Linux to View Currently Running Processes

Monitoring running processes is a fundamental task in managing Linux systems. Whether you're a system administrator tracking the performance of servers, a developer debugging an application, or just curious about what's running on your machine, the ps command is an essential tool in any Linux user's arsenal. In this blog post, we'll explore how to use ps to view currently running processes and guide you through installing it on various Linux distributions using different package managers.

What is ps?

ps stands for "Process Status." It is used in Unix-like operating systems to display information about active processes on a system. This command can show a snapshot of processes running at the moment you run the command. You can filter this list to get details about specific processes and format the output to include specific information.

Basic Usage of ps

Before diving into installation and detailed usage, here’s a quick primer on using ps:

  • ps on its own will display processes running in the current shell.

  • ps aux lists all the running processes, showing detailed information including the user owning the process, CPU usage, memory usage, and the command that initiated the process.

  • ps -e or ps -ef provides a complete list of processes.

  • ps -u <username> shows processes run by a particular user.

These commands offer a glimpse into the powerful capabilities of ps. Different options can be combined to extract precisely the information you need.

Installing ps on Various Linux Distributions

The ps command is included in the procps or procps-ng package, depending on your Linux distribution. This package is usually installed by default on most Linux systems, but if you find it missing for some reason, here’s how you can install it:

For Debian/Ubuntu and derivatives:
sudo apt update
sudo apt install procps
For Fedora, CentOS, and RHEL:

On Fedora and newer versions of CentOS/RHEL, you can use dnf:

sudo dnf install procps-ng

On older CentOS versions, you might still use yum:

sudo yum install procps
For openSUSE:
sudo zypper install procps

Breaking Down Common Options and Flags

  • a Show processes for all users

  • u Display the user/owner of the process

  • x Include processes without a controlling terminal

  • f Show a full-format listing

Here’s how you could use ps to find details about python processes:

ps aux | grep python

This command is handy to locate all python-related processes; it lists detailed information and uses grep to filter the output.

Conclusion

The ps command is a powerful tool for monitoring the activities and resources of processes on Linux systems. By understanding how to use and install ps, you can effectively manage and troubleshoot applications and services. Remember that while ps gives a snapshot at the moment of execution, for continuous monitoring, you might want to look into tools like top or htop.

A Tip for Advanced Use

For advanced users, combining ps with other commands like grep, awk, or sort can be particularly powerful. For instance, using ps with sort to list processes by RAM usage, or employing awk to format the output extensively, can significantly enhance your process monitoring and troubleshooting abilities.

Whether you're a seasoned Linux user or just starting, mastering the ps command will enhance your ability to manage your system efficiently. Happy monitoring!