Bash Alias Quotes: Single & Double Quote Examples
These are for anyone writing bash aliases and wrestling with quotes — whether you're escaping spaces, embedding variables, or passing arguments to a command. Pick a line that matches your current shell struggle, tweak it to fit your command, and paste it straight into your terminal.
Short and Punchy
Quick one-liners that get the job done without fuss. Use these when you need a compact alias that's easy to remember.
- alias ll='ls -l'
- alias la='ls -a'
- alias ..='cd ..'
- alias ...='cd ../..'
- alias home='cd ~'
- alias c='clear'
- alias h='history'
- alias j='jobs'
- alias e='exit'
- alias q='exit'
With Variables and Expansion
These aliases need double quotes so the shell expands variables and commands at runtime. Perfect for dynamic paths or reusing your current directory.
- alias now="date '+%Y-%m-%d %H:%M:%S'"
- alias myip="echo "Your IP: $(curl -s ifconfig.me)""
- alias grep="grep --color=auto"
- alias mkdir="mkdir -pv"
- alias cd="cd -P"
- alias path='echo $PATH'
- alias lastcmd='fc -ln -1'
- alias up='cd .. && ls'
- alias back='cd $OLDPWD'
- alias here='pwd && ls'
With Single Quotes for Literal Text
When you want no expansion at all — just the raw string — single quotes are your friend. Great for aliases that use $ or backticks literally.
- alias dollar='echo $HOME'
- alias bashver='echo $BASH_VERSION'
- alias quote='echo "Don't panic"'
- alias backtick='echo `date`'
- alias literal='echo "$HOME is not expanded"'
- alias star='echo *'
- alias tilde='echo ~'
- alias empty='echo ""'
- alias space='echo "hello world"'
- alias tab='echo -e "a\tb"'
Funny and Playful
Lighten up your terminal with a bit of humor. These aliases are perfect for surprising a coworker or making yourself chuckle.
- alias plz='sudo'
- alias wtf='man'
- alias yolo='git commit -m "yolo"'
- alias oops='git reset --hard'
- alias nope='false'
- alias coffee='caffeinate'
- alias brain='sleep 5'
- alias zen='clear && echo "Breathe."'
- alias busy='echo "I'm swamped"'
- alias later='echo "See you tomorrow"'
For Git and Development
Streamline your version control workflow with these time-saving aliases. They mix single and double quotes to handle complex commands.
- alias gs='git status'
- alias ga='git add .'
- alias gc="git commit -m"
- alias gp='git push'
- alias gl='git log --oneline'
- alias gd='git diff'
- alias gco='git checkout'
- alias gb='git branch'
- alias gst='git stash'
- alias gpo="git push origin HEAD"
For File and Directory Operations
Make file management a breeze with these aliases. They show how to use quotes to handle spaces and special characters in filenames.
- alias rm='rm -i'
- alias cp='cp -i'
- alias mv='mv -i'
- alias ln='ln -i'
- alias mk='mkdir -p'
- alias rd='rmdir'
- alias tree='find . -print | sed -e "s;[^/]*/;|____;g;s;____|; |;g"'
- alias l='ls -lah'
- alias ll='ls -l'
- alias la='ls -A'
For System and Process Management
Keep an eye on your system with these handy aliases. They often need double quotes for variables and command substitution.
- alias ps='ps aux'
- alias top='htop'
- alias mem='free -h'
- alias disk='df -h'
- alias cpu='lscpu'
- alias net='ip addr'
- alias ports='netstat -tulpn'
- alias proc='ps -ef | grep'
- alias kill9='kill -9'
- alias reload='source ~/.bashrc'
Practical Tips for Choosing and Personalising
Pick an alias that matches your most frequent command. If you often type the same long command, turn it into an alias. To personalise, replace the command inside the quotes with your own arguments or flags. Test each alias in a terminal before adding it to your permanent config. Keep aliases short and memorable, and avoid overriding built-in commands unless you're sure.
Frequently Asked Questions
When should I use double quotes instead of single quotes in an alias?
Use double quotes when you want the shell to expand variables like $HOME or command substitutions like $(date). Use single quotes when you want the literal characters, for example if you're echoing a dollar sign or a backtick.
How do I include a single quote inside a single-quoted alias?
You can close the single quote, add an escaped single quote, and reopen it. For example: alias sayit='echo '"'"'hello'"'"'' — it looks odd but works.
Can I use both single and double quotes in the same alias?
Yes, you can nest them as long as you escape properly. For instance, alias greet="echo 'Hello, $USER'" uses double quotes outside and single quotes inside, letting $USER expand.
How do I make an alias permanent?
Add the alias line to your ~/.bashrc or ~/.bash_aliases file, then run source ~/.bashrc to apply the changes immediately.
Why does my alias with spaces fail?
If your command contains spaces, wrap the entire command in quotes. For example, alias mycmd='echo "hello world"' — the outer single quotes keep the spaces together.