How to create an alias?

0135

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

  1. Open your terminal.

  2. Create an alias. For example, to create an alias ll for ls -la, you would type:

    alias ll='ls -la'
  3. Verify the alias. You can check if the alias was created successfully by typing:

    alias
  4. 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 ~/.bashrc or ~/.zshrc). Open the file in a text editor and add the alias line:

    echo "alias ll='ls -la'" >> ~/.bashrc

    Then, reload the configuration file with:

    source ~/.bashrc

Now, you can use ll in your terminal to execute ls -la.

0 Comments

no data
Be the first to share your comment!