[Linux] "ll" is not a command

table of contents
Hello everyone.
I'm Naka, a member of the System Solutions Department, and I can't feel at ease without a blanket under my tummy, even on a hot day.
Those who build and operate infrastructure environments will likely have many opportunities to use Linux.
*Of course, Unix-only and Windows-only environments also exist.
Of these, I think the most commonly used command is the "ls" command, which is used to check a list of files, but
I think many people also use "ll" as a superior version of the "ls" command.
In this article, we
will explain that "ll" is not a command, and there are times when it cannot be used, so it is better to have some idea of what it is!"
This article takes the stance that "It's not a big deal, but there are some people who don't know about it, so I'd like to explain it."
Execution environment
[For explanation
] Linux environment group
"OS: Ubuntu 20.04.5 LTS (WSL2 environment)"
Shell: Bash
Locale changed to Japanese
"OS:CentOS7.9(2009) (WSL2 environment)"
・Shell:Bash
[Side note]
●Windows environment
・OS: Windows 11 (version: 21H2)
・Shell: Command Prompt
・Language setting changed to Japanese
"ll" is "generally" an "alias" for "ls -l"
"ll" is not a command, but an "alias" that is registered and defined as an alternative name for a specific command, like a shortcut
I believe it is generally recognized and used as a shortened version of "ls -l"
Check with the alias command
A brief explanation of the alias command
a built-in command for the Bash shell, used to temporarily register an "alias .
Because it is not a Linux command, be aware that in other shells, there may not be an equivalent command or the behavior may be different.
*This is only temporary and will disappear when you restart the computer, so if you want to register it permanently, you will need to write it in the shell configuration file
If you enter this command without any arguments, you can see the currently set "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'
As you can see, in the default state of CentOS7, "ll" refers to "ls -l --color=auto"
In recent popular distributions, "ll" is often set as the default from the beginning.
This can lead to confusion, but it is good to know that it is an "alias" and not a "command".
Why it's good to be aware of these details
A1. Depending on the production environment, "alias" may not be set
There are some environments where no "alias" is registered at all
, perhaps out of concern that setting an "alias" may cause commands that the operator does not expect to be executed *In fact, depending on the distribution and version, no "alias" may be registered by default.
It can be a hassle if you don't know the commands and options you normally use, and
it seems that some people get confused because they don't know that "ll" is an "alias" and can't use it, so it's a good idea to remember it.
A2. There are some things that cannot be written in the work procedure manual
The etiquette for writing work procedures will vary depending on the culture of each company and the operational rules at the site, but
in general, just as you would avoid writing relative paths, you would probably not use aliases set with "alias."
It goes without saying that relative paths are particularly prone to causing major accidents when using the "rm" command
The presence or absence of "alias" settings varies depending on the environment, and the default content also differs depending on the distribution, so it is safer to avoid using it as a common language in instruction manuals
A3. Even if there are no rules, you may be warned
This is similar to the answer to A2. When I was a very new employee, I wrote "ll" in a procedure manual and was told by my superior at the time, "That's an alias, so stop using it in the procedure manual."
Some people think that this is not possible due to cultural and customary reasons
However, this article does not say that you should never use it, but rather takes the stance that "you should be aware that it is an alias whose meaning changes depending on the environment."
The definitions registered vary depending on the distribution
I wrote that it is best to avoid using it as a common language in procedure manuals, 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 this until I researched it while writing this article, but
as mentioned above, in Ubuntu 20.04.5 LTS it is "ls -alF", which displays hidden files with "-a" and type identifiers with "-F".
So, if you are in an environment where you only use this distribution and are so familiar with "ll" that you don't know it's an alias,
when you access another server you might find yourself frustrated because you can't find hidden files when using "ll" without the "-a" and "-F" options.
In reality, the "ll" itself does not have a great influence, but it is an analogy that suggests that "it is better not to use uncertain things in procedure manuals."
Aside: Aliases in Windows PowerShell
Aliases exist not only in Linux, but also in Windows PowerShell, and by default they are configured to allow the use of common UNIX commands
UNIX command/PowerShell cmdlet
cd → Set-Location
ls → Get-ChildItemReferences: https://learn.microsoft.com/ja-jp/powershell/scripting/learn/shell/using-aliases?view=powershell-7.4
When you type cd as shown above, the corresponding PowerShell cmdlet "Set-Location" will be executed
*Please note that in PowerShell, commands are called "cmdlets" rather than "commands."
summary
That's all.
The author is not an "ll" police officer, but rather came up with the idea of this article when he reflected on himself and thought, "There are things you don't notice when you use them on a daily basis," and "I should think about the things I use on
a daily basis."
Every command has surprisingly useful options and
can be used in unexpected ways, so it might be interesting to take a look at various commands using "ll" as an opportunity.
This is a long post, but thank you for reading this far!
Reference materials
alias(1p) - Arch manual pages (Archwiki)
https://man.archlinux.org/man/core/man-pages/alias.1p.en
Using Aliases (Microsoft: PowerShell Official Documentation)
https://learn.microsoft.com/ja-jp/powershell/scripting/learn/shell/using-aliases?view=powershell-7.4
22