sudo apt install net-tools ifconfig#private ip hostname -I or ifconfig or ip addr show #public ip curl ifconfig.meifconfig -a$ hostname -I # The following commands allow you to get ip address in Linux. Open a terminal. Type any of the following command. Press Enter. The Ip address is next to inet. ip address ip address show eth0 ifconfig -a ifconfig eth0 ip route ip route show dev eth0 ip addr ip addr show ifconfig -a ip route # private interface="lo" ip addr | grep "inet\b" | grep "\b${interface}.*$" | awk '{gsub(/\/.+/,"",$2); print $2}' # public curl ifconfig.meip addr ip addr show eth0 ifconfig -a ifconfig eth0 ip route ip route show dev eth0# show IP address of current linux machine ip addr showip addr show | grep inet | grep -v inet6 | awk '{print $2}' | cut -d '/' -f 1# Run ifconfig command and filter the output using grep and awk ip_address=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | awk '{print $2}') # Print the current IP address echo "Current IP address: $ip_address"