If you want to know the IP address and currently active network interfaces on Linux, we need to use “ifconfig” command.
The ifconfig command is part of “net-tools” package in ubuntu, hence we first need to make sure it is installed, if its not we need to install it as below,
$ sudo apt-get install net-tools
Now, you can check the IP address and network interfaces as, where below “192.168.1.100” is current IP address. If you have more than one network interface connected, i.e. Ethernet cable directly connected to your laptop/pc and also laptop/pc is connected to WIFI, you may see the two intefaces with active IP address, in that case Ethernet takes precedence over WiFi, hence you may use Ethernet IP address to access your machine.
$ ifconfig -a
enp8s0 Link encap:Ethernet HWaddr 00:26:b9:11:51:48
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:17
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:2924 errors:0 dropped:0 overruns:0 frame:0
TX packets:2924 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:290201 (290.2 KB) TX bytes:290201 (290.2 KB)
wlp4s0b1 Link encap:Ethernet HWaddr 0c:60:76:61:ce:49
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::c238:fbab:7238:686f/64 Scope:Link
inet6 addr: 2401:4900:1906:5b2e:d8c7:71f2:457b:2/128 Scope:Global
inet6 addr: 2401:4900:1906:5b2e:ca0f:a0ee:4ee1:274/64 Scope:Global
inet6 addr: 2401:4900:1906:5b2e:e988:3f17:fab3:b493/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57602 errors:0 dropped:0 overruns:0 frame:0
TX packets:40922 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:57699640 (57.6 MB) TX bytes:6251783 (6.2 MB)