Skip to content

Shell Aliases

By Elliot J. Reed

Here you'll find a few handy aliases to use in ZSH and Bash Shell. Tested on Linux - likely work on Mac!

.. ... ....
# Make changing directory up easier
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
ls sl ll
# Make ls show directory endings
alias ls='ls -FA --color'
# Make sl list files ('ls')
alias sl='ls'
# Make ls -l show in human-readable format
alias ll='ls -lhFA --color'
du
# Show human readable file sizes in directory
alias du='du -ach | sort -h'
free
# Show human-readable free memory
alias free='free -th'
diff
# Make diff side-by-side
alias diff='diff -y --color'
clip
# Copy file contents to clipboard (USAGE: clip [FILE])
alias clip='xclip -sel clip <'
perm
# Get numerical file permissions of file
alias perm='stat -c "%a %n"'
ping
# Ping 3 times rather than infinite
alias ping='ping -c 3'
mkdir
# Make directory and parent directories, and output which directories have been created
alias mkdir="mkdir -pv"
flushdns
# Flush DNS cache
alias flushdns='sudo resolvectl flush-caches'

Conclusion

These shell aliases demonstrate how small customizations can significantly improve your command-line productivity. By adding these to your ~/.bashrc or ~/.zshrc file, you'll have convenient shortcuts that make common tasks faster and safer. From easier directory navigation with .. and ... to human-readable output with modified ls, du, and free commands, each alias solves a specific friction point in daily terminal work.

Start by adding the aliases that align with your most frequent tasks, then gradually expand your collection as you identify other repetitive commands. Remember to source your configuration file after making changes with source ~/.bashrc or source ~/.zshrc to load the new aliases. These simple productivity enhancements can save you countless keystrokes and help prevent common mistakes, making your command-line experience smoother and more efficient.