Skip to content

[Linux] Use "alias" command to custom your command

When we using Linux operating system such as Ubuntu and Mint, it is vert convenient to be able to use commands in Terminal to open the files and execute the programs we need.

But unfortunately, not all programs we install can be opened or execute directly. In fact, we can set the shortcut commands for the things we want to do quickly by setting the alias command.

I record how to use the alias command in the following.


How to use alias

The method of using alias is very simple. For example, I want to open the PyCharm IDE, I need to enter the very long command:

sh /home/clay/IDE/pycharm-2019.3.1/bin/pycharm.sh


But we can use alias to set the shorter version command.

alias pycharm='sh /home/clay/IDE/pycharm-2019.3.1/bin/pycharm.sh'

The alias is placed at the right, followed by "shorter_version_command"="complete_command".

But it should be noted that this command will be invalid if the terminal is closed. If you want to make this command permanent, we have to enter it in the file ~/.bashrc.

Use any editor such as vim to open ~/.bashrc and write:

alias pycharm='sh /home/clay/IDE/pycharm-2019.3.1/bin/pycharm.sh'


Activate:

source ~/.bashrc

In this way, it can be used immediately, and it can be used normally after rebooting.

Tags:

Leave a Reply