Talk Tech to Me: 9 Common Linux Network Commands (2023)

Talk Tech to Me: 9 Common Linux Network Commands (1)

There seem to be an infinite number of commands forLinux Administratorsto remember. Some are for file manipulation, some are for managing hardware, and still others are for configuring services or databases.

Network connectivity is a critical part of Linux server functionality. Read on to learn nine commands that cover most network management needs on Linux devices. Some of these tools are built-in, while others need to be added using a package manager.

4 configuration commands

There are some basic approaches to troubleshooting or examining the configuration of network nodes. One of the first steps is to determine the current configuration, including IP address, subnet mask, and interface settings.

1. The IP command

The IP command is available by default on many Linux distributions these days. The command and its associated subcommands are very flexible and allow administrators to view and change IP address settings.

To see the IP addresses of all interfaces, type:

# IP-Adr

This command displays the current IP address and subnet mask for all interfaces on the system. Specify a specific interface using ip addr show enp0s3 as shown below:

Talk Tech to Me: 9 Common Linux Network Commands (2)

Figure 1: The IP address shows the enp0s3 command

Don't forget that theifconfigThe command will display similar information if available on your preferred distribution.

There are some variations on the IP command that you should be aware of. For example, displays route and connection information:

Talk Tech to Me: 9 Common Linux Network Commands (3)

Figure 2: The IP route command

Talk Tech to Me: 9 Common Linux Network Commands (4)

Figure 3: IP-Link shows enp0s3 command

2. The nmcli command

your favoriteLinux distributioncan handle network connections using NetworkManager. NetworkManager has Graphical User Interface (GUI) and Textual User Interface (TUI) utilities, but in this case I will focus on the Command Line Interface (CLI) tool.

Device information is displayed withnmcli connectionShow Command (abbreviated tonmcli com). The output shows the link name, user identifier (UID), device type and name.

Talk Tech to Me: 9 Common Linux Network Commands (5)

Figure 4: Or nmcli command with

(Video) grandMA2 Troubleshooting - We’ve All Been There - Tech Talks 08-08-2017

Additional device information can be displayed for each deviceshow devicessubcommand. Here is an example:

Talk Tech to Me: 9 Common Linux Network Commands (6)

Figure 5: The nmcli dev showing the enp0s3 command

It is also useful to confirm that the interface is enabled withnmcli development status.

Talk Tech to Me: 9 Common Linux Network Commands (7)

Figure 6: O command nmcli dev status

3. The dhclient command

Most Linux servers are configured with static IP addresses. But workstations and other devices are probably DHCP (Dynamic Host Configuration Protocol) clients. These devices lease an IP address configuration from a DHCP server.

Periodically, the leased information may become out of date due to recent network changes. In that case, it makes sense to start a new DHCP lease generation process.

OdhclientThe command is used to delete and then lease an IP address configuration from the DHCP server. First, use the command with no options, and then add the -r option to start the new lease.

Talk Tech to Me: 9 Common Linux Network Commands (8)

Figure 7: The dhclient and dhclient -r commands

Windows administrators are probably familiar with its use.ipconfig /releaseEipconfig /refreshto perform the same task.

4. The ethtool command

Oettoolutility activatedsystem adminto configure network interfaces. Many options are available including speed, duplex, activationLANand driver information, among other settings.

Talk Tech to Me: 9 Common Linux Network Commands (9)

Figure 8 The ethtool enp0s3 command

through queriesettool, a system administrator can discover the capabilities of a network interface card (NIC) to determine whether support for options such as remote enable features on the LAN is available. Additional information may be helpful in confirming that the switch and NIC speeds are compatible and duplexing is enabled.

5 connection utilities

Administrators can use the above commands to check the current system's network settings. What if these settings are correct? How can system administrators gather information about how these settings are used?

1. The SS Command

The ss command displays current connections to the system, replacing the venerableliquid stateUtility. It displays detailed information about socket statistics for supportProblems solutionand performance monitoring. If you need to see current connection information for your Linux server, ss is the command to use.

The ss command with no options displays existing connections with Transmission Control Protocol (TCP) sockets on the host. An unmodified ss command displays large output. Filtering this output is the key to getting useful information.

For many system administrators, the first useful option is the-4Switch showing IPv4 data. Many internal networks have not yet migrated to IPv6. In addition, the results of TCP or UDP (User Datagram Protocol) connections can be displayed using-TE-youoptions or

(Video) 5 Basic Networking commands for everyone (2023) | How to troubleshoot network issues on Windows?

Even more convenient is the output displayed based on the state of connections. A simple example is the listening sockets display:

Talk Tech to Me: 9 Common Linux Network Commands (10)

Figure 9: The ss -4 state listen command

You can also view output for specific connections by specifying the destination IP address, as shown below with the destination example:

# ss-dst

The ss utility is a powerful replacement forliquid state, but it certainly requires some dedication to learn.

2. The nmap command

