Many of you may use “ll” instead of the “ls” command.
In this article, I’m going to explain what “ll” is and what you should know about it.
・Linux Environment Group
“OS: Ubuntu 20.04.5 LTS (WSL2 environment)”
・Change the locale to Japanese
“OS: CentOS7.9(2009) (WSL2 environment)”
・OS: Windows11 (version:21H2)
・Shell: Command prompt
・Change the language to Japanese
ll is basically "alias" of ls -l
The "ll" is not a command, it’s an "alias" registered and defined as an alias for a specific command, it’s like a shortcut.
I think it is generally known and used as a shortened version of "ls -l".
Check using the alias command
I’m going to do a quick explanation of the alias command.
This is a built-in command of the Bash shell, which is used to temporarily register "aliases".
Note that this is not a Linux command, so the same name may not exist or may behave differently in different shells.
*It is only temporary and will disappear after rebooting, so if you want to keep the registration permanently, you need to write it in the shell configuration file.
If you enter the alias command without arguments, you will see the current setting of “alias”.
●CentOS7.9(2009) $ alias alias cp='cp -i' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
Just like the above, “ll” refers to “ls -l –color=auto”.
“ll” is set by default in most common distributions these days.
This is why people misunderstand “ll” as a command. It is good to be aware that it is an "alias".
The reasons why you should aware of this
The ”alias” might not be set in some production environments.
There are some environments where no “alias” is set at all, perhaps they are concerned that setting “alias” might cause commands to be executed in unexpected ways.
*There are some cases that have no default settings depending on the distributions and versions.
You don’t want to spend a lot of time and effort because you don't know the commands and options that you normally use in such cases. In addition, it is also possible that you might get confused if you didn’t know that “ll” is an “alias” that cannot be used in some cases.
2. There are cases that cannot be written in the instruction of work
The rules in writing work manuals may be depending on the company and each team, but in general, as well as relative paths should not be used, aliases should not be used.
Relative paths, in particular, can be the major cause of an accident when using the “rm” command,
Since “alias” may or may not be set depending on the environment, and the default contents are different depending on the distribution, it is safe to avoid using “alias” as a common language in work manuals.
3. There are might not be rules but you maybe get warned
This is similar to the answer above, but when I was a newbie, I used “ll” in a work manual and my manager warned me “This is an alias, you shouldn’t use it in the manual”.
Some people think it is “taboo” to use in terms of the situation.
However, the stance of this article is not to tell you that you should never use “ll”, but rather “be aware that the meaning of alias changes depending on the environment”.
The registered definitions are different depending on distributions
I said that “It is safe to avoid using it in manuals as a common language.” because there are cases where the definitions are literally different.
●Ubuntu 20.04.5 LTS $ alias | grep ll alias ll='ls -alF'
●CentOS7.9(2009) $ alias | grep ll alias ll='ls -l --color=auto'
I didn’t know until I wrote this article, but as shown above, in ubuntu 20.04.5 LTS is “ls -alF”, which shows “-a” hidden files and “-F” type identifiers.
Therefore, if you are in an environment where you only use this distribution and are too familiar with “ll” without knowing that this is an alias, for example, when you use another server, you may be get confused like “there’s no hidden file…” when you use “ll” that has no “-a” and “-F” options.
In fact, “ll” itself does not have much effect, but it is an example of “it is better not to use something uncertain in manuals”.
Aside: Alias in Windows PowerShell
Alias can be used in not only Linux but also in Windows PowerShell, which is commonly used in UNIX commands as a default.
UNIX command/PowerShell cmdlet cd → Set-Location ls → Get-ChildItem
As shown above, if you type cd in PowerShell, it executes cmdlet “Set-Location”.
*Please note that it’s called “cmdlet” in PowerShell.
Sometimes we are using it without knowing what it actually is, it’s important to think about what we are usually using.
Maybe there are more useful commands and options that you may not know. It’d be fun to discover them!
This blog post is translated from a blog post written by Naka Tomo on our Japanese website Beyond Co..