Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
ip command
Listing the IP addresses
ifconfig Command 
Traceroute Command 
nslookup Command
ping command 
Frequently Asked Questions
What is the advantage of using commands?
What is the sudo command?
How to use the Traceroute command in Linux? 
Last Updated: Mar 27, 2024

Linux - Networking

Author Neha Chauhan
0 upvote
Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM


Along with windows, iOS and macOS, Linux is also an operating system. An operating system manages the communication between the hardware and software. Linux is open-source, free of cost and highly secure. 

A network is a spider web-like structure that connects digital devices to each other. Linux provides a list of commands that can be used to configure, troubleshoot and manage these networks. 

Linux Networking Commands

In this article, we will discuss the commonly used Linux networking commands. 

ip command

This command is used to manipulate and configure network interfaces. 

➡️ Usage

Use it to view all the active network interfaces. Use it to assign and unassign a network’s IP address. You can also start and stop the network using this command. 

➡️ Syntax

ip a <option> 


ip addr <option>




Listing the IP addresses

You can use address show or addr show or addr or a as command line option along with the ip command to display the list of all the active IP addresses in the network. 

To display the ipv4 and ipv6 addresses add -4 and -6 to the command respectively. 


ip address show

ip addr show

ip addr

ip a

For ipv4

ip -4 addr

For ipv6 

ip -6 addr


Adding an IP address 

Use the ip addr add command along with the <ip address> and the name of the <interface>. 


ip addr add <ip number> dev <interface name> 

Deleting an IP address



Use the del option along with the ip command to delete the IP address. Mention the ip address and the interface to which it belongs.  ip addr del <ip number> dev <interface name> 

Start and stop an interface



Use the up argument to start the network interface and down argument to stop the network interface. 


ip link set wlp6s0 up


ip link set wlp6s0 down

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job

ifconfig Command 

It is used to initialize and configure network interfaces. This command was later replaced by the ip command.

➡️ Usage

Start and stop the network interfaces. 

Use it to add an IP address. 

Use it to delete an IP address. 

➡️ Syntax

ifconfig [...OPTIONS] [INTERFACE]




List all active networks

All the network routes that are active will be listed. ifconfig 

List all networks

All the networks whether active or inactive are listed. ifconfig -a

Assign an IP address 

Mention an IP address that should be given to the network interface.  ifconfig eth0 <ip address> netmask <mask>

To start a network

Use it to activate the network. ifconfig up eth0

To stop a network

Use it to deactivate the network. ifconfig down eth0

Note: It is an obsolete command. It has been replaced by the ip command. 

Traceroute Command 

This command can be used to display how the packets are transferred from the local host to another network. It shows the hops and the path taken by the packets to reach from the local host to another network system. 

It is a troubleshooting command. 

➡️ Usage

This command will display the path taken by the packets to travel from the local host to another network server. 

➡️ Syntax

traceroute<server name or server ip address> 


➡️ Install traceroute

In order to use this functionality you will need to install it manually. 

Run the following command to install the traceroute functionality:

On Ubuntu & Debian Systems:

sudo apt-get install traceroute


Or on CentOS:  

yum install traceroute -y 



Command syntax


Use this command to display the hops and the path taken by the packets. traceroute <server name> or <server IP address> 

Trace using Ipv6 

Use Ipv6 protocol to trace the path of the packet. traceroute -6 <server name> or <server IP address> 

Trace using Ipv4

Use Ipv4 protocol to trace the path of the packet. traceroute -4 <server name> or <server IP address> 

Set number of queries per hop

Mention the number of hops a packet should make per query. traceroute -q <number of hops to make> <server name or IP address>

Interface to use 

Use the ‘i’ option to specify the interface to be used. If it is not set, it will use the interface according to the route table.  traceroute -i wlp3s0b1<server name or IP address> 

Maximum hops 

Use -m option to set the maximum number of hops. By default this value is set to 30.  traceroute -m <integer value indicating max number of hops> <server name or IP address> 

Getting help

A list of all the list options and their usage will appear. 

Press ‘q’ to quit. 

traceroute --help

nslookup Command

This command is used to obtain DNS related queries.

➡️ Usage

It can be used to obtain the domain name and the Ip address, along with some other information related to the DNS records.

➡️ Syntax

nslookup <domainName> 

Information Type


Command syntax

Domain information

Use the nslookup command to obtain the information of the domain. nslookup <domainName>

Ns records 

Use type=ns to display the NS records of the domain. nslookup -type=ns <domainName> 

MX records

Use the query=mx to find the MX records responsible for email exchanges. nslookup -query=mx <domainName>

All records

Use type=any to view all the DNS records nslookup -type=any <domainName>

ping command 

The receipt of corresponding Echo Reply messages is displayed, along with round-trip times. Ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution.

Stop ping by pressing CTRL+C. After every ping command, a summary report is displayed. It contains the following information :

Min - Minimum time that it takes to get a response from the host that has been pinged from your end.

Avg - Average time that it takes to get a response from the host that has been pinged from your end.

Max - Maximum time that it takes to get a response from the host that has been pinged from your end.

Frequently Asked Questions

What is the advantage of using commands?

Commands make use of Linux fast. Many operations not available in GUI versions can be performed using commands only. Commands give a powerful way to handle Linux systems.

What is the sudo command?

It is one of the essential commands. It gives the user superuser/root privileges. Be careful while using this command, as you can access critical sections of the server using this command.  

How to use the Traceroute command in Linux? 

You can install the Traceroute by running this command - sudo apt-get install traceroute. You can use this command after the installation is over. 


Congratulations on finishing this article. In this article, we discussed some commonly used networking commands in linux. We discussed their usage, syntax and common examples. 

Do not stop learning! We recommend you to read some of our articles - 

🔥 Introduction to Linux

🔥 Linux Kernel

🔥 Linux Directories

Head to the Guided Path on the Coding Ninjas Studio and upskill in Data Structures and AlgorithmsCompetitive ProgrammingSystem Design, and many more courses.

If you want to Practice top Coding Problems, attempt mock tests, or read interview experiences, head to the Coding Ninjas Studio, our practice platform.

We wish you Good Luck!🎈 Please upvote our blog 🏆 and help other ninjas grow.

Live masterclass