Linux Alias Command: How to Create and Use It?

February 26, 2022

Linux users may need to use the same command repeatedly. Where You can lose focus on what you are doing by typing or copying the same command. in this tutorial I will show you the best way in How to Create and Use Linux Alias Command.

So, To avoid such scenarios, it is possible to save time and create aliases for your numerous utilized commands. Aliases can be used as shortcuts that allow you to specify a command or set of commands, with or without any custom options.
What you’re waiting for to save your effort and time? You can start now by using aliases in your Linux system. So, in this tutorial, I will show you how to create and use the Alias Command step By step. Let’s go now! 

Check out the List of Currently Defined Aliases for Linux

Whether you use a command line interface or a shell script, you can modify Unix-style shell commands by creating aliases. For more information, check out the list of Currently Defined Aliases for Linux. This will show you the names of commands and the aliases they use

Execute alias to see a list with defined aliases for your profile.

This page shows the default aliases that Centos 7 has created for you.

As we can see while we execute ll command


It is equivalent to running ls -alF Command

ls -alF

An alias can be created with one equivalent character to the command you choose.

How to create aliases in Linux? | Linux Alias Command

aliases is a basic command that allows you to substitute a different command with a similar name. Aliases are useful for logging into remote servers and launching applications, but they can also be used to make files accessible on the local machine. Here are a few examples of aliases in Linux. Using an alias to run a command, for example, “ls -color auto” in Ubuntu, is a great way to make this command even easier to access.

So, It is easy to create aliases. There are two types of aliases : temporary ones and permanent ones.
In this tutorial, we will review Both types.

How to Create Temporary Aliases

In this section, we will learn how to create temporary aliases on Linux. You can also use alias to fix misspellings when you are typing commands. The alias command will automatically correct the spelling of the commands you type. Alias is a very powerful command combo. You can use it to change the name of an existing file on your computer users. 

You will need to type alias and enter the name you want to use to execute the command. The “=” sign should be followed by the command you wish alias.

Here is the syntax

$ alias shortName="your custom command here"

Here’s an example:

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

To go to the webroot directory, you can use “wr” shortcut. This alias will only work for the current terminal session.
The alias will not be displayed if you open a new terminal session. A permanent alias is required if you want to save your aliases across sessions.

How to create Permanent Aliases

creating a Permanent Aliases in Bash is easy if you follow a few simple steps. First, add the alias you wish to use to your.bashrc file. Once the file is created, it will automatically be run when the system reboots. Then, you can add another alias to it. Repeat these steps for each alias you wish to use.

You can save aliases in your shell configuration profile file to keep them between sessions. You can do this by:

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

You can use the same syntax as when creating temporary aliases. This is because you will be saving it as a file. You can use bash to open .bashrc files with your favorite editor, such as this:

$ vim ~/.bashrc

You will need to locate a location in your file where you want the aliases to be kept. You can also add them at the end of your file. You can add comments to your aliases for organizations.

#My custom aliases
alias home=”ssh -i ~/.ssh/mykep.pem [root@host ~]
alias ll="ls -alF"

Save the file. This file will automatically be loaded in the next session. The following command can be used to activate the alias you have just created in the current session:

$ source ~/.bashrc

You can remove an alias that was added to the command line by using the unalias command.

$ unalias alias_name
$ unalias -a [remove all alias]


This is a quick example of creating an alias to execute commonly used commands without repeatedly typing each command. You can now think about which commands you use most often and create shortcuts in your shell for them.

The right decision!
If you're ready to make an impact in your business, it's time to get started now! Discover our offers and make the right decision!
Get Started Now!
payment gateway method for lgvps company
payment gateway method for lgvps company
Stripe paypal method for lgvps
A BeinCart LLC Company
Copyright © 2022 BeinCart LLC | Designed by LGVPS Team