How to Use the sar Command on Linux (2024)

How to Use the sar Command on Linux (1)

The sar command lets you see performance statistics for different elements of your Linux computer, for both real-time and historical data. We show you how to use this great resource.

RELATED: How to View System Performance Statistics on Your Chromebook

The sar Command

The sar command, or System Activity Reporter, is part of the sysstat package. It captures a set of statistical information such as CPU load, memory paging, memory utilization, swap usage, network I/O, and much more. It makes this data accessible to you in real-time snapshots—showing you what’s happening on your computer right now—and in historical reports.

RELATEDUnderstanding the Load Average on Linux and Other Unix-like Systems

It runs in the background as a daemon, gathering a set of data every ten minutes. The data for the current day is written to a text file. It is converted to a binary file as midnight passes. The files are overwritten each month so they don’t steadily gobble up your hard drive’s capacity.

The sar command lets you interrogate the system and see the statistics. But first, you’ll need to install the sysstat package.

Installing the sysstat Package

Installing sysstat is very straightforward. We use the package manager of your Linux system to install it and then use systemd to enable and start the background daemon.

To install sysstat on Ubuntu we use apt:

sudo apt install sysstat

How to Use the sar Command on Linux (3)

To install sysstat on Fedora, type:

sudo dnf install sysstat

How to Use the sar Command on Linux (4)

And to install sysstat on Manjaro, we use pacman:

sudo pacman -S sysstat

How to Use the sar Command on Linux (5)

With sysstat installed, we need to enable it so that it can run as a daemon—a background process—each time you boot your computer, and we need to start it now so that we can use it right away. We use systemctl, part of the systemd family of utilities, to enable and start daemons.

sudo systemctl enable sysstat

How to Use the sar Command on Linux (6)

sudo systemctl start sysstat

How to Use the sar Command on Linux (7)

To see which version of sar you’re using, and to make sure it is responding, you can use the -V (version) option:

sar -V

How to Use the sar Command on Linux (8)

Real-Time Statistics With sar

You can use sar to see what is happening inside your computer right now. And because a snapshot is just that—the state of play at a certain point in time—and sometimes a trend is more useful, you can ask sar to display several snapshots with a specified number of seconds between them.

CPU Statistics

To see three sets of CPU statistics with two seconds between them, we’d use this command, which uses the -u (CPU) option. Note that the interval comes first. So this command reads “show the CPU stats in steps of two seconds, for three sets of data.”

sar -u 2 3

How to Use the sar Command on Linux (9)

Stretching your terminal window makes the table line up neatly, so it is easier to read.

The header for the first column is the time the command was executed. The values in the column are the time each set of data was collected at. The other columns are:

  • CPU: The number of the CPU core, or ALL for the average of all cores.
  • %User: The percentage of time spent running applications at the user level, “in userland.”
  • %Nice: The percentage of time spent running applications at the user level, with nice priority.
  • %system: The percentage of time spent executing processes at the system level, in the kernel.
  • %iowait: The percentage of time when the CPU was idle with a pending disk I/O request.
  • %steal: In a virtual machine, this is the percentage of time the virtual CPU was idle because the CPU of the hardware host was servicing a different virtual machine.
  • %idle: The percentage of time when the CPU was idle without any pending disk I/O requests.

The final line is the average of the preceding lines.

To see the statistics for a specific core, use the -P (per-processor) option. This is followed by the number of a CPU core, or a list or range of core numbers, like 0,1,4 or 4-8.

This command looks at three sets of data with one second between them, for core 1. Remember, cores are numbered from zero.

sar -P 1 1 3

How to Use the sar Command on Linux (10)

Memory Paging Statistics

The -B (paging) option causes sar to display statistics related to the paging of memory to the hard drive. We’re going to ask for two sets of information, with five seconds between them.

sar -B 5 2

How to Use the sar Command on Linux (11)

The columns contain the following information.

  • pgpgin/s: Total number of kilobytes the system has paged in (retrieved) from the hard drive per second.
  • pgpgout/s: Total number of kilobytes the system has paged out to the hard drive per second.
  • fault/s: Number of page faults, both minor and major, made by the system per second.
  • majflt/s: Number of major faults the system has made per second, that have required loading a memory page from disk.
  • pgfree/s: Number of pages placed on the free list by the system per second.
  • pgscank/s: Number of pages scanned by the memory management system kswapd daemon per second.
  • pgscand/s: Number of pages scanned directly per second.
  • pgsteal/s: Number of pages the system has reclaimed from cache per second.
  • %vmeff: Calculated as pgsteal / pgscan, this is an indication of the efficiency of page reclaims.

