[Linux] "ll" is not a command

table of contents
Hello everyone.
This is Naka from the Systems Solutions Department, and even on hot days, I can't feel at ease without a blanket under my stomach.
Those who build and operate infrastructure environments will likely have many opportunities to work with Linux.
(Of course, Unix and Windows-only environments also exist.)
Among them, I think the most frequently used command is probably the "ls" command for listing files, but I
also think many people use "ll" as a more advanced alternative to the "ls" command.
This article explains that
"ll" isn't a command, and it's good to know what it is to some extent, as it can't always be used!
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
[For 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
shell, used to temporarily register an "alias."a built-in command in the Bashis
Since it's not a Linux command, be aware that a similar command may not exist or its behavior may differ in other shells.
*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 most modern distributions, "ll" is often set as the default.
This can sometimes lead to misunderstandings, but it's important to remember that it's 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
, perhaps due to concerns that an unexpected command might be executed if an alias is set
In some environments, no aliases are registered at all
*Note that in some distributions and versions, aliases may not be registered by default.
It's problematic if you get stuck because you're not familiar with the commands and options you normally use, and
it seems that some people get confused when they can't use "ll" because they don't know it's an "alias," so it's a good idea to remember it.
A2. There are some things that cannot be written in the work procedure manual
While the best practices for work procedure manuals may vary depending on each company's culture and on-site operational rules, it's
generally common to avoid using relative paths and to avoid using 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 for this article, but
as mentioned above, in Ubuntu 20.04.5 LTS, the command is "ls -alF", with "-a" indicating hidden files and "-F" indicating type identifiers.
Therefore, if you're only using this distribution and you've become too accustomed to using "ll" without realizing it's an alias, you
might encounter problems when working with a different server, such as not being able to see hidden files because you're 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 commands/PowerShell cmdlets:
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
I'm not exactly an "ll" police officer, but rather, I came up with this topic when I reflected on myself and thought, "There are things you don't notice when you use them regularly," and "Let's think about the things we use
every day."
Every command has surprisingly useful options and
unexpected uses, so it might be interesting for everyone to take a closer look at them, starting with "ll".
This was 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
24
