What is their purpose in this step?

QuestionsQuestions8 SkillsProDec, 10 2025
051

Ah, thanks for clarifying!

The purpose of these commands in this step is to set up a process that testuser will later terminate with their newly
defined sudo permissions.

Let's break it down:

  1. pgrep top || echo "No top processes running": This command first checks if any top processes are already running.

    • pgrep top: Searches for processes named "top" and returns their PIDs if found.
    • ||: This is an "OR" operator. If the pgrep top command fails (meaning no top processes are found), then the
      command after || will execute.
    • echo "No top processes running": Simply prints this message if no top processes are found.
      The primary goal here is to ensure we start fresh without existing top processes, to avoid confusion.
  2. sudo top &: This command starts the top process (a real-time task manager) as the root user and runs it in the
    background.

    • sudo top: Runs top with superuser privileges.
    • &: This symbol sends the top process to the background, so your terminal prompt becomes available again
      immediately, and top continues to run without monopolizing your console.

Later in the step, testuser (with limited sudo access) will use the pkill command to stop this background top process,
thus demonstrating that our custom sudo rule works as intended.

Does that help clarify their purpose?

0 Comments

no data
Be the first to share your comment!