Bookmark this page

Guided Exercise: Viewing Linux Processes

View the status of processes and monitor resource usage.

Outcomes

  • Use the GNOME System Monitor application and command-line tools to monitor application usage.

As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.

[student@workstation ~]$ lab start network-process

Instructions

  1. Launch the GNOME Calculator application and monitor the process resources.

    1. Launch the GNOME Calculator.

    2. Launch the GNOME System Monitor. On the Processes tab, click the Process Name column to sort by name. Review the list of processes and locate the gnome-calculator process.

    3. Review the user owner, CPU usage, memory, and other information for the gnome-calculator process.

      Figure 7.10: GNOME calculator process resources
  2. Stop the GNOME Calculator application.

    1. Select the entry for gnome-calculator and click End Process in the bottom left corner to stop the application.

    2. Confirm the operation by clicking End Process.

      Figure 7.11: Stopping a process in GNOME System Monitor
  3. Launch the GNOME Calculator again.

  4. Find the GNOME Calculator PID on the command line.

    1. List all active processes that are running in the system.

      [student@workstation ~]$ ps -ef
      UID          PID    PPID  C STIME TTY          TIME CMD
      root           1       0  0 14:04 ?        00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 31
      root           2       0  0 14:04 ?        00:00:00 [kthreadd]
      root           3       2  0 14:04 ?        00:00:00 [rcu_gp]
      ...output omitted...
      root       36259       2  0 18:43 ?        00:00:00 [kworker/u8:1-events_unbound]
      student    36260    3639  0 18:44 pts/5    00:00:00 ps -ef

      The process list is long, which makes it difficult to find a single process.

    2. Find the GNOME Calculator PID by using the pgrep command.

      [student@workstation ~]$ pgrep -f gnome-calculator
      2958
  5. Find and terminate the GNOME Calculator PID interactively by using the top command.

    [student@workstation ~]$ top
    1. Press uppercase L on your keyboard to enter the top search prompt. Type calc and press Enter.

      Your output might vary.

      Figure 7.12:

      Locating a process in the top command

    2. Press k to terminate the gnome-calculator process. The top command suggests the first result as the process to stop.

      Figure 7.13:

      Stopping a process in the top command

    3. Verify that the PID matches the ID for the gnome-calculator process. If the suggested PID does not match the gnome-calculator process, then enter the PID manually. Press Enter to confirm the PID and press Enter again to accept the default signal to stop the process.

      Press q on your keyboard to exit the top command.

      Figure 7.14: Confirm the default signal to stop the process
  6. Verify that the gnome-calculator process is no longer running by using the pgrep command. As expected, the pgrep command returns no results.

    [student@workstation ~]$ pgrep -f gnome-calculator

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish network-process

Revision: rh104-9.1-3d1f2bc