Linux Process Displaying

LinuxLinuxBeginner
Practice Now

Introduction

In the distant reaches of the galaxy, the Hegemony Empire has established itself as a technological colossus, wielding vast computational resources to maintain its dominance. As a talented engineer working in the Empire's tech division, your mission is clear—optimize the performance of the systems powering the empire's interstellar network. The Empire's vast computational nexus is pivotal for its strategic operations, and ensuring that each process runs at peak efficiency is your responsibility.

The goal of this lab is to master the use of the ps command, a crucial tool for monitoring and managing the myriad of processes running on a Linux system. By harnessing the full potential of ps, you will ensure that the Hegemony Empire's systems are running smoothly, allowing them to keep a watchful eye over the galaxy. Prepare to embark on a journey that not only covers the technical aspects but also sharpens your problem-solving skills as an Imperial Technology Engineer.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/SystemInformationandMonitoringGroup -.-> linux/ps("`Process Displaying`") subgraph Lab Skills linux/ps -.-> lab-271363{{"`Linux Process Displaying`"}} end

Exploring the Basic ps Usage

In this step, you will familiarize yourself with the basic usage of the ps command. The ps command is used to display information about the currently running processes on your system. By default, without any options, ps will show processes that are associated with your current terminal session.

Open your terminal and ensure you're in the ~/project directory. Your task is to run the ps command to observe the currently active processes. Type and execute the following command:

ps

This will display a list of processes associated with the terminal. The output should look similar to this:

    PID TTY          TIME CMD
    188 pts/0    00:00:00 zsh
    449 pts/0    00:00:00 ps

In this output,:

  • PID represents the process ID
  • TTY shows the terminal associated with the process
  • TIME indicates the cumulative CPU time
  • CMD shows the command that initiated the process.

Displaying All Processes

Now that you have a basic understanding of ps, let's expand your knowledge. The Empire requires complete oversight, and you must be able to display all processes on the system—not just those attached to your terminal.

In this step, you will use ps with the -e option to display every process running on the system. In the terminal, run:

ps -e

You will see a comprehensive list of all processes with additional details. It will look similar to this:

    PID TTY          TIME CMD
      1 ?        00:00:00 init.sh
     22 ?        00:00:00 supervisord
     23 ?        00:00:00 sshd
···

Notice how processes not associated with any terminal are displayed with a ? under the TTY column.

Show Processes in Full Format

As an Imperial Technology Engineer, having detailed insights into each process is vital. The full-format listing provides a wealth of information, which could be critical for your analyses.

Use the -f option with ps for a full-format listing. Execute the following in your terminal:

ps -ef

This command displays an extended list of details for each process, such as the UID (user ID), PPID (parent process ID), and more. Here's a snippet of what you should see:

UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 16:45 ?        00:00:00 /bin/bash /etc/shiyanlou/sbin/init.sh
root          22       1  0 16:45 ?        00:00:00 /usr/bin/python3 /usr/bin/supervisord -n
root          23      22  0 16:45 ?        00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
...

By understanding the information provided in this format, you can make informed decisions about managing processes.

Summary

In this lab, you've taken on the role of an Imperial Technology Engineer and learned to wield the ps command to display and manage processes in a Linux environment. We've covered the basics of displaying processes related to your terminal session, expanded to view all system processes, and looked at the full-format listing for detailed insights. This knowledge is essential for ensuring the Hegemony Empire's systems are operating with maximum efficiency. Your command of the ps utility will prove invaluable as you continue your career with the Empire.

Other Linux Tutorials you may like