Skip to content

Instantly share code, notes, and snippets.

@pH-7
Last active June 2, 2024 21:14
Show Gist options
  • Save pH-7/241140810610ba5012f5 to your computer and use it in GitHub Desktop.
Save pH-7/241140810610ba5012f5 to your computer and use it in GitHub Desktop.
Get my server local IP (saver time if you change very often your machine) - https://github.com/HiDeaUp/hideaup.github.io
ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
@pH-7
Copy link
Author

pH-7 commented May 21, 2023

On Mac, it's usually:

ifconfig en0| grep "inet[ ]" | awk '{print $2}'

@pH-7
Copy link
Author

pH-7 commented May 21, 2023

You can also use ip addr show command if available (ip will progressively replace ifconfig on Linux distributions).

More info: https://www.redhat.com/sysadmin/ifconfig-vs-ip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment