du, df, free and sar command
du (Disk Usage) is used to estimate the disk space used by files and directories. It identifies which files and directories consume the most disk space. Commonly used options with du ‘-h’ for human readable format and ‘-s’ to display a summary of directory total size.
Eg: du -h /path/to/directory
df (Disk Free) is used to find the available disk space mounted on file system. It defines the total disk space, used space, available space and the file system type for each mounted partition. Useful options with df ‘-h’ for human readable output and ‘-T’ to display the file system type.
Eg: df -T /dev/sda1
The free command is used to display the system information (RAM) usage. It defines the total memory, used memory, free memory, shared and cache memory. Eg: free -h
sar (System Activity Report) is a performance monitoring and reporting tool that is used to collect, report and save the system activity information. It helps administrator to monitor the overall health and performance of a system including CPU and memory usage, disk and network activity.
Eg: 1. This will report the CPU usage in every 1 second 5 times
ubuntu@ip-172-31-35-243:~$ sar -u 1 5
The output will include the information such as
%user: Time spent in user mode, %system: Time spent in system mode, %iowait: Time spent waiting for I/O operations to complete, %idle: Time the CPU was idle.
sar -r 1 5 → To check the memory usage (used and free memory)
The output will include the information such as
kbmemfree → free memory in kilobytes, kbmemused: used memory in kilobytes, kbbuffers → memory sued by kernel buffers.
To check the disk activity we use → sar -d 1 5