Skip to content

Instantly share code, notes, and snippets.

@pH-7
Last active May 21, 2023 03:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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