What are your favorite bash aliases?

Bash aliases are awesome. They can save you keystrokes and give you shortcuts to some of your most used commands. I’ll share some of my own down in the answers.

What’s in your .bashrc file? What bash aliases have you found the most useful?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The one that I always make sure to include is:

alias sudo='sudo '

This looks a bit confusing, but essentially, it makes all of the other aliases you define function correctly when used with sudo. The ALIASES section of the bash manual says:

If the last character of the alias value is a blank, then the next command word following the alias is also checked for alias expansion.

So this is just a nice way of making sure your commands are evaluated for aliases before being passed over to sudo, which ends up being pretty useful.

alias ls='ls -AlhF --color=auto'

NEVER terminal without it ;-)

Here are a few more of my favorite aliases.

Show/hide hidden files in the macOS Finder:

alias show="defaults write AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write AppleShowAllFiles -bool false && killall Finder"

Limit ping to five ECHO_REQUEST packets:

alias ping='ping -c 5'

Display drives and space in human readable format:

alias drives='df -h'

Run this one in ~/ to discover what folders are using the most space:

alias usage='du -h -d1'

Colorize grep output

alias grep='grep --color=auto -n'

Clear the screen (can’t live without this one!)

alias c='clear'

That’s all, folks!