As a developer or a frequent command line user such as DevOps Engineer, you might find yourself repeatedly typing the same lengthy commands. This can be tedious and time-consuming. Luckily, there’s a solution to this problem that can save you a lot of time – Bashrc Alias. In this article, we’ll discuss what Bashrc Alias is and how it can help you simplify your command line tasks.
What is Bashrc Alias?
Bashrc Alias is a way to create shortcuts for your most commonly used commands in the terminal. These shortcuts are created by adding a line of code to the .bashrc file in your home directory. When you create an alias, you’re essentially creating a new command that will execute a more extended command that you specify.
For example, if you frequently use the command “ls -la” to see a detailed list of files in a directory, you can create an alias called “ll” that will execute the “ls -la” command. So, instead of typing “ls -la” every time you want to see a detailed list of files, you can type “ll“.
How to Create an Alias in Bashrc?
To create an alias in Bashrc, you can follow these steps:
- Open your terminal and type
cdto go to your home directory.
nano .bashrcto open the .bashrc file in the nano text editor.
- Scroll to the bottom of the file and add a new line for your alias. The syntax for creating an alias is
alias short_command='long_command'. For example,
alias ll='ls -la'.
- Save and exit the file by pressing
CTRL + X, then
Y, and then
- To activate the new alias, restart your terminal or execute the command.
Bashrc Alias is a powerful tool that can help you simplify your command line tasks and save you a lot of time. By creating aliases for your most commonly used commands, you can reduce the typing you must do and make your workflow more efficient. So, next time you find yourself repeatedly typing the same lengthy command, consider creating an alias in your .bashrc file.