How to Monitor your Linux Server Using Remote Command Line

How to Monitor your Linux Server Using Remote Command Line

What Do I Need?

  • A Dedicated or VPS Linux Server
  • Ubuntu
  • Putty

What is Remote Monitoring?

Being a Linux administrator is a largely thankless position where you’ll be responsible for a lot of hardware, software, and data. And monitoring and protecting it is far from an easy task. There are, however, a multitude of tools out there, some native to most Linux distributions, some not. Normally as an administrator, you’d be expecting to log in via a remote ssh connection to the machine or machines that require monitoring and caring for. What follows in this how-to guide is an overview of some of the best commands to be used when remote monitoring your web servers.

  1. top

Without any doubt, the top command is the number one command-line tool to monitor Linux. It’s one of the most widely used commands by Linux system administrators all over the world. It quickly provides details about all running processes in an ordered list. The list also keeps updating in real-time. Plus, not only does it show the process names, but it also displays the memory usage and CPU usage, among other details.

  1. vmstat

vmstat is the command-line utility that has the main task of displaying virtual memory statistics. It also helps you to display various information including all system processes, CPU activity, paging, block IO, kernel threads and disks, etc. vmstat is a part of default installation in almost all the Linux distribution, so it is available straight away after the installation.

  1. lsof

If you want to look at all the files currently opened in the system, then you need to make use of the lsof command. It’s also used to monitor all processes currently in use. One of the major advantages of this command is that it helps administrators to see the files currently in use when a disk cannot be unmounted. Using this command, these files can be identified easily.

  1. tcpdump

tcpdump is another command-line utility that allows Linux system administrators and network engineers to monitor all TCP/IP packets transferred over a network. Using tcpdump, one can also save all the packets in a separate file for analysis in the future. This is useful in penetration testing and detecting signs of bad actor illegal connection to your server or servers.

  1. netstat

netstat is one of the oldest command-line utilities used for network troubleshooting. Using netstat, we can easily find network connections, routing tables, Ethernet card statistics, and masquerade connections. In other words, we can say, it also helps you troubleshoot any network related issues quickly. In the latest Linux distributions, netstat isn’t part of the default installation so it has to be installed using the following command:

sudo apt install net-tools

Using the following command you can list all tcp connections to your Linux server:

netstat -tunlp

  1. htop

htop command is another feature-rich command-line utility that offers real-time monitoring of various vital resources in the Linux system. Compared to the top command, htop is a much-improvised version and even provides color-coded output for easier understanding. It also supports both horizontal and vertical viewing and also allows administrators to manage processes as well. In the latest Linux distributions, netstat is not the part of default installation so it has to be installed using the following command:

sudo apt install htop # version 2.2.0-2build1

Conclusion

There are lots more useful commands to explore so be sure to keep an eye out for more incoming how-to guides on maintaining and monitoring your Linux servers. Personally, I recommend spending some time exploring the above-outlined commands and getting used to how they can help you in various use cases. It’s always a good idea to make a note of your preferred troubleshooting routine involving these commands and others as you get more advanced.

HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top