The Linux alias is used to create shortcuts or short forms for the commands. The alias makes a command with options easy to call without remembering all details. If you set an alias but this alias is not saved and cleared after reboots you should use the shell configuration file in order to save the alias. Aliases are created using the alias
keyword but where is the alias file or alias file configuration?
Alias File In Bash Shell
The alias commands in bash are stored inside the bash configuration file. The bash configuration file is located ~/.bashrc
. We can put the alias configuration into the “.bashrc” file in order to make the alias persistent between reboots.
$ vim ~/.bashrc
Alias File In ZSH Shell
The alias file in ZSH shell is located in the ~/.zsh
. We can put the alias configuration into the “.zshrc” file in order to make the alias persistent between reboots.
$ vim ~/.zshrc
Alias File In CSH Shell
The alias configuration is stored in ~/.csh
the CSH shell. We can put the alias configuration into the “.csh” file in order to make the alias persistent between reboots.
$ vim ~/.csh
Alias File In Korn Shell
The alias configuration is stored in ~/.ksh
the CSH shell. We can put the alias configuration into the “.ksh” file in order to make the alias persistent between reboots.
$ vim ~/.ksh
Adding Alias To Alias Files
Open the alias files according to your shell type and add the alias. In the following example, we add an alias named mycd
which simply changes the current working directory into the /mnt
.
alias mycd="cd /mnt"