How to get the IP Address in Linux

How to find IP Address in Linux?

It is easy in Windows, just open the command prompt and run ipconfig command. This command displays the ipv4 address, subnet mask, gateway information, and a whole lot of information. So, what is the equivalent command to check IP addresses in Linux?

Let’s find it out in this article.

What is IP Address?

An IP address is a number that identifies a computer within a network. Every day the system uses it whether you are aware of it or not.

On the other hand, there are private and public IP addresses. The private ones are those assigned to us by an internal network. An example, quite common is when we have a router in our house to connect several devices. The router will assign a private address for each of them; however, there is also the public one which is the IP address the computer uses to access the Internet. It is not recommended to disclose this IP address but we will also show you how to get it.

Finding IP address on Linux

Each desktop environment has a particular graphical interface to obtain the computer’s IP address. However, the fastest and most efficient way is to do it from the terminal. Also, this method guarantees that it will work in any distribution.

In Linux, you can use ifconfig, hostname, or ip command to find out IP address. 

ifconfig command

ifconfig is the command to view and change the configuration of the network interfaces on your system. It stands for “interface configuration”.

So, open a new terminal session from the main menu and run ifconfig command to list all the available network interfaces as shown below.

$ ifconfig

This output displays information about all network interfaces currently in operation. 

Get the IP address on Linux
Get the IP address on Linux

We are interested in the inet and inet6 values. inet shows a private ipv4 address while inet6 shown ipv6 address.

hostname command

The ifconfig command shows a whole lot of information. But, if you only want to find ip address, simply use the hostname command with the – I option as shown below.

hostname -I

The output of this command shows the private IP address on the terminal prompt.


ip command

ip is another command available in Unix or Unix-like system. This command provides a similar utility to configure the network interfaces on your system, but with additional functionality.

ip addr show

Check inet and inet6 values to find IP addresses.


1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp6s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 00:90:f5:c3:0b:8b brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 74:2f:68:08:39:0f brd ff:ff:ff:ff:ff:ff
inet brd scope global dynamic noprefixroute wlp5s0
valid_lft 80510sec preferred_lft 80510sec
inet6 fe80::8c46:df48:2b0b:5255/64 scope link noprefixroute
valid_lft forever preferred_lft forever

Use curl command to get the public IP address

Sometimes it is useful to know our public IP address. However, it is also not convenient to spread it.

To do this, we will use the curl command. So the first step is to install it:

If you use Debian, Ubuntu, Linux Mint, or any derivative:

sudo apt install curl

In the case of using RHEL, CentOS 8, or Fedora

sudo dnf install curl

Anyway, you can read the official curl documentation and get more information.

Once curl is installed, simply run the following command:


And then you’ll get as screen output the IP address.

As I said before, it’s better not to show it.

If you prefer to use a graphical interface…

Many people are still afraid of the terminal and that is why they always prefer to use the graphical interface. Of course, this equally effective method is quite useful for beginners and newcomers.

So, open Settings from the main menu. You will see the following screen:

Wifi connections on Ubuntu
Wifi connections on Ubuntu

This screen shows the Wifi connections. In my case, I am using one but if you connect via a network cable, go to Network section.

Networks section
Networks section

So, I am connected to a wifi network called Trojan Malware and an Options button is activated. Click on it and you will see this screen:

Get the IP Address in Ubuntu
Get the IP Address in Ubuntu

In the first screen called Details, you will see the network information and the IP address we have.

This is a quick and easy way if you don’t want to use the terminal.


In Linux, it is quite simple to obtain the IP address of the computer and especially if we use the terminal. So the IP address is vital for many network services but also for other processes via the Internet.

In this post, you have learned to obtain both private and public IP addresses in a simple way. However, it is advisable not to disclose them for security reasons.

So, leave us a comment and spread this post using your social networks.

Scroll to Top