Technoracle
    Facebook Twitter Instagram
    • Sitemap
    • Privacy Policy
    • Disclaimer
    • Term of Services
    Facebook Twitter Instagram Pinterest Vimeo
    TechnoracleTechnoracle
    • Tutorials
      • Amazon Cloud
      • Google Cloud
    • How To
    • Blog
    • About
    Subscribe
    Technoracle
    Home»How To»How to Check CPU Usage in Linux Easily
    How To

    How to Check CPU Usage in Linux Easily

    Rajesh ShivamBy Rajesh ShivamMarch 26, 2022Updated:March 26, 2022No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    How to Check CPU Usage in Linux
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Analyzing CPU usage is very important for the smooth running of any system. Sometimes CPU usage reaches 100% and due to that CPU becomes unavailable for processing other requests until the CPU becomes free. There may be multiple reasons behind high CPU usage, such as Programs with higher CPU requirements, autostart programs, multiple opened tabs of browsers, and many more reasons. In this tutorial, I am going to explain how to check CPU usage in Linux and the causes of high CPU usage in Linux. So, let’s get started.

    Page Contents

    • How to Check CPU Usage in Linux
      • Top command (Most common method)
      • Check CPU Usage using htop
      • CPU Activity Check using mpstat Command
    • Conclusion

    How to Check CPU Usage in Linux

    There are plenty of tools and commands to monitor CPU Usage. Let’s start with the most popular command top to find out CPU usage in Linux. In this article, I am going to discuss commonly used methods to check CPU usage.

    Top command (Most common method)

    The top command provides a real-time view of the system. It displays CPU utilization, process statistics, threads details, uptime, swap space, etc. All the data are filterable by size, type, and order.

    Open terminal from the application launcher or press (control + alt + t) on the keyboard. Now, run the top command.

    $ top

    The top command will show all the running processes, threads, system uptime, number of users, the total number of running tasks, etc. To exit from top, press Q on the keyboard.

    Sample output of top command.

    top command output

    Now let’s see how we can check the information one by one by sorting the top command with options.

    Some Important Top Command Options to Check CPU Usage

    OptionsDescription
    PSort processes by CPU usage
    IRemove idle processes
    SSort the list by how long processes have been running
    Msort task list by memory usage
    Tsort task list by run time
    Nsort task list by process id

    To access the help manual of the top command, run following command.

    $ man top

    Check CPU Usage using htop

    Htop is more like an improved version of top command with more interactive, graphical, and easier to read than top command. Htop allows you to kill the processes without PID, it makes it easier to sort the process based on the usage, etc. To install htop on the Ubuntu system, run the following command.

    $ sudo apt install htop

    Once the installation completed. Run the htop command.

    $ htop

    Sample output.

    htop command output

    Learn more about htop here.

    CPU Activity Check using mpstat Command

    The mpstat command writes to standard output activities for each available processor. Most of the RHEL based operating systems include mpstat by default. In Ubuntu, you need to install sysstat to use mpstat. Run the following command to install sysstat.

    $ sudo apt install sysstat

    Once the installation is completed, run mpstat command to check the CPU activity details.

    $ mpstat

    You should get the following output.

    mpstat command output

    To print from the first processor (0 is the first one) with option -p and ALL will list all the CPU statistics. The command is

    $ mpstat -P ALL

    Output.

    how to check CPU usage in Linux

    Conclusion

    In this article, you have learned how to check CPU usage in Linux. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.

    ubuntu tips
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleHow to Upload File to AWS EC2 Instance
    Next Article How to Setup Ubuntu Firewall Easily
    Rajesh Shivam

    Hello, everyone, I am Rajesh Shivam, I am a full-time freelancer with more than seven years plus experience in different freelancing platforms, in this blog, I am going to provide complete freelancing tips and tricks.

    Related Posts

    How To

    How to Install Microsoft Teams on Ubuntu 22.04 Easily

    February 22, 2023
    Read More
    How To

    What is Elastic IP and Its Pricing in AWS

    February 22, 2023
    Read More
    How To

    How to Convert PEM to PPK file [Step by Step Guide]

    February 22, 2023
    Read More
    Add A Comment

    Leave A Reply Cancel Reply

    Facebook Twitter Instagram Pinterest
    © 2023 Technoracle

    Type above and press Enter to search. Press Esc to cancel.

    Go to mobile version