I/O Transfer Rates

To see the I/O and transfer rate statistics, use the -b (note, lowercase “b”) option. We’re asking for three sets of data with four seconds between them.

sar -b 4 3

How to Use the sar Command on Linux (12)

This is what the columns hold.

  • tps: Total number of transfer requests per second that were made to physical devices. Note that this is a count of requests. They may not all have been successful.
  • rtps: Total number of read requests per second issued to physical devices.
  • wtps: Total number of write requests per second issued to physical devices.
  • dtps: Total number of discard requests per second issued to physical devices.
  • bread/s: Total amount of data read from physical devices. The figure is given in blocks of 512 bytes, per second.
  • bwrtn/s: Total amount of data written to physical devices in blocks per second.
  • bdscd/s: Total amount of data discarded in blocks per second.

There are many more categories of information that you can select to review. They are all used in the same manner. You can also use the -A (all) option to see a complete dump of everything sar can throw at you.

Check out the sar man pagefor the full list.

RELATED: What Are Read/Write Speeds, and Why Do They Matter?

Historical Statistics With sar

To review any of the historical data is simply a case of adding the -s (start) and -e (end) options time to any of the usual sar commands. The times are expressed in the 24-hour clock.

To see what the CPU load was like between 06:30 and 07:15 today, we’ll use this command.

sar -u -s 06:30:00 -e 07:15:00

How to Use the sar Command on Linux (13)

To see what the situation was like on a previous day, use a number as an option flag. The number indicates which day to report on. The -1 option would mean yesterday, the -2 option would mean two days ago, and so on.

Let’s generate a report between 13:00 and 13:00, using yesterday’s data.

sar -u -1 -s 13:00:00 -e 13:30:00

How to Use the sar Command on Linux (14)

Another way to specify the day you wish to report on is to use the name of that day’s data file on the command line. We do this with the -f (filename) option.

The daily files are called “saXX” where the XX is replaced by the day of the month. They’re created in the log folder of your Linux computer. The sar log folder is probably called “/var/log/sa/” or “/var/log/sysstat/.”

On Ubuntu it is “/var/log/sysstat/” so the format of our command to see the CPU usage between 14:00 and 14:30 for the 21st day of this month would look like this:

sar -u -s 14:00:00 -e 14:30:00 -f /var/log/sysstat/sa21

How to Use the sar Command on Linux (15)

Information Is Power

And sar certainly gives you enough information to make informed decisions on the performance of your computer.

If you’re in a support role—or you’re the tech support for your friends and family—being able to review historical data is a great way to start digging into an issue that gets reported to you today but actually happened yesterday. Or last week.

RELATED: System Slow? How to See If Linux is Memory, CPU, or IO Bound

READ NEXT

  • How to Fix Joystick Drift on Xbox, PlayStation and Other Controllers
  • How to Repost on TikTok
  • Blue Light Is Not as Bad as You Think
  • How to Use Split Screen on a Mac
  • Windows 10 Home vs. Pro: What’s the Difference?
  • What Are Reference Headphones and Speakers (And Should You Buy Them?)
How to Use the sar Command on Linux (2024)

FAQs

How to check SAR value in Linux? ›

First thing first, install the “sysstat” which provides the sar utility. By default, sar stats are collected every 10 minutes. The data is collected using a simple cron job configured within /etc/cron. d/sysstat.

How to check memory usage using SAR in Linux? ›

Use the sar -r command to report the number of memory pages and swap-file disk blocks that are currently unused. Output from the -r option is described in the table below. The average number of memory pages available to user processes over the intervals sampled by the command. Page size is machine-dependent.

How to check CPU usage with sar command? ›

Use the sar -u command to display CPU utilization statistics. The sar command without any options is equivalent to sar -u . At any given moment, the processor is either busy or idle. When busy, the processor is in either user mode or system mode.

Why use sar command in Linux? ›

The sar command gathers statistical data about the system. Though it can be used to gather some useful data regarding system performance, the sar command can increase the system load that can exacerbate a pre-existing performance problem if the sampling frequency is high.

How do I run a .sar file? ›

Download SapCar.exe and extract the SAR File

