This post contains my personal collection of useful macOS commands.
Most of them are specific to the macOS, however, some are univrersal.
Show hidden files:
defaults write com.apple.finder AppleShowAllFiles YES;
killall Finder /System/Library/CoreServices/Finder.app
Hide hidden files:
defaults write com.apple.finder AppleShowAllFiles NO;
killall Finder /System/Library/CoreServices/Finder.app
networksetup -setairportpower en0 off; \
sleep 0.1; \
ifconfig en0 down; \
sleep 1; \
dscacheutil -flushcache; \
killall -HUP mDNSResponder; \
killall mDNSResponderHelper; \
sleep 0.1; \
ifconfig en0 up; \
sleep 0.1; \
networksetup -setairportpower en0 on
Flush DNS cache:
sudo killall -HUP mDNSResponder
Update for macOS Catalina and later:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Get local IP address:
ifconfig | grep "inet " | grep -v 127.0.0.1 | cut -d\ -f2
Get public IP address:
curl http://bot.whatismyipaddress.com