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.


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}'


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

The second IP here 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) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

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