Rename the file to SAPCAR.exe. Open a command prompt and go to the SAPCAR.exe location. In the command prompt, type SAPCAR.exe –xvf NWRFC_xxxxxx. SAR to unpack the SAR file.

How does sar command work? ›

The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters, writes information the specified number of times spaced at the specified intervals in seconds.

How can I check my SAR limit? ›

SAR (Specific Absorption Rate) for Mobile Phones

The International Commission on Non-Ionizing Radiation Protection (ICNIRP) has prescribed Specific Absorption Rate (SAR) for mobile Phones. DoT has approved the permissible SAR value limits for Mobile Phones to 1.6 W/Kg measured over 1 gm tissue.

What is the code to check SAR value? ›

-- On your phone open the dialer or phone app. -- Now dial *#07# in your phone. This will show the you the SAR measurement of your device as specified by the manufacturer.

How do I see total RAM in Linux? ›

Linux
  1. Open the command line.
  2. Type the following command: grep MemTotal /proc/meminfo.
  3. You should see something similar to the following as output: MemTotal: 4194304 kB.
  4. This is your total available memory.

How do I monitor RAM usage in Linux? ›

The /proc/meminfo file stores statistics about memory usage on the Linux based system. The same file is used by free and other utilities to report the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel.

How do I check my RAM speed Linux? ›

Linux check ram speed and type commands
  1. Open the terminal application or log in using ssh command.
  2. Type the “ sudo dmidecode --type 17 ” command.
  3. Look out for “Type:” line in the output for ram type and “Speed:” for ram speed.
Sep 9, 2022

How can I see my full CPU usage? ›

System Cooling Policy
  1. Click the Start button and click Control Panel.
  2. Click Power Options.
  3. Click Change Plan Settings.
  4. Click Advanced Power Settings.
  5. Expand the Processor Power Management list.
  6. Expand Minimum Processor State List.
  7. Change the settings to 100 percent for "Plugged in."
  8. Expand System Cooling Policy List.

How to check the CPU utilization in Linux? ›

Running the mpstat command on a Linux system will display an output like the one shown in figure 2. This command shows various CPU statistics including idle time, io wait time and steal time. Similar to the top command, the idle time shown here can be used to compute the CPU utilization using the same formula.

How to check CPU core utilization in Linux? ›

You can check how your CPU is being used with the htop command. This prints out real-time information that includes tasks, threads, load average uptime and usage for each CPU. You should see a real-time display with information on how your CPU is being put to use.

How to enable SAR in Linux? ›

Sar must be enabled before it can begin to collect data. Using your preferred text editor, open the /etc/default/sysstat configuration file, and change the value of ENABLED to true .

How do I check the health of my Linux server? ›

Here are some command-line tools that focus on monitoring Linux disk storage:
  1. df. You can use df to check how much space your Linux machine is using. ...
  2. du. This command-line utility allows you to see disk space that is already consumed by files. ...
  3. The ls Command. ...
  4. top. ...
  5. htop. ...
  6. mpstat. ...
  7. vmstat. ...
  8. iostat.
Nov 24, 2022

How to extract SAR files in Linux? ›

How to extract (decompressing) CAR and SAR Files ? - Go to the directory where you want to decompress via the "cd" command - SAPCAR -xvf <your-SAR-file> (or car -xvf <your-SAR-file>) On AS/400: SAPCAR '-xvf <your-SAR-file>' - Then all files and directories, that are stored in this archive, become decompressed.

What must you do when responding to a SAR? ›

You must comply with a SAR without undue delay and at the latest within one month of receipt of the request or within one month of receipt of:
  1. any information requested to confirm the requester's identity (see 'Can we ask for ID? '); or.
  2. a fee (only in certain circ*mstances – see 'Can we charge a fee? ').

Where are Linux SAR files? ›

The name "sar" stands for "system activity report," and it can display current performance, provide reports that are based on log files stored in your system's /var/log/sa (or /var/log/sysstat) folder, or be set up to automatically produce daily reports.

What is the highest SAR level? ›

According to the report, Samsung smartphones emit the least radiation level. It is worth noting that there's no universal standard for safe SAR value for smartphones. In India, SAR value for phones is set at a maximum of 1.6 W/kg. The US also has a maximum of 1.6 W/kg for SAR value.

What happens if SAR value is high? ›

While there has been a lot of talk about the phones with high SAR (specific absorption rate) value can potentially damage the body at a cellular level, particularly when you hold the phones against your ears and talk on them, not enough attention has been paid by smartphone users to the damage that these devices the ...

Does SAR value change over time? ›

Do SAR values change when a mobile's OS is updated? Original OS updates from the manufacturer are designed to improve the software functioning in the device and do not affect any radio settings including SAR values.

What is *# 67? ›

Use *67 to hide your phone number

Open your phone's keypad and dial * - 6 - 7, followed by the number you're trying to call. The free process hides your number, which will show up on the other end as “Private” or “Blocked” when reading on caller ID. You will have to dial *67 each time you want your number blocked.

What parameters affect SAR? ›

Specific absorption rate proportionately increases with certain parameters:
  • square of the Larmor frequency or B0, i.e. worse as main field increases.
  • square of the B1 pulse, worse with larger flip angles.
  • size and shape of the patient: larger SAR with obesity.
  • RF pulses per unit time: greater SAR with FSE/TSE.
Sep 10, 2019

Which SAR value is harmful? ›

According to US Federal Communications Commission (FCC), phones with a SAR level of 1.6 W/Kg for body or below are deemed safe. The same measurement is followed in India. In Europe, the government agencies require that the phone should have a SAR value of less than 2W/kg.

Does Linux have a RAM limit? ›

Linux and Unix-based computers

Most 32-bit Linux systems only support 4 GB of RAM, unless the PAE kernel is enabled, which allows a 64 GB max. However, 64-bit variants support between 1 and 256 TB. Look for the Maximum Capacity section to see the limit on RAM.

What happens when RAM is full Linux? ›

That is the swap partition. When Ram is filled linux takes this swap area to run low priority process. No process is run from swap.

How to check resource usage in Linux? ›

Check CPU Usage with Iostat Command

Run the iostat command without any option will display the information about CPU utilization, device utilization, and network file system utilization. Use the -c option to break the CPU utilization into user processes, system processes, I/O wait, and idle time.

How do I check my RAM latency and speed? ›

The part number of a memory module is usually printed on its body. You can search for this part number to know more about the CAS Latency of this RAM. Alternatively, sometimes, RAM timings may also be printed. It can look somewhat like this – CL15-18-18-36.

How to check CPU speed in Linux? ›

Using lscpu

We can also use the lscpu command-line utility to retrieve the CPU speed. lscpu collects the general CPU architecture information from the /proc/cpuinfo virtual file and the sysfs pseudo-file system. As we can see from the output of lscpu, the results are 2.70 GHz and 2904.004 MHz, just like before.

How do I reduce RAM usage in Linux? ›

Reducing RAM usage
  1. Disable and uninstall memory-intensive applications. ...
  2. Uninstall disabled applications. ...
  3. Uninstall applications that are running but have no rules enabled or otherwise aren't being used. ...
  4. Uninstall Spam Blocker and Phish Blocker if they're not being used. ...
  5. Bypass DNS sessions.

Is it normal to have 90% CPU usage? ›

If you are currently not running any additional programs, your CPU usage should be anywhere between 1% and 10% just through Windows processes alone. Anything higher than that on an idle PC means that something might be wrong.

Is 99% CPU usage normal? ›

If the CPU usage is around 100%, this means that your computer is trying to do more work than it has the capacity for. This is usually OK, but it means that programs may slow down a little. Computers tend to use close to 100% of the CPU when they are doing computationally-intensive things like running games.

Is 70% CPU usage normal? ›

If the System Idle Process is high, around 70% - 90%, in the CPU column of the Task Manager. And, you're not running any programs or perhaps just a few. It is normal for it to be high because the processor is not doing much at the moment.

How do I fix high CPU usage in Linux? ›

Below are some common fixes to reduce high CPU load:
  1. Kill or restart processes: Often, there are just one or two processes increasing the CPU load. ...
  2. Update system apps and drivers: Outdated drivers and apps can also cause high CPU load because they can't effectively perform the I/O operations.

How to debug high CPU utilization in Linux? ›

Debugging High CPU Utilization Issues
  1. Capture thread dumps for analyzing the thread state and calls. ...
  2. Capture top CPU consuming threads data for 5 minutes run by using a jvmtop utility. ...
  3. Capture method level CPU profiling data for 5 minutes run by using a jvmtop utility. ...
  4. Capture container logs for the test run duration.

How do I fix high CPU usage? ›

