Top 15 Linux Networking tools that you should know!

Top 15 Linux Networking tools that you should know!

Written by Server Enthusiast on Mar 1st, 2021 Views Report Post

Introduction

Linux is one of the most widely used operating systems out there. The Linux Kernel is also the larges open source project. As a developer, it is more likely than not that you would have to work in one way or another with a Linux based system.

As a person who works in any IT related job, the following Linux networking commands could help you with your day to day tasks in order to analyze, maintain and troubleshoot different problems with your servers, network infrastructure, and even your domain names.

Top 15 Linux Networking tools

Here is a list of my personal top 15 Linux networking tools with examples!

ping

The ping command, might be one of the most frequently used commands by sysadmins, it uses ICMP packages to check if two machines are connected.

Syntax:

ping 191.168.1.100

You could also ping a domain name in order to find out what IP it resolves to:

ping devdojo.com

traceroute

The traceroute command shows you the path from your current machine to your remote server/system and each hope along the way.

Syntax:

traceroute devdojo.com

The output of the above command would look like this:

 1  164.122.64.253 (164.122.64.253)  1.081 ms  1.064 ms  1.056 ms
 2  168.197.249.56 (168.197.249.56)  1.382 ms 168.197.249.60 (168.197.249.60)  11.573 ms 136.197.249.54 (136.197.249.54)  1.054 ms
 3  168.197.250.149 (168.197.250.149)  0.981 ms 168.197.250.137 (168.197.250.137)  0.995 ms  0.980 ms
 4  de-cix-frankfurt.as13335.net (80.81.194.180)  2.513 ms  2.509 ms  2.501 ms
 5  104.26.11.219 (104.26.11.219)  1.331 ms  1.369 ms  1.359 ms

Essentially it is similar to ping but it shows you each step from your server to your remote host.

By using traceroute you will be able to tell if the connection from one machine to another is failing and where exactly the connection is lost.

mtr

The mtr command, is kind of a combination between traceroute and ping, it is used to check if there is any packet lost in your network.

Syntax:

mtr devdojo.com

curl

The curl command is probably my personal favorite! You can use it to make HTTP requests.

Syntax:

curl https://devdojo.com

There are many useful arguments that you could use, for example, if you add the -IL arguments you would get the headers of your domain:

curl -IL https://devdojo.com

You can also use curl to download files:

curl http://some.url/your_file.zip --output your_file.zip

wget

The wget command is quite similar to curl but has fewer options

I often use it to just download a file:

wget http://yourdomain.com/some_file.txt

dig

The dig command is a great tool for troubleshooting different DNS problems. It is used for DNS lookups, for example, if you wanted to know the A record fo your domain name you would have to run the following command:

dig a yourdomain.com

And in case you are not receiving emails, the first thing that you would check is if your MX record is correct:

dig mx yourdomain.com

whois

The whois command is used to get the information related to a domain name.

Syntax:

whois devdojo.com

As a response, you would get useful information like when the domain was registered, the expiration date, the current nameservers, and the registrar information.

ssh

SSH stands for secure shell and runs on port 22. It is a secure way of connecting to a remote server.

Syntax:

ssh your_user@yourdomain.com

In case that your SSH service is listening on a different port, you can use the -P argument to specify a custom port.

scp and rsync

I'm putting scp and rsync commands as one, as they have quite similar functions. Both commands are used to securely copy files from one server to another over SSH.

Syntax:

  • To copy a file from one server to another using scp you would need to use the following syntax:
scp yourfile.txt root@your_server.com:/home/your_user/

The above command would copy the yourfile.txt from your machine to your remote server.

  • To do the same thing with rsync you would use the following command:
 rsync -avz [email protected]:/home/user/dir/

Some of the benefits of the rsync command are that it makes the operation a lot faster, and also if the transfer fails for whatever reason, you could restore the process.

The scp command on the other side, does a linear copy, but one of the benefits over rsync is that you could copy files with scp from one remote system to another remote system without first downloading them to your local machine.

ifconfig

The ifconfig command is used to inspect the current network configuration on your server. It can show you information like:

  • Your IP address
  • Your MAC address
  • All other interfaces attached to your current machine

I'm a big fan of the ifconfig command as I really like the output and I'm used to it, but you need to keep in mind that the ifconfig command is now deprecated and you should be using the ip command instead.

ip

The ip command is quite similar to the ifconfig command and can be considered as the newer version.

Syntax:

ip addr

Or use the following for short:

ip a

Similar to ifconfig the ip a command gives you information for all of the available interfaces.

telnet

Before there was SSH, telnet was the go-to protocol for connecting from one server to another.

However as telnet is insecure, nobody nowadays should use telnet for connections.

However, you might still use the telnet client to test the connectivity from your local machine to a remote server on a specific port.

For example, if you wanted to check if port 80 on a remote server is open, you could run the following command:

telnet devdojo.com 80

nc

The nc command, or netcat is used to read from and write to network connections using TCP or UDP.

As an example, you could start listening on a port with the following command:

nc -l 1234

The above command would start listening on port 1234 and if you open a second terminal and use telnet to connect on that port, then start typing, you will be able to see the input from your second terminal directly on your first terminal that you've started the nc command on. You should give this a try, it's pretty cool!

nmap

The nmap command is an open-source tool, used for scanning networks.

The command is used to discover other hosts on a specific network by sending packets and then analyzing the response. For example, you could use nmap to run a port scan on a specific host and find out what ports are being used:

nmap devdojo.com

netstat/ss

As a system administrator, I use the netstat command super often! It shows you the network statistics on your machine, for example, if you wanted to see all of the connections port 80, you could just run the following command:

netstat -plant | grep 80

You could also use netstat to see what services are running and listening on your machine as well.

netstat -plant | grep LISTEN

As much as I love the netstat command it is now being replaced with the ss command. It is faster and provides more information.

Syntax:

ss -lt

Conclusion

Learning the above commands will make your life a lot easier in case you are facing any issues with your website or server.

Of course, there are a lot more commands out there but those are my top 15, I encourage you to go out there and explore the power of Linux! It is just amazing, it can be used as a desktop, web server, and even a firewall!

Comments (0)