How To Make A Permanent Alias In Kali Linux

     Since the Linux operating system is based almost entirely on terminal commands, it is imperative that you create some basic aliases to make your life a bit easier. One way of doing this is to just issue the command, “alias=command.” The problem with this method is that it only keeps the alias until the system is logged off, then you have to enter it all over again.
    The solution? Enter the alias in the .bashrc file. This simple tutorial will explain to you how to do this.

Step one:

Log into Linux and open a terminal.

Step two:

In the terminal, type “leafpad .bashrc”.

step one

Step three:

Hit Enter. A text file (.bashrc) should open in the leafpad text editor.

Step three 1

Scroll down until you reach a line filled with #alias examples.

Step three 2

Step four:

Place your select cursor at the end of the last #alias example and hit enter, making a new line. See photo below.

Step four

Step five:

Type the alias in the specified above location using the following format:
alias [shortcut]='[command]'
Replace [shortcut] with the alias you want, and replace [command] with the command that the alias stands for.
Example: alias updatesys='apt-get update && apt-get upgrade'

The above example is a alias that I use so I can easily update Kali without having to type in “apt-get update && apt-get upgrade” every time.

Picture example:
step four 2

Final step:

You’re almost there! Now that you’re done typing the alias in, you need to save the .bashrc file. Do this quickly by hitting Ctrl+S or click “File > Save.”

To insure that the file has been completely saved, make sure that the asterisk next to the file name is gone:

Tip 1

Now close the .bashrc file and the terminal behind it. Open a new terminal and try out your alias. If all went according to plan, the alias will be permanent, and can only be removed if you remove it from the .bashrc file in the same way you created it.

Congrats! You’re done!

Repeat these steps to create as many permanent aliases as you please!

1 comment:

  1. I've tried about 20 different complicated methods to do the same thing, and none of them worked!
    Then I found your post, and its simplicity is absolutely brilliant!
    THANK YOU!!!!


Feel free to leave any criticisms or suggestions here in the comments!