top Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

The top command is a Linux utility that allows you to monitor system processes in real-time. It gives you an overview of the system's resource usage and helps you identify processes that may be causing performance issues.

Linux top Command Syntax

The syntax for the top command is as follows:

Where:

  • OPTIONS: Optional arguments that can be used with the top command.

top Command Options:

  • -d SECONDS: Specifies the delay between each screen refresh. By default, the delay is set to 3 seconds.
  • -b: Runs top in batch mode, which is useful for scripting and logging system activity.
  • -n ITERATIONS: Specifies the number of iterations to run top for.
  • -u USERNAME: Shows only the processes for the specified username.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Example Usages

  • To run top and view system resource usage in real-time::

    Explanation: This will open the top utility and display system resource usage in real-time. Press 'q' to exit.

  • To run top and sort processes by CPU usage::

    Explanation: This will sort the processes by CPU usage, with the highest usage at the top of the list.

  • To run top and show only processes for a specific user::

    Explanation: This will show only the processes for the specified username.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Tips

  • Press 'h' while running top to display a help screen with a list of available commands.

  • Use the up and down arrow keys to scroll through the list of processes.

  • Use the 'r' command to renice a process and change its priority.

Advanced Use Cases of top Command in Linux

  • To run top in batch mode and output system resource usage to a file::

    Explanation: This will run top in batch mode for 1 iteration and output the system resource usage to a file named top_output.txt.

  • To run top and display only the running processes::

    Explanation: This will sort the processes by CPU usage, display only the running processes, and update the screen every second.

  • To run top and highlight processes using a specific color scheme::

    Explanation: This will highlight processes using a color scheme, making it easier to identify resource-intensive processes.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • The top command is a powerful tool for monitoring system resource usage in real-time.

  • It can be used to identify resource-intensive processes and diagnose performance issues.

  • By using the various options and commands available with the top command, you can customize the output and gain deeper insights into your system's performance.

  • Learning how to use the top command is an essential skill for any Linux system administrator or power user.