How to Create and Use Alias in Linux

We all know that command line is fast, but Linux users often need to use the same command over and over again it slow you down and affects you productivity and also if the command is long you need to remember it and type it.

You can save some time by creating aliases for your most often used commands. Aliases are custom defined short commands.

List Currently Defined Aliases in Linux

$  alias

list-aliases
list-aliases

Now you can see executing:

$  ll

is actually executing:

$  ls  -alF

Thus  ll is just an alias to  ls  -alF

Creating Aliases in Linux

Creating an alias in Linux is very easy task there are two types of alias that you can create temporary or permanent.

Creating Temporary Alias in Linux

you can make use of alias command to create any alias with the following syntax.

$  alias  shortcommand=”your long command”

for example /var/www/html is  a directory where you store your code and you often need to cd to this path, you can create alias for this as follows.

$  alias  wr=”cd /var/www/html”

custom-alias
custom-alias

But there is a problem with approach alias created this way it will only last for current session if you open new terminal session it will vanish. But there is a way to create permanent aliases.

Creating Permanent Aliases in Linux

To keep alias available for all sessions you can write the alias to users shell config profile file.

Bash – ~/.bashrc
ZSH – ~/.zshrc
Fish – ~/.config/fish/config.fish

The syntax to be used for creating permanent alias is same as for temporary one, the difference is that you will be saving the command in file this time. You can edit the file with your favorite editor.

$  vim  ~/.bashrc

You can add the aliases in the end of the file as follows:

alias  dev=”ssh ~/.ssh/pem-file.pem  admin@192.168.1.133″
alias wr=”cd /var/www/html”

Save the file and these aliases will be available in all your future sessions.

If you want these to become available for current session as well run following command.

$  source  ~/.bashrc

To remove an alias that was added using command line you can use unalias command.

$  unalias  alias_name
$  unalias  -a     (removes all alias)

Alias is a very useful feature it saves you time and keep from writing or remembering long command. Feel free to provide feedback and Let us know in the comments section how did you make use of alias.

2,556 Replies to “How to Create and Use Alias in Linux”

  1. Good day! tecpenguin.com

    We suggesting

    Sending your commercial offer through the feedback form which can be found on the sites in the Communication section. Contact form are filled in by our application and the captcha is solved. The superiority of this method is that messages sent through feedback forms are whitelisted. This method raise the chances that your message will be open.

    Our database contains more than 25 million sites around the world to which we can send your message.

    The cost of one million messages 49 USD

    FREE TEST mailing of 50,000 messages to any country of your choice.

    This message is automatically generated to use our contacts for communication.

    Contact us.
    Telegram – @FeedbackFormEU
    Skype FeedbackForm2019
    Email – FeedbackForm@make-success.com
    WhatsApp – +44 7598 509161

  2. Good day,

    I am reaching out to you based on a request from a profiled client who is looking for a potential investment opportunity within your scope of business .

    Details of investment proposal will be sent out to you on reading back from you as we deem it necessary to seek for your consent prior to any formal exchange of material information relating to the Subject matter .

    I look forward to your earliest response , please do contact me directly only via my private email address stated below .

    Kind Regards,

    Anthony Russell
    Managing Partner
    Tel Line: +447440934362
    Email : anthonyrussell@deximinvestmentsolutionsukltd.com

  3. The cleaning firm accomplishes cleaning of rooms of various sizes as well as setups.

    The company’s experts offer cleaning with the aid of modern-day technologies, have special devices, as well as also have certified detergents in their collection. In addition to the above advantages, white wines offer: desirable rates; cleansing in a short time; high quality results; more than 100 favorable reviews. Cleaning up offices will assist maintain your work environment in order for the most productive job. Any kind of company is exceptionally essential environment in the team. Cleaning up services that can be gotten inexpensively now can assist to prepare it and also offer a comfy space for labor.

    If needed, we leave cleansing the kitchen area 2-3 hours after placing the order. You get cleaning immediately.

    We provide specialist find a maid service for exclusive customers. Utilizing European equipment and licensed tools, we accomplish optimal results and give cleaning quickly.

    We offer discounts for those that use the service for the very first time, as well as desirable terms of collaboration for routine consumers.

    Our pleasant group supplies you to get familiarized with beneficial terms of participation for company clients. We properly approach our tasks, clean using professional cleaning products and customized equipment. Our staff members are trained, have medical publications as well as recognize with the nuances of eliminating complicated and also hard-to-remove dirt from surfaces.

    We supply high-quality cleaning for big enterprises and small firms of different directions, with a discount of up to 25%.

  4. Предположим, вы хозяин нового сайта, который имеет приятный стиль, удобную навигацию и полезную для клиентов рекламную информацию. Но на интернет-проект ни кто не заходит. Что делать? Если у вас есть собственный бизнес мы поможем вам создать веб портал. Не тайна, ни одно действительное или виртуальное предприятие не может продвигаться независимо. Любой фирме необходимо помощь в приобретении известности, а во Всемирной сети без нее безусловно не обойтись из-за бешеной конкуренции.Мы занимаемся разработкой веб-сайта. Здесь мы готовы запустить полноценный интернет-проект в течение 5 дней. Выключая предоставления полных веб-сайтов, мы предоставляем сервис тех. сопровождения: уместное продление хостинга и нового домена, добавление контента на интернет-сайт, размещения новостей. Наши услуги посодействуют вам стать фаворитом на горизонтах сети интернета.

    Как продвигать в буржунете