# Linux commands: alias

> Learn how the Linux alias command creates a shortcut for another command, like alias ll for ls -al, and how to make your aliases permanent in .bashrc.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-09-11 | Topics: [CLI](https://flaviocopes.com/tags/cli/) | Canonical: https://flaviocopes.com/linux-command-alias/

It's common to always run a program with a set of options you like using.

For example, take the `ls` command. By default it prints very little information:

![Terminal showing ls command output with just words.txt filename displayed](https://flaviocopes.com/images/linux-command-alias/Screen_Shot_2020-09-03_at_15.21.00.png)

while using the `-al` option it will print something more useful, including the file modification date, the size, the owner, and the permissions, also listing hidden files (files starting with a `.`:

![Terminal showing ls -al output with detailed file permissions, owner, size and modification date for words.txt](https://flaviocopes.com/images/linux-command-alias/Screen_Shot_2020-09-03_at_15.21.08.png)

You can create a new command, for example I like to call it `ll`, that is an alias to `ls -al`.

You do it in this way:

```bash
alias ll='ls -al'
```

Once you do, you can call `ll` just like it was a regular UNIX command:

![Terminal showing alias creation with alias ll equals ls -al and then using ll command to display detailed file listing](https://flaviocopes.com/images/linux-command-alias/Screen_Shot_2020-09-03_at_15.22.51.png)

Now calling `alias` without any option will list the aliases defined:

![Terminal showing alias command output displaying the defined alias ll equals ls -al](https://flaviocopes.com/images/linux-command-alias/Screen_Shot_2020-09-03_at_15.30.19.png)

The alias will work until the terminal session is closed.

To make it permanent, you need to add it to the shell configuration, which could be `~/.bashrc` or `~/.profile` or `~/.bash_profile` if you use the Bash shell, depending on the use case.

Be careful with quotes if you have variables in the command: using double quotes the variable is resolved at definition time, using single quotes it's resolved at invocation time. Those 2 are different:

```bash
alias lsthis="ls $PWD"
alias lscurrent='ls $PWD'
```

\$PWD refers to the current folder the shell is into. If you now navigate away to a new folder, `lscurrent` lists the files in the new folder, `lsthis` still lists the files in the folder you were when you defined the alias.

> The `alias` command works on Linux, macOS, WSL, and anywhere you have a UNIX environment
