The netstat command in Linux: network statistics and connections

Introduction

In the world of Linux system administration, knowing the state of network connections is essential for diagnosing problems, optimizing performance, and ensuring security. One of the most traditional tools still widely used is the netstat command. Although it has been partially replaced by ss in modern distributions, netstat remains a valuable reference due to its wide set of options and readable output. In this article we will explore what netstat is, how to install it, its basic syntax, the most useful options, and several practical examples you can apply in your day-to-day work.

What is netstat?

Netstat (short for network statistics) is a command-line tool that displays information about network connections, routing tables, interface statistics, and more. It provides a detailed view of open sockets, both TCP and UDP, and allows filtering by state, address, port, and protocol. Its output can include the PID and name of the process occupying each connection when run with root privileges, which is very useful for identifying applications that consume bandwidth or exhibit suspicious behavior.

Installation and availability

In most Linux distributions, netstat is part of the net-tools package. On Debian/Ubuntu-based systems you can install it with:

  • sudo apt update && sudo apt install net-tools

On RHEL, CentOS, or Fedora distributions the package is likewise called net-tools and is installed with:

  • sudo yum install net-tools or sudo dnf install net-tools

This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .