
Creating an alias for use on the command line can save the user from typing long commands, common options, or typos. This will save you some time and repetitive keystrokes, and ultimately make your command line experience even more efficient.
To create a permanent alias on Linux, you can add the alias command to the user’s shell startup file. The location and name of this file will depend on the shell you are using.
For Bash, the file is ~/.bashrc, and you can add an alias by adding the following line to the file:
alias <alias_name>='<command>’
alias web=’cd /var/www/html/’
For Zsh, the file is ~/.zshrc, and you can add an alias in the same way, using the alias command.
For fish shell, the file is ~/.config/fish/config.fish, and you can add an alias using the alias command.
Once you have added the alias to the appropriate file, you can either logout and login again or reload the shell config by executing source ~/.bashrc (for bash), source ~/.zshrc (for zsh), source ~/.config/fish/config.fish (for fish).
It will create a permanent alias and you will be able to use it in any new terminal session you open.
To check your configured aliases, along with the new one you just set, execute this command:
Command: alias -p
You may also read:
- How To Use chattr Command in Linux
- [Two Methods] Force Linux User to Change Password at Next Login
- Getting Started with Apache Solr on Ubuntu
- Understanding OpenSSL Commands – A Comprehensive Guide
- How To Check SSL Certificate Expiry Date from Certificate File
- How To Install Apache Tomcat on Ubuntu 22.04 LTS
- How To Compress Files Faster Using Pigz on Ubuntu Linux
- A Step-by-Step Guide to Setting up Nginx and SSL with Certbot
- Mastering Chage Command – Examples and Usage
- How to Save cURL Output to a File