What Is Ps in Shell Scripting?

//

Angela Bailey

In shell scripting, ps stands for “process status”. It is a command that is used to provide information about the currently running processes on a Unix-like operating system. The ps command displays the process ID (PID), terminal associated with the process, CPU and memory usage, and other details.

Basic Usage

To use the ps command, open your terminal and type ps, followed by any desired options.

The basic usage of the ps command is as follows:

$ ps [options]

Options

The ps command offers various options to customize its output. Some commonly used options are:

  • -e: Displays information about all processes, regardless of the terminal they are associated with.
  • -f: Provides full-format listing, including additional details like parent process ID (PPID) and CPU usage.
  • -u: Displays information about processes belonging to a specific user.
  • -l: Provides a long listing format with detailed information about each process.
  • -a: Shows information about all processes except session leaders and processes that have no controlling terminal.

Examples:

Example 1: Basic Usage

To display information about all currently running processes, simply run the following command:

$ ps

Example 2: Custom Output Format using -f Option

If you want to see more detailed information about the processes, you can use the -f option.

$ ps -f

Example 3: Filtering Processes by User

If you only want to see processes belonging to a specific user, you can use the -u option followed by the username.

$ ps -u username

Conclusion

The ps command in shell scripting is a powerful tool for obtaining information about running processes. By using various options and combinations, you can customize the output according to your needs. Understanding how to use this command will help you monitor and manage processes effectively on your Unix-like system.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy