Where do I put zsh aliases Linux?

If you are a Linux user, then undoubtedly, most of your time is spent in the terminal. Working in the command line is a fantastic activity, but typing commands after commands can be exhausting. Aliases are utilized for this purpose. Aliases save you from typing huge command lines over and over again. Furthermore, you can do your tasks with only a few keystrokes, which feels like magic in the command line. In most operating systems, the bash shell is included by default. In comparison, z shell or zsh is a popular alternative out there regarding customization and usability. You can install the zsh shell in few minutes if you do not have it already or skip this section if you have zsh installed.

zsh installation:

$ sudo apt install zsh

zsh aliases:

The .zshrc file exists in the user home directory where ZSH aliases are configured. These aliases are loaded automatically when the shell starts, but you can force them to reload through sourcing the .zshrc file.

Alias basic syntax:

alias Flag Custom-alias="Command"
  • “alias” for the alias keyword
  • “Flag” for adding a flag
  • “Custom-alias” for setting custom alias
  • “Command” entering a command for the custom alias

Simple zsh aliases:

A simple zsh alias is a shorter form of a long command. For creating a simple alias, utilize any text editor such as “nano” in your Linux system and edit the “./zshrc” file. To make editing easier and avoid confusion, keep all of your zsh aliases in one file section.

$ nano ~/.zshrc

Here is the syntax for creating a custom zsh aliases:

alias <custom-alias>=”<command>

In the following example, we will set some zsh aliases for making the git repositories work.

alias gadd="git add ."
alias ginit="git init ."
alias gc="git commit -m 'initial commit"

Now, save this “./zshrc” file and then write out the below-given command for making changes.

$ source ~/.zshrc

Now, initialize a git repository and check out the output.

$ ginit

zsh myip alias:

Add the following line to your “./zshrc” file to print out the current public IP address value. This line will create a zsh alias for the “myip” command.

alias myip='curl http://ipecho.net/plain; echo'

$ source ~/.zshrc

$ myip

zsh reload alias:

Do you also forget the method of reloading the zsh terminal? Then, no worries!. You can create a zsh alias for reloading your zsh terminal.

alias reload='source ~/.zshrc'

source ~/.zshrc

zsh update packages alias:

In the “./zshrc” file, to add an alias for updating the packages list, utilize the below-given command.

alias sapu='sudo apt-get update'

$ source ~/.zshrc

Now use this alias in the terminal and check the output in the terminal.

$ sapu


Aliases are an essential part of any Linux shell, and ZSH lets you customize your aliases according to your requirement. You can also use zsh aliases to make the workflow easier. This article provided you with various forms of zsh aliases: simple zsh alias, update packages alias, reload terminal alias, and myip alias. Once you grasp the idea of making zsh alias in zsh, then it won’t be difficult for you to experiment with it.

About the author

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.