Defining a shortcut with the alias command in Linux
In the Linux command line, you can define abbreviations for commands that you use frequently and that are long to type. Thanks to the abbreviation you define, you shorten long commands and save time. In this article, the use of the alias command and creating abbreviations will be explained.
Categories:
2 minute read
In the Linux command line, you can define abbreviations for commands that you use frequently and that are long to type. Thanks to the abbreviation you define, you shorten long commands and save time. In this article, the use of the alias command and creating abbreviations will be explained.
alias uptodate='sudo apt update && sudo apt upgrade'```
Thanks to the update command given above, a long command has been converted into an abbreviation of uptodate. It is possible to multiply these examples. For example, let's shorten the systemctl command to view the services running on our system.
```bash
alias active_services='systemctl --type=service --state=running'```
You need to make these commands and similar ones permanent. If you want to use alias abbreviations when your system restarts, you must create a file named .bash_aliases in the home folder. You can add any abbreviations you want into this file, one command per line. Below is the screenshot of the file we created.
```bash
nano .bash_aliases
In this way, your working speed on the command line will increase significantly.