- One Tip a Week
- Posts
- One Tip a Week: An Alias for Flushing DNS
One Tip a Week: An Alias for Flushing DNS
I don’t know about everyone else, but sometimes I need to flush my DNS. In the past I’d always Google this for my Mac, but one day I said
“Enough!”
On macOS, it’s a super long two commander with sudo in the mix, so I decided to create a shell alias. This is what I came up with
alias flushdns='sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder'
Now all I need to do from the terminal is run flushdns
. It will prompt for your login password for your machine, but that’s only because we need to run sudo to perform this action.
You could create an alias on Windows as well, but the command is a little more straightforward.
ipconfig /flushdns
On Linux it’s a short command as well.
resolvectl flush-caches
I leave it up to you to decide if it merits an alias on other OSes, but on macOS, holy guacamole, that’s a lot to type! That said, I could always use mcfly to find the command. 😎
What’s some of your go to shell aliases? Drop me an e-mail or let me know on my socials!
That’s it! Short and sweet. Until the next one!