20 Linux Monitoring Commands You Should Know

In this article we are going to cover 20 Linux Monitoring Commands You Should Know as a System Admin/Linux System Admin/DevOps/SRE.

Introduction

If you are working as a System Administrator/Linux Admin/DevOps/SRE then most probably you will need to deal with performance-related issues in the Linux environment. Let’s go through some of the most used Linux command-line utilities to diagnose network and performance-related issues

Linux Monitoring Commands

1. Top

When we will run this command it will open an interactive command mode. Where the top half portion will contain the statistics of processes and resource usage. And Lower half contains a list of the currently running processes.

top 

Pressing q will simply exit the command mode.

Output:

20 Linux Monitoring Commands You Should Know 1

2. vmstat

The vmstat command is a Linux Utility for displaying statistics related to memory consumption, disk usage and other system information.

vmstat must not be present in your Linux System but no worries.

We can install easily under package “ sysstat”

vmstat

Output:

20 Linux Monitoring Commands You Should Know 2

3. iostat

The iostat command in Linux lets you monitor CPU utilization and I/O (input/output) statistics of all the disks and file systems.

iostat commands are useful for changing system configuration to better balance the i/o load between physical disks.

This command is mostly used by Linux System Administrators.

iostat

Output:

20 Linux Monitoring Commands You Should Know 3

4. iostat -d

The iostat -d command is used for monitoring system input/output device loading by observing the time the devices are active related to their average transfer rates.

iostat -d command is used to display the device utilization report.

iostat -d

Output:

20 Linux Monitoring Commands You Should Know 4

5. lsof

The job of lsof command is to “list open files” in the system.

An open file does not mean pdf or a text file, it includes disk files or pipes used by processes in the background.

This command is a handy tool for Operating System debuggers and system administrators.

lsof

Output:

20 Linux Monitoring Commands You Should Know 5

6. tcpdump

The tcpdump is a tool that is used for TCP/IP packet analysis.

This command is commonly used for traffic analyzer on Linux, as well as many other operating systems.

tcpdump allows you to sniff all traffic that goes in and out of all interfaces.

More importantly, it has the ability to filter the traffic by interface, host, destination or source host, type of traffic, and many other criteria.

We can also save the captured packets in a file for later analysis.

tcpdump

Output:

20 Linux Monitoring Commands You Should Know 6

7. netstat

netstat command displays various network related information such as network connections, routing tables, interface statistics, multicast memberships, etc.

netstat is used for monitoring incoming and outgoing network packets.

netstat

Output:

20 Linux Monitoring Commands You Should Know 7

8. netstat -s

The netstat -s command print out network statistics like total number of packets received and transmitted by protocol type and so on.

To print statistics of only select protocols like TCP or UDP use the corresponding options like t and u along with the s option.

netstat -s

Output:

20 Linux Monitoring Commands You Should Know 8

9. ps -ef | grep PID

ps command will print four columns of information for two minimum processes running in current shell.

The -e option instructs ps to display all processes.

The -f option stands for full format listing which provides detailed information about the processes.

ps -ef | grep apache

Output:

20 Linux Monitoring Commands You Should Know 9

10. nethogs

NetHogs is a small net top tool.

Instead of breaking the traffic down per protocol or per subnet, like most such tools do, it groups bandwidth by process and does not rely on a special kernel module to be loaded.

If there’s suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this, and if it’s some kind of spinning process, kill it.

nethogs

Output:

20 Linux Monitoring Commands You Should Know 10

11. mpstat

Using mpstat command will display the Global Average Activities by All CPUs.

We are able to display overall CPU statistics per system or per processor through mpstat command.

mpstat

Output:

20 Linux Monitoring Commands You Should Know 11

12. free -m

Free -m is a command that displays used memory in our system.

Free -m command also displays the available memory in our system.

free -m

Output:

20 Linux Monitoring Commands You Should Know 12

13. uptime

uptime command displays that how long does the system has been running.

It also displays how many users are logged in.

Output:

20 Linux Monitoring Commands You Should Know 13

14. ps -e

The ps command helps you to view details of currently-running processes.

We can also kill or terminate processes that are not behaving normally.

This will list all the processes running and also those process which are started by other users.

ps -e

Output:

20 Linux Monitoring Commands You Should Know 14

15. ac

The ac command displays the report of connect time(hrs) of that system on the basis of login and logout timings.

It is stored in wtmp file.

ac

Output:

20 Linux Monitoring Commands You Should Know 15

16. ac -d

The ac -d cpmmand prints total for each day than just one total at end.

ac -d

Output:

20 Linux Monitoring Commands You Should Know 16

17. ac -p

The ac -p command prints total time for each user in addition to the everything into a value.

ac -p

Output:

20 Linux Monitoring Commands You Should Know 17

18. vmstat -m

The vmstat tool is used to monitor system’s virtual memory usage.

The vmstat -m command displays the slap information of your virtual machine.

vmstat -m

Output:

20 Linux Monitoring Commands You Should Know 18

19. vmstat –d

The vmstat -d displays the disk statistics of the virtual memory of our system.

The vmstat -d tool is used to monitor system’s virtual memory usage.

vmstat -d

Output:

20 Linux Monitoring Commands You Should Know 19

20. pstree

The pstree command shows a inheritance structure of processes.

pstree command displays that which command is children of other command.

pstree

Output:

20 Linux Monitoring Commands You Should Know 20

Conclusion:

We have covered Linux Monitoring Commands You Should Know as a System Admin/Linux System Admin/DevOps/SRE.

Related Articles:

30 Basic Linux Commands with Examples

Reference:

Linux official page

Akash Padwal

I am Akash Padwal working as a DevOps Engineer Intern in Product Company. Likes to explore new DevOps tools and share knowledge.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap