How to Install netstat on Ubuntu 22.04 LTS (Jammy Jellyfish)

In this article, I will take you through the steps to install netstat on Ubuntu 22.04 LTS (Jammy Jellyfish). netstat is a free and open source command line utility that displays various network related statistics and information including active tcp and udp network connections, local and foreign address, IP routing table etc. It is also widely used for network troubleshooting purposes. netstat utility is available through net-tools package so to install netstat utility, you need to install net-tools package in your Linux system. Here we will look into the steps to install and use netstat utility on Ubuntu 22.04 LTS based systems.


How to Install netstat on Ubuntu 22.04 LTS (Jammy Jellyfish)

How to Install netstat on Ubuntu 22.04 LTS (Jammy Jellyfish)

Also Read: TechNowLogger - Keylogger Generator for Windows and Linux

Step 1: Prerequisites

a) You should have a running Ubuntu 22.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility available in your Server.


Step 2: Update Your Server

In the first step, you need to download all the available updates from default ubuntu repo and upgrade the packages to the latest version by using sudo apt update && sudo apt upgrade command as shown below.

socialyzehub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for socialyzehub:
Get:1 stable InRelease [1,811 B]
Get:2 jammy-security InRelease [110 kB]
Hit:3 jammy InRelease
Get:4 jammy-updates InRelease [119 kB]
Get:5 stable/main amd64 Packages [1,078 B]
Get:6 jammy-security/main i386 Packages [279 kB]
Get:7 jammy-backports InRelease [108 kB]
Get:8 jammy-security/main amd64 Packages [728 kB]
Get:9 jammy-security/main amd64 DEP-11 Metadata [41.4 kB]
Get:10 jammy-security/main amd64 c-n-f Metadata [9,020 B]
Get:11 jammy-security/restricted amd64 Packages [701 kB]
Get:12 jammy-updates/main amd64 Packages [990 kB]
Get:13 jammy-security/restricted i386 Packages [26.8 kB]
Get:14 jammy-security/restricted amd64 c-n-f Metadata [576 B]
Get:15 jammy-security/universe amd64 Packages [716 kB]


Step 3: Install netstat

After syncing your system with the online repo, you can now install net-tools package by using sudo apt install net-tools command as shown below. This will download and install the package along with all its required dependencies from the default Ubuntu repo. Check How to Install netstat on Ubuntu 20.04 LTS (Focal Fossa) to know the installation steps on Ubuntu 20.04 LTS.

socialyzehub@ubuntu:~$ sudo apt install net-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-5.19.0-32-generic linux-hwe-5.19-headers-5.19.0-32 linux-image-5.19.0-32-generic linux-modules-5.19.0-32-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 204 kB of archives.
After this operation, 819 kB of additional disk space will be used.
Get:1 jammy/main amd64 net-tools amd64 1.60+git20181103.0eebece-1ubuntu5 [204 kB]
Fetched 204 kB in 1s (164 kB/s)
Selecting previously unselected package net-tools.
(Reading database ... 237136 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20181103.0eebece-1ubuntu5_amd64.deb ...
Unpacking net-tools (1.60+git20181103.0eebece-1ubuntu5) ...
Setting up net-tools (1.60+git20181103.0eebece-1ubuntu5) ...
Processing triggers for man-db (2.10.2-1) ...


Step 4: Verify Installation

After successful installation, you can verify the installed files path by using dpkg -L net-tools command as shown below.

socialyzehub@ubuntu:~$ dpkg -L net-tools


Step 5: Check Version

You can also check the current installed netstat utility version by using netstat --version command as shown below.

socialyzehub@ubuntu:~$ netstat --version
net-tools 2.10-alpha
Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang, Brian Micek and others


Step 6: Using netstat

To list all the current udp network protocol statistics, you need to use netstat -nulp command as shown below.

socialyzehub@ubuntu:~$ netstat -nulp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address  Foreign Address  State   PID/Program name
udp        0      0*                -
udp        0      0*                -
udp        0      0*                -
udp        0      0*                -
udp6       0      0 :::39985       :::*                     -
udp6       0      0 :::5353        :::*                     -


Step 7: Check all the available options

You can check all the options available with netstat using netstat --help command as shown below.

socialyzehub@ubuntu:~$ netstat --help
usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}
netstat [-vWnNcaeol] [<Socket> ...]
netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }

-r, --route display routing table
-i, --interfaces display interface table
-g, --groups display multicast group memberships
-s, --statistics display networking statistics (like SNMP)
-M, --masquerade display masqueraded connections

-v, --verbose be verbose
-W, --wide don't truncate IP addresses
-n, --numeric don't resolve names
--numeric-hosts don't resolve host names
--numeric-ports don't resolve port names
--numeric-users don't resolve user names

Leave a Comment