In this tutorial, we will show you how to create bash aliases on a Linux VPS running Ubuntu 16.04 as an operating system. In general, a Bash alias is simply a keyboard shortcut, an abbreviation, a means of avoiding typing a long command line command sequence. Follow the tutorial below and you should be able to create bash aliases in few minutes.
Table of Contents
1. Create a Bash Alias
Creating and using bash aliases is very useful. Aliases can be defined directly on the command line, or in .bash_profile, or you can specify user-defined aliases to the ~/.bashrc file. The syntax of creating a bash alias is the following:
alias name='unix command /with some options/parameters'
2. create aliases permanently
If you want to create aliases permanently, edit the ~.bashrc file, add the aliases at the end of the file and save it.
The changes in .bashrc would be active after you log out and log back in, or you can use the following command to source the file and enable newly created aliases instantly:
source ~/.bashrc
Alias examples
3. List All Files
To list all files, including hidden files (i.e. starting with .), using a long listing format and append indicator (one of */=>@|) to entries, set the following alias:
Change the default output of the ‘df’ command and print sizes in powers of 1024:
alias df='df -h'
10. Change the Default Output of the ‘ping’ Command
Change the default output of the ‘ping’ command and stop after sending 4 ECHO_REQUEST packets:
alias ping='ping -c 4'
11. Remove Alias
Removing aliases is as simple as adding them. To unset a specific alias, use:
# unalias lh
# lh
-bash: lh: command not found
12. Unset all aliases
To unset all aliases, use the following command:
# unalias -a
Of course, you don’t have to create bash aliases if you use one of our managed VPS hosting plans, in which case you can simply ask our expert Linux admins to create bash aliases for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to create bash aliases, please share it with your friends on the social networks using the buttons or simply leave a reply below. Thanks.
Good post, kudos