Network Mapper (nmap) searches for open ports on remote systems. It is an incredibly powerful tool used for both nefarious and benevolent motives. Keep this in mind when trying to troubleshoot situations where remote connections are unknown, fail, or are rejected.

Many different types of scans are available, including whole subnet or targeted host scans.

A basic scan of the network looks like this:

Talk Tech to Me: 9 Common Linux Network Commands (11)

Figure 10: The nmap command (truncated output)

A quick scan shows active hosts on a network without showing additional information (e.g. ports):

Talk Tech to Me: 9 Common Linux Network Commands (12)

Figure 11: The nmap -sn command

the power ofnmapreally shines when performing more specific checks. One of the most common uses is to display open ports on target systems. Although a scan can show all open ports, administrators usually already know which port to check.

To confirm the statusPort 22/TCP(the default Secure Shell (SSH) port) on a server with IP address, type:

Talk Tech to Me: 9 Common Linux Network Commands (13)

Figure 12: The nmap -p 22 command

Similarly, nmap can show port 22 results for an entire subnet with:

# nmap -p 22

(Video) I Bought the Two FASTEST CPUs... but I'm Only Keeping the Winner - 13900K vs 7950X

To search the top 25 ports, add the --top-ports 25 option:

# nmap --top-ports 25

Nmapit's extremely powerful, and there are a lot more options. A general scan is useful, but system administrators can use this tool to really get into the details.

For those more comfortable with graphical tools, consider ZenMap.

3. The tcpdump utility

BothssEnmapprovide information about existing connections, but do not tell system administrators how these connections are used.

The tcpdump utility is installed on many Linux distributions. It intercepts network traffic and gives administrators an overview of what kind of information is flowing over existing connections.

One reasontcpdumpcommand looks like this:

# tcpdump -i enp0s3

The output is all traffic on the specified interface.

It's easy to specify traffic to or from a specific IP address, for example To do this, type the following:

# tcpdump-Host

However, on a server with busy network connections, a lot of information can be collected in a very short time. Try filtering coverage by the specific traffic port you need.

Here's a recording for the port 80 traffic, along with words to write the output to a file called webtraffic:

# porta tcpdump 80 -w webtraffic

The file isn't easy to read with a standard editor, but you can use it.tcpdump -r webtrafficor open the file withWiresharkto make the content more user-friendly.

Of course, Wireshark offers similar functionality and has a very nice GUI.

4. The mtr command

While tools likePing e Tracerouteare invaluable for network troubleshooters whomtrCommand can be even more effective. It includes the functionality of standard tools and provides visibility into network performance information, including dropped packets along a route. It updates this information automatically, giving system administrators real-time information about network performance.

A basic test looks like this:

Talk Tech to Me: 9 Common Linux Network Commands (14)

Figure 13: The mtr command

(Video) Linux HATES Me – Daily Driver Challenge Pt.1

In this case I also targeted localhostmtrto view available baselines.

The mtr command also works by simply specifying an IP address instead of a fully qualified domain name (FQDN) or hostname.

If the output is too disorganized, try the-cOption to display results in a wide format. I usually walkmtras-4Option to return only IPv4 information.

The output includes the percentage of packets lost, the number of packets sent, and various fields related to network performance. As results are displayed for each hop, administrators can identify where communication is failing or which routers may be experiencing performance issues.

you can installmtron Linux, macOS and Windows. In fact, Windows administrators may already be familiar with a similar tool called Pathping.

5. The iperf command

The mtr command can certainly provide valuable information about a network route, but what about the available bandwidth being used by a specific server? there is theiperfutility is coming.

There are two basic ways to use it.iperf, either directed to a server owned by an Internet hosting organization or directed to one of your internal servers.

To useiperfinternally dedicating two systems. One acts as the destination server while the other is the client. To installiperfin both systems.

To set the target device as the target server, use the-SPossibility:

# iperf -s

A default port number is displayed. The client uses this connection to test performance.

Then switch to the client device. O -Ccauses the device to run iperf in client mode. Provide at least the IP address of the destination server.

The command looks like this on the client, assuming the server's IP address is

# iperf -c

The output provides system administrators with information about the server's available bandwidth. However, testing a single server connection is not necessarily realistic. Most servers must support many simultaneous connections. gladly,iperfcan help with that.

Use o-POption to specify the number of parallel connections to the destination, which gives much more information about how the server's actual network performance is.

# iperf -P 30 -c

Use iperf on Linux servers, of course, but note that there are versions for Windows, macOS, and even Android and iOS (iPhone). Consider network testing possibilities with this variety.

Understand basic networking commands

Linux server administrators are often responsible for critical services including web and database functions. These services depend on network connectivity and it is up to system administrators to know many different basic network commands for configuration and troubleshooting. The nine commands listed here represent a solid list of utilities that play an important role in maintaining network connectivity.

CompTIA Linux+ covers the skills needed to be a Linux administrator and use commands like the ones in this article. CompTIA CertMaster Learn + Labs for Linux+ allow you to learn and practice your hands-on skills on one platform.Sign up for your free trial today.

(Video) Linux Fundamentals - Useful Networking Commands


How to check NIC issues in Linux? ›

How to troubleshoot network connectivity with Linux server
  1. Check your network configuration. ...
  2. Check the network configuration file. ...
  3. Check the servers DNS records. ...
  4. Test the connection both ways. ...
  5. Find out where the connection fails. ...
  6. Firewall settings. ...
  7. Host status information.
May 17, 2022

How do I see all networks in Linux? ›

How To: Linux Show List Of Network Cards
  1. lspci command : List all PCI devices.
  2. lshw command : Linux identify Ethernet interfaces and NIC hardware.
  3. dmidecode command : List all hardware data from BIOS.
  4. ifconfig command : Outdated network config utility.
  5. ip command : Recommended new network config utility.
Jul 19, 2022

What are 5 Linux commands? ›

Top 50 Linux Commands You Must Know as a Regular User
  • ls - The most frequently used command in Linux to list directories.
  • pwd - Print working directory command in Linux.
  • cd - Linux command to navigate through directories.
  • mkdir - Command used to create directories in Linux.
  • mv - Move or rename files in Linux.
Aug 3, 2022

How many Linux commands are there? ›

There are well over 100 Unix commands shared by the Linux kernel and other Unix-like operating systems.

How to check Ethernet status in Linux? ›

Run the following cat command:
  1. $ cat /sys/class/net/eno1/carrier. $ cat /sys/class/net/eno1/operstate. Another option is use the ip command along with grep command/egrep command:
  2. $ ip a s eno1 | grep state.
  3. $ sudo ethtool eno1 | grep -i 'Link det'
  4. $ nmcli device status.
Oct 15, 2022

How do I find my hidden nic? ›

Method 6: Check for nonpresent, ghosted, or hidden network adapters
  1. Click Start, click Run, type cmd.exe, and then press ENTER.
  2. Type set devmgr_show_nonpresent_devices=1 , and then press ENTER.
  3. Type Start DEVMGMT. ...
  4. Click View, and then click Show Hidden Devices.
  5. Expand the Network adapters tree.
Sep 23, 2021

How do I debug a network connection? ›

Approaches to debug network connectivity
  1. Use the Ping Remote tool to determine whether the network can reach a remote target. ...
  2. Use the traceroute command to trace the network path to a remote target.
  3. Use the TCP Connection Test tool to verify connectivity to a specific port on a remote target.

How do I find all IP addresses on a network Linux? ›

How to Find All IP Addresses on a Network
  1. Open the command prompt.
  2. Enter the command “ipconfig” for Mac or “ifconfig” on Linux. ...
  3. Next, input the command “arp -a”. ...
  4. Optional: Input the command “ping -t”.
Jan 4, 2023

How do I see all network connections? ›

To display all active connections:
  1. Open a command prompt.
  2. Type netstat -a.
  3. Press Enter.
  4. Observe active TCP and UDP connections and listening ports, the local address and port number, the remote name or address and port number if a connection is established, and the connection status.
May 22, 2016

How to check IP address in Linux? ›

If you enter the command “ifconfig” in the terminal, all information will be displayed. You can also use the commands “ip addr” or “ip a”. Confirm with [Enter]. You'll now be shown all IP addresses that are in your network.

What are networking commands? ›

As we learned, networking commands are used at the command prompt to get network information like the IP address of the system (remember that an IP address is the address of your device in a network), MAC address, network route traversed by a packet, and the IP address of the server in which a website or URL is hosted.

What is the command for network connections? ›

Press Win + R to open the Run command dialog box. Type ncpa. cpl and press Enter to open the Network Connections tool.

How do I list network services in Linux? ›

Check running services on Linux
  1. Check the service status. A service can have any of the following statuses: ...
  2. Start the service. If a service isn't running, you can use the service command to start it. ...
  3. Use netstat to find port conflicts. ...
  4. Check xinetd status. ...
  5. Check logs. ...
  6. Next steps.
Dec 20, 2019

What are network utility commands? ›

from the command line. A summary of the most useful commands are here: /all is used to display more in depth details about the TCP/IP and DHCP lease settings. /release is used to clear the current IP address settings. /renew is used to obtain new IP address settings after using the /release command.


1. How to use the traceroute command: 2-Minute Linux Tips
(IDG TECHtalk)
2. Computer Networking Course - Network Engineering [CompTIA Network+ Exam Prep]
3. Network Troubleshooting using PING, TRACERT, IPCONFIG, NSLOOKUP COMMANDS
4. Break WiFi networks using Cloud GPUs in seconds
(David Bombal)
5. ChatGPT Tutorial: 5 Mind-Blowing Ways To Use This AI (Jasper Killer?!)
(Digital Creator Avi)
6. CompTIA A+ Full Course - FREE - [31+ Hours]
(Paul Browning)


Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated: 09/13/2023

Views: 6021

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.