How to Create Aliases (Shortcuts) for Common Commands in Linux

If you spend a lot of time working on Linux, you’ve probably found yourself typing the same commands again and again. Whether it’s checking files with ls -l, switching directories, or updating your system, repeating long commands can slow you down.

This is where aliases come in handy. Aliases in Linux are custom shortcuts that let you run lengthy or complex commands with a simple keyword of your choice. With just a few tweaks, you can save valuable time and make your command-line workflow much more efficient.

What are Aliases in Linux?

An alias is basically a user-defined shortcut for a command or a set of commands. Instead of typing the full command every time, you assign it a shorter name. For example:
alias ll="ls -alF"

Now, whenever you type ll, it will automatically execute ls -alF.

Chances are, your Linux system already has some predefined aliases. You can view them by running:
alias

Types of Aliases: Temporary vs. Permanent

Aliases can be temporary (only available during the current terminal session) or permanent (saved to your shell configuration so they work every time you log in).

  1. Creating Temporary Aliases

To create a temporary alias, use the following syntax:
alias shortcut="your command here"

For example:
alias wr="cd /var/www/html"

Now, typing wr will take you directly to the /var/www/html directory. But remember – this alias will disappear once you close the terminal.

  1. Creating Permanent Aliases

If you want aliases to stay available across sessions, you’ll need to add them to your shell configuration file. Depending on the shell you use, it could be one of the following:

Bash: ~/.bashrc
Zsh: ~/.zshrc
Fish: ~/.config/fish/config.fish

For example, in Bash:
vim ~/.bashrc

Add your aliases at the end of the file:

My custom aliases
alias ll="ls -alF"
alias home="ssh -i ~/.ssh/mykey.pem user@192.168.0.100"

Save the file, then reload it with:
source ~/.bashrc

Now your aliases will work in every new session.

Why Use Aliases?

Here are a few reasons aliases are handy:

  • Save time: shorter commands, faster typing.
  • Avoid errors: no more mistyping complicated options.
  • Personalize Linux: make your environment work the way you like.

For example, instead of typing:
ls -lh --color=auto

You could just type:
ll

Organising Aliases with .bash_aliases

On Ubuntu and many Debian-based systems, it’s a good practice to store aliases in a separate file called .bash_aliases. This file is automatically loaded by .bashrc, keeping your configuration cleaner and more organized.

Example:
vim ~/.bash_aliases

Add your aliases:
alias gs="git status"
alias c="clear"
alias update="sudo apt update && sudo apt upgrade -y"

Reload with:
source ~/.bash_aliases

Removing Aliases

If you want to delete an alias, use the unalias command:
unalias alias_name

To remove all aliases in the current session:
unalias -a

Useful Aliases for Everyday Linux Tasks

Here are some practical aliases you might find helpful:
alias gs="git status"
alias gp="git pull"
alias serve="python3 -m http.server"
alias ..="cd .."
alias …="cd ../.."
alias update="sudo apt update && sudo apt upgrade -y"

These shortcuts are particularly handy for developers, sysadmins, and anyone who spends hours in the terminal.

Conclusion

Creating aliases in Linux is one of the easiest ways to boost productivity and simplify your workflow. Instead of wasting time retyping long commands, you can create custom shortcuts tailored to your daily tasks.

Think about the commands you run most often, add them as aliases, and enjoy a faster, smoother Linux experience.

Anita Sreelal
Anita Sreelal