To create an alias in your shell, you can use the alias command followed by the name you want to use for the alias and the command it should execute. Here’s the general syntax:
alias alias_name='command_to_run'
Example
-
Open your terminal.
-
Create an alias. For example, to create an alias
llforls -la, you would type:alias ll='ls -la' -
Verify the alias. You can check if the alias was created successfully by typing:
alias -
Make it permanent (optional). If you want the alias to persist across terminal sessions, add the alias command to your shell's configuration file (like
~/.bashrcor~/.zshrc). Open the file in a text editor and add the alias line:echo "alias ll='ls -la'" >> ~/.bashrcThen, reload the configuration file with:
source ~/.bashrc
Now, you can use ll in your terminal to execute ls -la.