This can happen for several different reasons, which is why it's important to learn how to fix high CPU usage in Windows 11.
  1. Reboot Your PC. Before trying anything else, try restarting your PC. ...
  2. End or Restart Processes. ...
  3. Update Drivers. ...
  4. Scan for malware. ...
  5. Power Options. ...
  6. Find Specific Guidance Online. ...
  7. Reinstalling Windows.

How do you check if all 4 cores are running? ›

Press Ctrl + Shift + Esc to open Task Manager. Select the Performance tab to see how many cores and logical processors your PC has.

How to check CPU and memory utilization in Linux in percentage? ›

mpstat Command to Display CPU Activity
  1. %usr – % CPU usage at the user level.
  2. %nice – % CPU usage for user processes labeled “nice”
  3. %sys – % CPU usage at the system (Linux kernel) level.
  4. %iowait – % CPU usage idling waiting on a disk read/write.
  5. %irq – % CPU usage handling hardware interrupts.
Jan 31, 2019

How do I check my top 10 CPU usage Linux? ›

Use ps Command to Find Top Processes by Memory and CPU Usage

ps is a Linux command-line utility with many options that helps you to display output in different formats. You can use the ps command with –sort argument to sort the output by memory and CPU usage.

How to check CPU health in Linux? ›

How to Check Your CPU in Linux
  1. Use the cat command to display the data held in /proc/cpuinfo. ...
  2. Use lscpu to display the CPU details. ...
  3. Using a vertical pipe, send the output of the lscpu command to grep and search for “max”. ...
  4. Type in the dmidecode command using sudo, and the argument -t 4.
Feb 20, 2022

How to enable sysstat in Linux? ›

The SysStat utility in Debian 10 can be installed by running the following command:
  1. sudo apt install sysstat.
  2. sudo nano /etc/default/sysstat.
  3. sudo systemctl enable sysstat.
  4. sudo systemctl start sysstat.
  5. sudo systemctl status sysstat.
  6. sudo apt-get autoremove --purge sysstat.

How do I check performance issues in Linux? ›

There are a handful of key Linux commands that system administrators use daily to monitor the performance of their computers and servers, debug performance issues, and to predict and avoid performance bottlenecks.
...
Top 7 Linux performance commands for system administrators
  1. top.
  2. vmstat.
  3. lsof.
  4. tcpdump.
  5. netstat.
  6. iostat.
  7. iotop.

How do I check my CPU problems? ›

Use Task Manager to view CPU consumption to help identify the process or application that's causing high CPU usage:
  1. Select Start, enter task, and then select Task Manager in the search results.
  2. The Task Manager window defaults to the Processes tab. ...
  3. Select the CPU column header to sort the list by CPU usage.
Dec 8, 2022

How do I check my CPU malfunction? ›

One of the most common signs of CPU failure is the random freezing of your computer, usually after just logging into the operating system. The system won't respond to any of your instructions. The mouse freezes on the screen and any attempt to use the keyboard will result in a series of short beeps.

What are health check commands in Linux? ›

health-check options are as follow: -h Show help -b Brief (terse) output for quick overview. -c Find and monitor all child and threads of a given set of processes. This option is only useful when attaching to already running processes using the -p option. -d Specify analysis duration in seconds.

How do I check my filesystem health? ›

Examples
  1. To check all the default file systems, enter: fsck. This command checks all the file systems marked check=true in the /etc/filesystems file. ...
  2. To fix minor problems with the default file systems automatically, enter: fsck -p.
  3. To check a specific file system, enter: fsck /dev/hd1.

How can I check the health status of a server? ›

How to Conduct a Server Health Check
  1. Hardware metrics – Fans, power supply, disk drives, CPU, storage, memory, environmental conditions.
  2. Reports – Information on procurement, usages, and status to use with future purchases.
  3. Alarms – Notifications of changes in server health for faster resolution.
Sep 1, 2021

How to calculate total CPU usage in Linux? ›

CPU Utilization is calculated using the 'top' command.
  1. CPU Utilization = 100 - idle time.
  2. CPU Utilization = ( 100 - 93.1 ) = 6.9%
  3. CPU Utilization = 100 - idle_time - steal_time.

Top Articles
Latest Posts
Article information

Author: Jamar Nader

Last Updated:

Views: 5950

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Jamar Nader

Birthday: 1995-02-28

Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

Phone: +9958384818317

Job: IT Representative

Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.