Open and edit your shell configuration file (usually ~/.bashrc for the default Bash shell, or ~/.zshrc if you are using Zsh) using nano editor:
nano ~/.bashrc
Scroll to the very bottom of the file and add your custom alias commands. For example, to map different PHP binary paths to short alias commands:
alias php83="/www/server/php/83/bin/php"alias php81="/www/server/php/81/bin/php"
Save the changes and exit the nano editor by pressing Ctrl + O, then Enter to save, and Ctrl + X to exit.
Apply the changes immediately to your current terminal session using the source command:
source ~/.bashrc
Verify that the aliases are working properly by running the commands to check their versions:
php83 -v
php81 -v
Note:
To view the list of all currently active aliases on your system, simply run the command alias.
If you want the alias to be available globally for all users on the server, add the alias lines to the /etc/bash.bashrc file instead of ~/.bashrc.
To temporarily bypass an alias and run the default or underlying system command, prepend a backslash before the command (example: \php83).
To temporarily disable an alias, use the unalias command (example: unalias php83). To remove it permanently, delete the alias line from ~/.bashrc and run source ~/.bashrc.
ADd Alias Command To Ubuntu | tutorials | Study Notes | Ferdyhape