Getty Images/iStockphoto

Tip

5 basic network commands for Linux and Windows

Linux and Windows use different network commands to run tasks that are common in both environments, such as network connectivity testing. But the commands often share similarities.

Nowadays, administrators work with more diverse platforms than ever. From Windows workstations to Linux servers to macOS laptops, they encounter a dizzying number of environments. Cloud computing and containers take this complexity to another level. It's tough enough for admins to recall all the shell commands for their platform of choice, let alone those needed for another OS. Add in cloud services, and the task gets even more difficult.

This article presents a list of common commands to manage network services, organized by task rather than by platform. It first identifies the task and then shows the standard Linux and Windows commands to manage the service or utility. The goal is to provide a cross-platform reference that helps all administrators.

First, I show commands that identify the system, followed by Dynamic Host Configuration Protocol (DHCP) lease management commands. Next, I display network connections and test name resolution. Finally, I cover the commands to test network connectivity. Admins can use these commands on their physical and virtual networks to verify the proper configuration and troubleshoot connectivity issues.

1. Identify the system

One of the most fundamental commands for identifying the local system is the hostname command. This command works on both Linux and Windows systems. It may not be exciting, but at least it's consistent.

Another common task is displaying the system's IP address. Linux has changed in the last few years, moving away from the ifconfig command to the ip command -- more specifically, ip addr. At the traditional Windows command prompt, ipconfig displays the system's basic IP address information, though admins can also use the Get-NetIPAddress cmdlet in a PowerShell window.

Linux commands:

hostname
ip addr

Legacy Linux command:

ifconfig

Windows commands:

hostname
ipconfig
Get-NetIPAddress

2. Manage DHCP clients

Admins often need more information about how a system acquired an IP address configuration. Most workstations lease an IP address from a DHCP server. Sometimes, it's necessary to get a fresh configuration. Linux administrators usually accomplish this with the dhclient command, while their Windows counterparts use ipconfig with the /release and /renew switches.

Linux commands:

Release the current configuration

dhclient -r

Acquire a new lease

dhclient

Windows commands:

Release the current configuration

ipconfig /release

Acquire a new lease

ipconfig /renew

3. Display current network connections

Both platforms recognize the netstat command to display current connections to the system. Many Linux administrators prefer using the ss command, but that's a personal preference. Plenty of options exist to narrow the output down to just the information admins need. To display these options in Linux, use --help or the manual page. In Windows, try the /? switch.

Linux and Windows command:

netstat

Linux command:

ss

4. Test name resolution

Name resolution is one of the most critical services on the network. Name resolution relates easy-to-remember hostnames to difficult-to-remember IP addresses. The DNS service hosts a dynamic database of resource records that track names and IP addresses.

No matter which platform admins prefer, they should recognize that all network nodes share common configuration requirements and troubleshooting needs.

When clients cannot reach DNS servers, they may not be able to check email, access data stored on remote file servers, print or reach required webpages. Troubleshooting name resolution is a common task.

Interestingly, Linux and Windows systems share one of the key utilities: nslookup. Originally a Linux tool, nslookup is included with Windows. It enables administrators to create manual DNS queries as part of troubleshooting. Linux also relies on two other commands, dig and host, to troubleshoot DNS. Windows administrators can use the Resolve-DnsName PowerShell cmdlet to accomplish the same thing.

Linux commands:

nslookup {remote-system}
dig {remote-system}
host {remote-system}

Windows commands:

nslookup {remote-system}
Resolve-DnsName -Name {remote-system}

5. Test network connectivity

Another common task is testing connectivity and verifying the path traffic takes across the network. The traditional tool for this is ping. Both Linux and Windows recognize the ping command, though Linux sends continuous pings by default, while Windows only sends four, unless told otherwise.

Both platforms also share the traceroute utility, though Windows spells the command tracert. This tool displays the routers, or hops, packets go through while traversing the network. This information enables administrators to see where the packets are going and identify potential network performance problems, saturation or outages. PowerShell can do the same by using the Test-NetConnection -Computername server01 -TraceRoute cmdlet.

Linux commands:

ping {destination}
traceroute {destination}

Windows commands:

ping {destination}
tracert {destination}
Test-NetConnection -Computername {destination} -TraceRoute

Wrap-up

No matter which platform admins prefer, they should recognize that all network nodes share common configuration requirements and troubleshooting needs. Windows networking has its roots in old Unix implementations of TCP/IP, and therefore, many commands are shared or at least similar. In fact, macOS also shares many of the Linux commands listed above.

Whether admins are connecting to a remote Linux server in the cloud from their Windows admin workstation or using Secure Socket Shell from their Linux laptop to hit an on-premises Windows server, they'll discover many commands that gather network information are similar. Admins can learn these commands to increase their diversity and flexibility as an administrator.

Next Steps

8 things to know when switching from Windows to Linux

83 useful Linux commands

This was last published in April 2022

Dig Deeper on Network management and monitoring

SearchUnifiedCommunications
SearchMobileComputing
SearchDataCenter
SearchITChannel
Close