blog posts

10 Linux Function Commands

We introduce you to 10 Linux performance commands that every system administrator should know. With these tools at your disposal, you’ll be well-equipped to tackle any performance-related challenges that come your way.

Linux system administrators need robust tools to monitor and optimize their systems effectively. A deep understanding of function commands can help you quickly identify and resolve problems and ensure smooth operation. In this article, we look at the top 10 Linux performance commands for system administrators and provide an overview of each command’s functionality and uses.

As a system administrator over the years, I’ve compiled a list of my top 10 Linux performance commands that I use daily. I’ll share my favorites in this blog post and explain why they’re essential. So, without further ado, let’s dive in!

top

 

The “above” command is my absolute favorite, and I’m sure many of you will agree. It provides a live and dynamic view of system processes, memory usage, and CPU load. Frankly, I love the simplicity and ease of identifying resource-hungry processes.

Although some people prefer “htop” because of its color display and extra features, I’m a big fan of the classic “top” command.

iostat

 

10 Linux Performance Commands Continued I have always considered disk performance to be an important aspect of system performance. This is where iostat comes in. It’s great for monitoring disk I/O and helps me identify potential bottlenecks.

The ‘iostat’ command is part of the ‘sysstat’ package, which is not always pre-installed on Linux distributions. Here’s how to install sysstat on some popular Linux distributions:

Debian and Ubuntu:

To install sysstat on Debian and Ubuntu, open a terminal and run the following command:

sudo apt-get install sysstat

Red Hat, CentOS and Fedora:

To install sysstat on Red Hat-based systems, open a terminal and run the following command:

sudo yum install system

Arch Linux:

To install sysstat on Arch Linux, open a terminal and run the following command:

sudo pacman -S sysstat

SUSE and openSUSE:

To install sysstat on SUSE and openSUSE, open a terminal and run the following command:

sudo zypper install system

After installing sysstat, you can use the iostat command to monitor disk I/O statistics. Remember to use ‘sudo’ or switch to root user if you need higher privileges to run the command. However, I wish the default output was a bit more user-friendly. But hey, it gets the job done, and that’s what counts.

Use the following command to display disk I/O statistics for all devices every 5 seconds. It helps you monitor disk performance and identify bottlenecks.

vmstat

 

 

vmstat” is another command that I rely heavily on. It reports virtual memory statistics, which help me understand how the system uses memory and swap space. I find it especially useful when dealing with memory intensive applications.

The only thing I’m not a fan of is the somewhat cryptic output. But once you get the hang of it, it’s a powerful tool. Use the following command to display virtual memory statistics every 3 seconds. This helps you understand how the system is using memory and swap space, which is useful when working with memory-intensive applications.

vmstat 3

 

free

 

The “free” command is great for a quick overview of system memory usage. It’s simple, easy to read, and straight to the point. I like to use it to check if my servers have enough free memory.

My only issue with “Free” is the lack of customization options, but given its purpose that’s a minor issue. To display the memory usage in a human-readable format, use the following command. It gives you an overview of total, used and available memory and swap space.

sar

 

sar’ is the swiss army knife of performance monitoring. It can provide information on almost every aspect of system performance, from CPU usage to network activity. I appreciate its versatility and the fact that it collects historical data, allowing me to analyze trends and identify past issues.

On the downside, the sheer number of options can be overwhelming. It’s a powerful tool, but it takes patience to master. To display the average CPU usage for the current day, use the following command. It helps you analyze CPU usage trends and identify past problems by collecting historical data.

Sar is also part of the system package. Please refer to the “iostat” section before running the next command to install systat on your Linux system.

sar-u

Are you getting this error after running the sar -u command?

Cannot open /var/log/sysstat/sa28: No such file or directory
Please check if data collection is enabled

This error message indicates that the required system activity data for “sar” is not being collected or stored. To fix this problem, we need to enable data collection and configure the sysstat package correctly.

mpstat

 

 

As a system administrator managing multi-core servers, “mpstat” is a lifesaver. It shows the usage of each processor core which helps me understand the system load distribution. I find it especially useful for tuning applications that need to be optimized for multi-core systems.

I can’t really find any fault with this – it does exactly what I need it to do! To display the CPU usage for each processor core, use the following command. This helps you understand the distribution of the system load, which is especially useful for setting up applications optimized for multi-core systems.

 

netstat

 

 

 

Network problems can be a real pain, and that’s where netstat comes in handy. This is my go-to command for monitoring network connections, routing tables, and interface statistics. I have to admit, I have a soft spot for this one – it saved me countless hours of troubleshooting.

The only downside is that it has been deprecated in favor of ‘ss’, but old habits die hard, and I still prefer using ‘netstat’.

Use the following command to display all active network connections and their status. It helps you monitor network connections and identify potential problems.

The “netstat” command is part of the “net-tools” package, which is not always preinstalled on Linux distributions. Here’s how to install net-tools on some popular Linux distributions:

Debian and Ubuntu:

To install net-tools on Debian and Ubuntu, open a terminal and run the following command:

sudo apt-get install net tools

Red Hat, CentOS and Fedora:

To install net-tools on Red Hat-based systems, open a terminal and run the following command:

sudo yum Install network tools

Arch Linux:

To install net-tools on Arch Linux, open a terminal and run the following command:

sudo pacman -S net-tools

SUSE and openSUSE:

To install net-tools on SUSE and openSUSE, open a terminal and run the following command:
Also read

sudo zypper Install network tools

After installing net-tools, you can use the netstat command to display the active network connections and their status. Remember to use ‘sudo’ or switch to root user if you need higher privileges to run the command.

netstat -tunap

 

ss

Speaking of ‘ss’, it is a worthy replacement for ‘netstat’. It is faster and more powerful and provides detailed information about sockets and network connections. I’m slowly warming up to it and I have to admit it has grown on me over time.

It’s just a matter of getting used to the new way, and once you do, ‘ss’ can be a valuable addition to your toolbox.

Use the following command to display detailed information about sockets and network connections. It is similar to netstat but faster and more powerful.

lsof

 

lsof” is an underrated gem. It stands for “Open List Movies”, but it does much more than that. This can help you track which processes are using specific files, directories, or sockets, which is very useful when debugging complex issues.

The only downside is that the output can be quite wordy and it can take a while to find the information you need. But overall, it’s a powerful command that I wouldn’t want to be without.

Use the following command to display a list of open files and the processes using them. This is useful when debugging file usage issues, such as identifying processes that have locked certain files.

strace

 

 

10 Linux Performance Commands Last but not least, strace is a lifesaver when it comes to debugging application problems. It tracks system calls and signals, allowing you to see exactly what a process is doing. The number of times this command has failed me when all other debugging methods have failed.

However, “strace” is not without flaws. It may be slow and difficult to decode the output. But when you need it, there’s no substitute for the insights it provides.

To trace the system calls and signals of a specific process, use the following command. This helps you understand what the process is doing, which can be invaluable when debugging application problems.

strace -p [PID] Replace [PID] with the process ID of the process you want to trace.

There are several ways to view the PID of a process. I suggest you use the ps command for quick output.