A bash alias is a shorthand way to reference a longer command. Aliases can be created temporarily, but they will be lost when you log out or restart your computer. To create a permanent bash alias on Linux or Unix, follow these steps:
- Open your bash profile file: You can open your bash profile file using a text editor such as nano:
nano ~/.bash_profile
- Create the alias: In the bash profile file, add the following line to create a permanent alias:
alias [alias_name]=β[command_to_alias]β
Replace [alias_name]
with the name you want to give the alias, and [command_to_alias]
with the full command you want the alias to reference. For example, to create an alias for the ls -la
command, you would add the following line to your bash profile file:
alias ll=βls -laβ
- Save and close the file: Once you have added the alias to the bash profile file, save the file and close the text editor.
- Reload the bash profile: To use the new alias, you need to reload the bash profile. You can do this by running the following command:
source ~/.bash_profile
With these steps, you have created a permanent bash alias on Linux or Unix. The alias will be available in future sessions and will be automatically loaded every time you log in.