Bash Command to Check IP Address


If you are on a Bash Shell and want to know the IP address of your device, then you can make use of the ifconfig command.


Example:

As ifconfig may have too much information, we can pipe it with awk command to filter out just the IPs.

# ifconfig | awk '/inet / {print $1, $2}'


inet 127.0.0.1
inet 192.168.1.3

Of the output, the first IP 127.0.0.1 is the loopback address also called as localhost.

The second IP here 192.168.1.3 is my local Private IP..

Bash Command to know IP Address Example
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author Info:

Rakesh (He/Him) is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap