We will show you how to shorten the long commands we use constantly in the Linux command line using an alias. Although we show it using Kali Operating system, you can use it on other Linux distributions too.
The use of alias helps you implement the operations you do on the command line very quickly. The acronym you define with a few letters will display a very long command and immediately execute it.
There is no need to recreate the bash_aliases file created for the first time during persistent use. You can edit this file, which is in the home folder and hidden, by opening it with any editor.
Permanent Alias in Linux
We shorten the commands that we use constantly and a little longer with the alias, but when you turn the computer off and on, it goes again. If you ask how to do it permanently, add the codes to the end of the ~/.bashrc file, the shortcut will not be deleted even if you turn it off and on. If the “.bashrc” config file is not available on your system, you can create a new one with “touch” command. You can use “touch .bash_aliases” as an example command.
nano ~/.bashrc
![~/.bashrc](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd8f07f04b46.png)
alias del='clear'
![alias del='clear'](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd8f0b0d748f.png)
Using Alias with Example
Example 1:
We use the clear command to delete the text on the command line. We will make the short name of the “clear” command to be “del“. In other words, the del text will delete the text on the screen. first, we run the command below.
alias del='clear'
![alias del='clear'](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd8f70a7020c.png)
We will add our command into the “.bashrc” config file to be permanent. After adding the following command, we click the “ctrl + x” command at first and click the “y” key secondly. Then click the “Enter” key to save it.
![~/.bashrc](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd8f07f04b46.png)
alias del='clear
![alias del='clear'](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd8f0b0d748f.png)
Example 2:
We use “apt-get update & sudo apt-get -y upgrade” commands in order to update or upgrade the operating system we use. We will make this command “upd” as its short name. First, we run the command below.
alias upd='sudo apt-get update; sudo apt-get -y upgrade' nano ~/.bashrc
![alias upd='sudo apt-get update; sudo apt-get -y upgrade'](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd90c87611bb.png)
We will add our command into the “.bashrc” config file to be permanent. After adding the following command, we click the “ctrl + x” command at first and click the “y” key secondly. Then click the “Enter” key to save it.
alias upd='sudo apt-get update; sudo apt-get -y upgrade'
![nano ~/.bashrc](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd905c625476.png)
Finally, we run the “upd” command. As you can see on the following page, the command is running successfully.
![upd](https://www.systemconf.com/wp-content/uploads/2020/12/img_5fd90f52c0fa0.png)
You can duplicate these examples and add them to the “.bashrc” config file.