The quickest way to see your IP address in Linux

The fastest method is to open a terminal and type hostname -I, then press Enter. This shows all IP addresses assigned to your computer on one line. If you only want the address your computer uses to connect to the internet, this command works on most Linux distributions without installing anything extra.

If that does not work on your system, try ip addr show instead. This command displays more detail — it lists every network connection your computer has, including the loopback address (127.0.0.1, which your computer uses to talk to itself). Look for the line that starts with "inet" under the connection you use, usually called "eth0" for wired or "wlan0" for wireless.

Key Takeaways

  • Type hostname -I in a terminal to see your IP address in one line on most Linux systems.
  • The ip addr show command displays all network connections and their addresses if you need more detail.
  • Your IP address tells your router and the internet where to send data meant for your computer.
  • You may have both a private address (starting with 192.168 or 10.) and a public address, depending on your network setup.

Understanding what your IP address is and why you need it

An IP address is a number that identifies your computer on a network, similar to how a street address identifies a house. Every device connected to the internet or a local network has one. Your computer uses it to send and receive data, and your router uses it to know which device to send incoming data to.

You might need to find your IP address to set up a printer on your home network, connect to your computer remotely, troubleshoot network problems, or configure software that needs to know where your computer is. Linux systems can have multiple IP addresses — one for your internet connection, one for your local network, and others for special purposes.

Using the terminal to display your IP address

Open a terminal on your Linux desktop. Most distributions have a terminal process in the applications menu, or you can press Ctrl+Alt+T on many systems. Once the terminal window opens, you are ready to type commands.

Type hostname -I and press Enter. The output will be one or more numbers separated by spaces, like 192.168.1.50 or 10.0.0.15. If you see multiple addresses, the first one is usually your main connection. This command works on Ubuntu, Debian, Fedora, CentOS, and most other distributions without requiring you to install additional software.

If hostname -I returns nothing or an error, use ip addr show instead. This command lists every network interface on your computer. Find the section labeled with your connection name (usually "eth0" for wired Ethernet or "wlan0" for WiFi). Under that section, look for a line starting with "inet" — the number after "inet" and before the forward slash is your IP address.

Other commands that show your IP address

The ifconfig command was the standard way to check IP addresses for many years, and it still works on most systems. Type ifconfig and press Enter. Look for your network connection name, then find the line that starts with "inet addr:" or just "inet" — the number there is your IP address. Some newer Linux distributions have removed ifconfig, so this may not work on your system.

Another option is nmcli device show, which works on systems using NetworkManager (most desktop Linux distributions do). This command displays detailed information about each network device, including the IP address under "IP4.ADDRESS". It is more verbose than hostname -I but less technical than ip addr show.

For a quick check without opening a terminal, many Linux desktop environments show your IP address in the network settings menu. Click the network icon in your system tray (usually in the top right corner), select your connection, and look for connection details or information — your IP address will be listed there.

Private IP addresses versus public IP addresses

The address you see in the terminal is usually your private IP address — the one your router assigns to your computer for use on your home or office network. Private addresses always start with 192.168, 10., or 172.16 through 172.31. Your router uses these addresses to route data between devices on your local network.

Your public IP address is different. It is assigned by your internet service provider and is what the rest of the internet sees when your computer connects to websites or services. To find your public IP address from Linux, you can type curl ifconfig.me in a terminal (this requires an internet connection and the curl program, which is usually installed). This command connects to a website that tells you what address the internet sees you coming from.

For most home users, knowing your private IP address is what matters — that is what you use to set up printers, access files on other computers at home, or connect to your computer remotely from another device on the same network. Your public IP address changes periodically unless your internet service provider charges extra for a static address.

Troubleshooting when commands do not work

If hostname -I returns nothing, your computer may not have an active network connection, or your distribution may not include the hostname command. Try ip addr show instead — this command is part of the iproute2 package, which is installed on nearly all modern Linux systems.

If you see an error like "command not found", the program is not installed on your system. This is rare for the commands listed here, but if it happens, try a different command from the list above. If none of them work, your Linux distribution may be very minimal or specialized — check the documentation for your specific distribution.

If you see an IP address but it starts with 169.254, your computer is not connected to your network properly. This is a temporary address that Linux assigns when it cannot reach a DHCP server (the device that normally hands out IP addresses). Check that your network cable is plugged in or that you are connected to the correct WiFi network.

Frequently Asked Questions

Why do I need to know my IP address?

You need it to set up network devices like printers, access your computer remotely, troubleshoot network problems, or configure software that needs to know where your computer is located on the network. Most of the time you do not need it, but when you do, these commands get you the answer in seconds.

What does the number after the slash mean in ip addr output?

The number after the slash (like /24 in 192.168.1.50/24) is the subnet mask, written in a shorthand called CIDR notation. It tells your computer which other addresses are on the same local network. You usually do not need to worry about it — just use the number before the slash as your IP address.

Is my private IP address the same every time I restart?

Usually yes, but not always. Most home routers are set to give your computer the same private address each time it connects, but this is not may provide. If you need the address to stay the same, you can set a static IP address in your network settings or configure your router to always assign the same address to your computer.

Can I change my IP address?

You can change your private IP address through your network settings, though this is rarely necessary. Your public IP address is assigned by your internet service provider and you cannot change it directly, but it will change on its own periodically unless you pay for a static public IP.