27th July 2024

What is Alias Command? Identifying Alias ​​in Kali with Examples

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
~/.bashrc

 

alias del='clear'
alias del='clear'
alias del=’clear’

 

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'
alias del=’clear’

 

LEARN MORE  What is System Center Configuration Manager(SCCM)? What are the Benefits?

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
~/.bashrc

 

alias del='clear
alias del='clear'
alias del=’clear’

 

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'
alias upd=’sudo apt-get update; sudo apt-get -y upgrade’

 

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
nano ~/.bashrc

 

Finally, we run the “upd” command. As you can see on the following page, the command is running successfully.

upd
upd

 

You can duplicate these examples and add them to the “.bashrc” config file.

Leave a Reply

Your email address will not be published. Required fields are marked *