Whether you are configuring a local web server, setting up an SSH connection, or troubleshooting network connectivity, knowing the IP address of your Ubuntu Linux machine is a fundamental requirement. For many years, Linux users relied on the classic ifconfig command to find this information. However, ifconfig has been officially deprecated in modern Linux distributions. The standard, modern tool for network configuration and information gathering is the powerful ip command.
Finding Your Local IP Address
The local IP address (often starting with 192.168.x.x or 10.x.x.x) is the address assigned to your computer by your local router. This is what you need to connect to your Ubuntu machine from another computer on the same home or office network.
To view your IP address, open your terminal and type the following command:
ip addr show
Press Enter.
Understanding the Output
The output of this command can look overwhelming at first glance, as it displays detailed technical information for every network interface on your system.
- Look for the block of text starting with a number. The first interface is usually
1: lo. This is the “loopback” interface (127.0.0.1), which your computer uses to talk to itself. You can ignore this. - Look for the next block. The name of your actual network interface will vary. If you are connected via an Ethernet cable, it often starts with an “e” (like
eth0,enp3s0, oreno1). If you are using Wi-Fi, it usually starts with a “w” (likewlan0orwlp2s0). - Underneath the name of your active interface, look for the line that begins with the word
inet. - The number immediately following
inetis your local IP address. It will look something likeinet 192.168.1.45/24.
Your IP address is the number before the slash (e.g., 192.168.1.45). The /24 is the subnet mask indicator.
The Shortcut Command
If ip addr show feels too long to type, the ip command allows for shorthand abbreviations. You can simply type:
ip a
This will produce the exact same detailed output, saving you a few keystrokes.
How to Show Only the IP Address (Clean Output)
If you are writing a bash script or just hate reading through the dense block of text to find that one specific number, you can use the -brief flag to compress the output into a very clean, easy-to-read table.
Type the following command:
ip -brief addr show
This will output a simple, single-line summary for each interface, clearly displaying the interface name, its status (UP or DOWN), and its IP address.