Networking Commands in Linux

networking commands

Networking in Linux is one of the main task for the system administrator as well as for the general users. There are so many networking commands in Linux and we will do all the important networking commands that helps in running the server.

I will try to make it short and well to make our audiences understand the role of networking in Linux. We will be using root user as we are using till now. Also, All the commands are case-sensitive in Linux so please take care of it always. If you do not know the basic commands to use linux then please refer to this link.

Let’s Begin with our networking commands.

  1. ifconfig

ifconfig is the one of the most important command used in networking part of the Linux. It helps in grabbing the basic information of Network of our server like name of the network card, IP Address etc.

Format of the ifconfig command is just ifconfig.

Examples: ifconfig

2. ping

ping command is used to check the network connectivity. It helps in inspecting the network connection between two nodes.

Format of the ping command is ping (node name or address)

Examples: ping 8.8.8.8, ping www.rootlearning.in etc.

It is an infinite loop, To close the ping command we have to press Ctrl+C key.

3. netstat

netstat helps in showing the information of network connections, routing tables, interface statistics, masquerade connections and multicast memberships.

Format of the netstat command is netstat but we generally use it with -tnlp option.

Examples: netstat -tnlp, netstat -tunlp etc.

4. ss

ss command works same as the netstat command as it is the advanced version of netstat. ss stands for Socket Stat. It works more faster than netstat with more information.

Format of the ss command is ss but we generally use it with -tnlp option.

Examples: ss -tnlp, ss -tunlp etc.

5. hostname

hostname is the name of your server that identifies the machine. You can change your hostname of your choice from the default hostname.

Format of the hostname command is hostname

Examples: hostname, hostname -i, hostname -f etc.

We can change the hostname by “hostnamectl set-hostname (new-hostname)” command.

6. curl

curl is a command line tool used for transferring data to or from the server using various protocols like FTP, HTTP, HTTPS etc.

Format of curl command is curl (URL)

Examples: curl https://rootlearning.in

7. ssh

ssh stands for Secure Shell that is used for connecting the servers remotely and manage them over a network. It is the most common networking command that can be used daily.

Format of ssh command is ssh username@IP address

Example: ssh root@5.255.121.42

We have type yes if it will ask and then enter the password of our remote server.

8. wget

wget is a command used for downloading the files from the web. It is one of the most useful command to download the softwares for our servers.

Format of wget command is wget (url of the file)

Examples: wget https://squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsquirrelmail%2Fsquirrelmail-webmail-1.4.22.tar.gz

9. scp

scp is a command to transfer the files between servers securely with the help of ssh protocol. It is also called as advance version of cp command.

Format of scp is scp (/localpath-of-file) username@IP address: (/path-of-server-file)

Example: scp /root/file1 root@5.255.121.42: /home

We have to enter the password of the server to get the file in our server.

10. dig

dig stands for Domain Information Groper that helps in querying DNS to gather information about Domain names, IP addresses and DNS records.

Format of dig command is dig (domain name)

Example: dig achra.in

That’s all about Networking Commands in Linux. Let’s do FAQ on networking commands.

Q. What command can I use to check my IP address?

A. Use ifconfig for checking IP address.

Q. How do I view the current network connections?

A. You can use netstat, ss, or lsof command
For Example: netstat -tuln or ss -tuln

Q. How can I test connectivity to another host?

A. We can use ping command for testing the connectivity.

Q. What command can I use to perform a DNS lookup?

A. We can use dig or nslookup for DNS lookup.

Q. What command can I use to find the public IP address?

A. Use curl with an external service:
curl ifconfig.me


Discover more from Root Learning

Subscribe to get the latest posts sent to your email.

One thought on “Networking Commands in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *