Forrest logo
back to the echo tool

linux:alias:create:permanent

Create an alias and persist it.
$ echo 'alias ${alias_name}="${alias_command}"' >> ~/.bash_profile
try on your machine

This command creates a new alias in the Bash shell and saves it to the user's bash profile.

Here's how it works:

  • echo is a command that displays a message on the terminal. In this case, it will write a command to create an alias to the terminal.

  • alias is a command that defines a new alias in the Bash shell. Aliases are shortcuts for longer commands.

  • ${alias_name} and ${alias_command} are variables that will be replaced by the user with the desired name and command for the new alias.

  • The >> operator appends the output of the echo command to the end of the ~/.bash_profile file, which is the user's Bash profile. This will ensure that the new alias is saved and available each time the user starts a new Bash session.

For example, if a user wants to create an alias for the long command ls -la, they could use the following command:

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

This will add a new alias to the user's bash profile that allows them to use the shorthand ll instead of typing out the longer command each time.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the echo tool