Bird
Raised Fist0
Linux CLIscripting~20 mins

top and htop (live monitoring) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Live Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Understanding the default output of top
What does the first line of the top command output typically show?
Linux CLI
top -b -n 1
ASystem uptime, number of users, and load averages
BMemory usage details only
CList of running processes with CPU usage
DDisk usage statistics
Attempts:
2 left
💡 Hint
Look at the very top line of the top output.
💻 Command Output
intermediate
1:30remaining
Identifying process sorting in htop
By default, how does htop sort the list of processes when you open it?
Linux CLI
htop
ABy process ID, ascending
BBy CPU usage, highest first
CAlphabetically by process name
DBy memory usage, lowest first
Attempts:
2 left
💡 Hint
Look at the column headers and which column is highlighted.
❓ Configuration
advanced
2:00remaining
Customizing top to show only processes of a specific user
Which command will show top output filtered to only display processes owned by user alice?
Atop -p alice
Btop --user=alice
Ctop -U alice
Dtop -u alice
Attempts:
2 left
💡 Hint
Check the top manual for the option to filter by user.
❓ Troubleshoot
advanced
2:00remaining
Resolving htop not showing colors correctly
If htop shows no colors and looks plain, which environment variable is most likely misconfigured?
AHOME
BPATH
CTERM
DUSER
Attempts:
2 left
💡 Hint
This variable tells programs what kind of terminal you are using.
✅ Best Practice
expert
2:30remaining
Choosing the best tool for live system monitoring with process tree view
Which tool is best suited for live monitoring of system processes with an interactive tree view showing parent-child relationships?
Ahtop
Bps
Ctop
Dvmstat
Attempts:
2 left
💡 Hint
One tool provides an interactive interface and can show process trees.

Practice

(1/5)
1. What is the main purpose of the top command in Linux?
easy
A. To display live system and process information
B. To edit text files
C. To compile programs
D. To manage user accounts

Solution

  1. Step 1: Understand the function of top

    The top command shows real-time information about system processes and resource usage.
  2. Step 2: Compare with other options

    Options B, C, and D relate to different commands or tools, not top.
  3. Final Answer:

    To display live system and process information -> Option A
  4. Quick Check:

    top = live system info [OK]
Hint: Remember: top shows live system stats [OK]
Common Mistakes:
  • Confusing top with text editors like nano
  • Thinking top manages users
  • Assuming top compiles code
2. Which of the following commands correctly starts htop in the terminal?
easy
A. start htop
B. htop -start
C. htop &
D. run htop

Solution

  1. Step 1: Identify correct syntax to run htop

    The command htop runs the program; adding & runs it in background.
  2. Step 2: Check other options for correctness

    Options B, C, and D are not valid Linux commands to start htop.
  3. Final Answer:

    htop & -> Option C
  4. Quick Check:

    Run htop with 'htop &' [OK]
Hint: Run htop by typing 'htop' or 'htop &' [OK]
Common Mistakes:
  • Using invalid flags like -start
  • Typing 'start htop' which is Windows style
  • Using 'run htop' which is not a Linux command
3. You run top and see a process using 95% CPU. What does this indicate?
medium
A. The process is waiting for user input
B. The process is sleeping and not active
C. The process is stopped
D. The process is using most of the CPU power

Solution

  1. Step 1: Interpret CPU usage in top

    High CPU percentage means the process is actively using CPU resources.
  2. Step 2: Understand other states

    Sleeping or waiting processes use little CPU; stopped processes do not use CPU.
  3. Final Answer:

    The process is using most of the CPU power -> Option D
  4. Quick Check:

    High CPU% = active process [OK]
Hint: High CPU% means active process using CPU [OK]
Common Mistakes:
  • Thinking high CPU means sleeping
  • Confusing waiting with stopped
  • Assuming stopped processes use CPU
4. You try to run htop but get: command not found. What should you do?
medium
A. Restart the computer
B. Install htop using the package manager
C. Run top instead
D. Check if you typed htop correctly

Solution

  1. Step 1: Understand 'command not found' error

    This means htop is not installed or not in PATH.
  2. Step 2: Fix by installing htop

    Use package manager like sudo apt install htop or sudo yum install htop to install.
  3. Final Answer:

    Install htop using the package manager -> Option B
  4. Quick Check:

    command not found = install missing tool [OK]
Hint: Install missing commands with package manager [OK]
Common Mistakes:
  • Restarting without installing
  • Ignoring the error and running top
  • Not checking spelling before install
5. You want to find and kill the process using the most memory using htop. What steps should you follow?
hard
A. Sort by memory, select process, press F9 to kill
B. Sort by CPU, select process, press F10 to kill
C. Sort by PID, select process, press F3 to kill
D. Sort by user, select process, press F5 to kill

Solution

  1. Step 1: Sort processes by memory usage in htop

    Press F6 or click the memory column to sort descending by memory.
  2. Step 2: Select the top memory-consuming process and kill it

    Use arrow keys to select process, then press F9 to kill it.
  3. Final Answer:

    Sort by memory, select process, press F9 to kill -> Option A
  4. Quick Check:

    htop kill = sort mem + F9 [OK]
Hint: In htop, F9 kills selected process after sorting [OK]
Common Mistakes:
  • Using wrong function keys to kill
  • Sorting by CPU instead of memory
  • Trying to kill by PID without selecting
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard