Computer Data NetworkIt could be argued that configuration and management run hand in hand, and should not be separated.

I do not disagree. It is not an easy matter to draw a line between the two, especially in the case of network commands that can be used to test whether or not the configurations were successful.

The fact of the matter is very simply that I ran out of time — and energy! — to cover all of the most common networking commands in a single post.

So I separated them, leaving you to mix them all back up and be used as needed. It’s like baking. Except it’s so much better, because you won’t have to wash dishes afterward!

The ping Command

The ping command “sends an ICMP ECHO_REQUEST to network hosts”, meaning that it uses the ICMP protocol to send a packet to the destination host and get a response.

A ping (and its response, or lack thereof) will tell you whether or not a destination is reachable, making it a valuable diagnostic tool.

Example: ping slashdot.org

If your ping keeping going, and going, and you want to stop it, use the Ctrl + C keyboard shortcut.

Alternatively, use the -c option, with a number that specifies how many pings to send/receive before stopping.

Example: ping -c 15 slashdot.org

Use the -q option to display the statistical summary of the ping data, skipping the display of each individual ping.

This is also a good way to find out the IP of a domain name, as it is shown each time the ping command is run.

Example: ping -c 1 -q slashdot.org

Use the -i option with a number, to change the time interval between packets/pings. The number will determine how many seconds to wait. The default is 1.

Example: ping -i 5 slashdot.org

To check if the local host is up and running, use ping 0, ping localhost, or the IP (usually ping 127.0.0.1).

The traceroute Command

The traceroute command “prints the route packets trace to network host”. Uh…

Simply put, you will get a printed (on the screen, not on paper, come on!) report of the IP addresses encountered along the route to the destination. This data enables you to trace the route taken.

This is useful not only to satisfy curiosity about how many stops are made and what locations those stops are made in along the way, but also because it can help to diagnose at which point(s) along the route there are problem(s). Each IP is returned with three “times” that indicate how long it took each of three packets to reach that point and be returned. If the “time” at one point is longer than the others, and/or a point is shown as asterisks (*) instead of readable data, then this could indicate problems along the path.

It is a good way to be able to determine if a server is slow, or if some point along the route that you are using to get to the server is slow — among other things.

Example: traceroute slashdot.org

The mtr Command

The mtr command is “a network diagnostic tool that combines the functionality of traceroute and ping.”

This command will show you real-time ping responses for all of the destinations along your route, neatly formatted.

Example: mtr slashdot.org

The tracepath Command

The tracepath command traces a path to a network host, discovering MTU along this path. Whatever that means!

The explanation that I prefer, is that tracepath is similar to traceroute, but with less options.

Tracepath does not require super-user privileges.

The whois Command

The whois command is “a client for the whois service”, meaning that it can look up registration details for an IP address or a domain name, directly from the command line.

Example: whois slashdot.org

The dig Command

The dig command is a DNS lookup utility that stands for Domain Information Groper.

It is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried.

Example: dig slashdot.org

The host Command

The host command is also a DNS lookup utility, with less functionality than dig.

It is normally used to convert names to IP addresses and vice versa.

Examples: host slashdot.org and host 216.34.181.45

The hostname Command

The hostname command is used to show or set the system’s host name.

On its own, the command will display the system’s host name: hostname

Use the –all-ip-addresses option to display the system’s IP address: hostname --all-ip-addresses

Use the -d option to display a system’s domain name.

Use the -s option to display only a system’s short name.

To set a new or unique host name, view man hostname.

The tcpdump Command

The tcpdump command is described as a tool to “dump traffic on a network”, but what it actually does is it analyzes packets on a network interface and describes their contents.

Using the command all on its own will cause it to capture all packets flowing through all interfaces. Use the -i option to specify a specific interface: tcpdump -i enp3s0

Use the -c option to specify how many packets to capture before terminating. If not specified, the command will run until terminated with the Ctrl + C keyboard shortcut.

The -tttt option will add a readable timestamp to the output.

Visit the man tcpdump manual entry for additional options.

The nslookup Command

The nslookup command queries internet name servers interactively.

If you type in the command on its own you will enter interactive mode, enabling you to type in multiple queries, one at a time. Use the Ctrl + C keyboard shortcut to break out of interactive mode.

Typing in the command with a domain or IP address as the argument will not enter interactive mode, but will show the results for that single query.

Other records are available also, using nslookup. Check the manual page for details.

Conclusion

This concludes our series on Linux networking commands. Upcoming, are additional commands related to remote system administration — since that happens over a network, they’re still network-related, right?

Stay tuned!