This article explains installing netstat
, a command line utility for troubleshooting network activity on Ubuntu Linux.
Netstat is a command-line utility for troubleshooting and monitoring network activity on Linux systems, including Ubuntu. It displays network connections, routing tables, and network interface statistics.
However, the netstat
package is not installed automatically on Ubuntu Linux. When you run the netstat
command Ubuntu, you may get an error message that reads “Command ‘netstat’ not found.”
Using the apt install netstat also won’t install the package on Ubuntu Linux. That’s because the netstat
package is included in Ubuntu’s repositories via the net-tools
packages.
You need to install the net-tools
package to get netstat installed on Ubuntu Linux. In other words, replace “sudo apt install netstat
” with “sudo apt install net-tools
” to install the netstat command in Ubuntu Linux.
Step 1: Open the Terminal
To install netstat, we need to access the Terminal. You can do this by pressing the Ctrl+Alt+T
key combination or by searching for “Terminal” in the Applications menu.
Step 2: Update the package list
Before installing any new packages, updating the package list on your Ubuntu system is recommended. This ensures that you have the latest repositories and package information.
In the Terminal, execute the following command:
sudo apt update
Enter your password when prompted, and press Enter
to proceed. This command will update the package list.
Step 3: Install the netstat package
Once the package list is updated, you can install the netstat package.
In the Terminal, enter the following command:
sudo apt install net-tools
This command will install the net-tools package, which includes netstat, onto your Ubuntu system.
Confirm the installation by typing Y
and pressing Enter
.
Step 4: Verify the Installation
To verify that netstat is installed correctly, you can run the following command:
netstat --version
If netstat is installed properly, you should see the version information in the Terminal.
Feel free to explore the options and parameters available with netstat by utilizing the man
command in the Terminal.
For example:
man netstat
This command will display the manual page for netstat, providing detailed information on how to use the utility.
Some useful netstat commands are below.
Find all listening ports
netstat -l
List listening TCP ports
netstat -lt
List listening UDP ports
netstat -lu
Monitor the network and get network statistics
netstat -c netstat -s
That should do it!
Conclusion:
- Installed the netstat command on Ubuntu Linux by installing the net-tools package
- Verified the installation by running the netstat –version command
- Explored other netstat commands such as netstat -l, netstat -lt, netstat -lu, netstat -c, and netstat -s for monitoring network activity and obtaining network statistics
Leave a Reply Cancel reply