-2

I want to know the easiest way and I would perfer a single line command that works on most or all Linux distros. I want to get the devices IPv4 address.

The reason why I want to know this is because I use XAMPP and to test my websites out on my phone I like to have my computer and phone connected to the same WiFi network and I connect to my website by my computers IP address.

  • use command: ifconfig – Tejas Dec 11 '18 at 1:04
0

The traditional command, on Unix, is ifconfig.

eg

% ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.137  netmask 255.255.255.0  broadcast 10.0.0.255
        ....

This command has been deprecated and may not always be installed by default. The modern command is ip.

% ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 10.0.0.137/24 brd 10.0.0.255 scope global noprefixroute dynamic eth0
       valid_lft 18396sec preferred_lft 18396sec

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.