Unveiling Linux Command's - sar
Tags: linux, terminal, bash
Published: 2023-08-28 05:08:57

In the world of computers, the SAR (System Activity Reporter) command is like a magic tool. It helps us understand how our computer is doing and where it might need some help. In this article, we'll take a look at the SAR command and see how it can tell us interesting things about our computer.

## What is SAR?

SAR stands for System Activity Reporter. It's like a detective that watches over our computer and takes notes about what it's doing. It looks at what's happening on our computer and makes reports about it. It can tell us things like how busy our computer is, how much memory it's using, how the network is behaving, and much more. It's like a data historian that keeps track of what our computer has been up to.

> For detailed matrix information, please refer to [here](https://knowledge.broadcom.com/external/article/168067/sar-system-accounting-utility.html)* and [here](https://docs.oracle.com/cd/E36784_01/html/E36819/spmonitor-8.html#ADSYSenueh)

```bash 
sar [ options ] [ <interval> [ <count> ] ]
```
example:
```bash
sar -b 1 10
```
```bash 
sar -r 1
```

SAR can do many helpful jobs for us. Let's look at some of them and see what they mean
> 

## Checking I/O and Transfer Rate
Imagine your computer is sending and receiving data. SAR can tell us how busy it is doing that. It can count how many times it's doing these jobs and how much data is being sent and received every second. 

```bash
sar -b [ <interval> [ <count> ] ]
```
example:
```bash
sar -b 1 10
```

## Paging Statistics
Sometimes, our computer needs to get information from the hard drive. This is called paging. SAR can tell us how often this happens and how much data is being moved between the hard drive and the computer's memory.
```bash
sar -B [ <interval> [ <count> ] ]
```
example:
```bash
sar -B 1 10
```
## Network Numbers
If our computer is connected to the internet, SAR can tell us how much data is going in and out. It can show us how many packets of data are being sent and received. This helps us understand if our internet connection is fast or slow.
```bash
sar -n [options] [ <interval> [ <count> ] ]
```
example:
```bash
sar -n DEV 1 10
sar -n TCP,UDP 1 10
```

## Load and Queue
When our computer is doing many things at once, it has a "load." SAR can tell us how heavy this load is. It can also tell us how many things are waiting to be done. This is like knowing how many people are waiting in line at a store.
```bash
sar -q [ <interval> [ <count> ] ]
```
example:
```bash
sar -q 1 10
```

## Memory and Swap Info
Our computer uses memory to work. SAR can show us how much of this memory is being used. It can also tell us if the computer is using "swap space," which is like extra memory.
```bash
sar -r [ <interval> [ <count> ] ]
```
example:
```bash
sar -r 1 10
```
## CPU Usage
The "brain" of our computer is called the CPU. SAR can tell us how busy the CPU is. It can say if it's mostly being used by programs, or if it's waiting for something to happen.
```bash
sar -u [ <interval> [ <count> ] ]
```
example:
```bash
sar -u 1 10
```
## Page Swapping
Sometimes, the computer needs to exchange data quickly. This is called "swapping." SAR can tell us if this is happening a lot and if it's causing any problems.

```bash
sar -W [ <interval> [ <count> ] ]
```
example:
```bash
sar -W 1 10
```

## Conclusion 
SAR is like a helpful friend that watches over our computer. It tells us all sorts of things about what's happening inside. Whether it's how busy our computer is, how much memory it's using, or how well the internet is working, SAR gives us answers. So, the next time you're curious about how your computer is performing, remember to ask SAR! Keep in mind that this article provides a simplified overview of SAR, and if you're interested in diving deeper, be sure to refer back to the detailed explanations above.