How to Find Your IP Address via Command Line in Ubuntu

The Networking Identification Vector

When configuring a headless Ubuntu Linux server to act as a web host, a database node, or a file sharing repository, the absolute first requirement is knowing its exact location on the network. Without a graphical interface, you cannot simply click on a Wi-Fi icon to view your connection details. You must query the operating system’s internal networking stack directly via the terminal to extract the server’s current IPv4 address.

How to Find Your IP Address

Modern Linux distributions have deprecated the classic ifconfig command in favour of the much more powerful and versatile ip command suite.

1. Open your terminal application or connect to your server via SSH.
2. To rapidly display the IP addresses assigned to every active network interface on your server, execute the following command:

ip addr show

3. The terminal will output a dense block of text detailing every hardware adapter. You must parse this output to find your address:
4. Ignore the first entry labelled lo (loopback); this is the 127.0.0.1 address the server uses to talk to itself.
5. Look for the second entry, which will usually be named something like eth0, enp3s0, or wlan0.
6. Within that specific block of text, locate the line that begins with the word inet.
7. The number immediately following inet (for example, 192.168.1.45/24 or 10.0.0.12/8) is your server’s current, active local IP address.

You can now use this specific numerical string to connect to the server via SSH from other machines on the same local network.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.