Last Updated on December 23, 2018 by itsubuntu
Insight: Create Bash Aliases In Linux Operating System [ Beginner’s Guide]
It is tedious and boring to type a long command every-time or even more boring to search the history of typed command in the terminal. There is an easy solution for this and the solution is Bash Aliases.
You can set a shortcut command for the long command which you might need to execute regularly. In this tutorial we are going to show you the method to create bash aliases in Linux. We are trying to simplify this process.
Create Bash Aliases In Linux Operating System
Syntax is as follows:
Generally, You can create bash aliases for the current session or permanently until you delete it. You can easily create a temporary bash alias by typing alias keyword.
alias omg="cd /home/omgfoss/public_html"
Above command will create a simple bash alias named omg which will be a shortcut command for the cd /home/omgfoss/public_html command or process. What you have to remember is that this alias only last for the current shell session only.
If you want to create a bash alias for the long term then you need to declare it in the
~/.bashrc file. Let’s create a bash alias in the .bashrc file.
At first you need to open the
~/.bashrc in your text editor:
After opening the file, You can now add your preferred aliases:
alias turnoff='ifdown eth0' alias omg='cd /home/omgfoss/public_html'
There is no limitation in number of bash aliases that you can create in this file. Once done, You need to save and close the bashrc file. Run the following command to make it available in current session.
Let us know if there is any error in this tutorial post.
Leave a Comment