[Linux] "ll" is not a command
table of contents
Hello everyone.
I belong to the System Solutions Department, and even on a hot day, I can't feel at ease without a futon on my stomach.
I think people who build and operate infrastructure environments have a high chance of using Linux.
*Of course, Unix and Windows-only environments also exist.
Among them, I think the most used command is the "ls" command to check a list of files, but
I think many people also use "ll" as an upward compatible version of the "ls" command. .
In this article,
"ll" is not a command, and there are some things you can't use, so it's better to know what it is! ”
This is an article with the stance of ``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
Change locale to Japanese
"OS:CentOS7.9(2009) (WSL2 environment)"
・Shell:Bash
[For digression]
●Windows environment
・OS: Windows11 (version:21H2)
・Shell: Command prompt
・Change language settings to Japanese
"ll" is "generally" "alias" for "ls -l"
"ll" is not a command, but something called "alias", which is registered and defined as an alias for a specific command; for example, it is a shortcut.
I think it is generally recognized and used as a shortened version of "ls -l".
Check with alias command
Let's briefly explain the alias command.
This is used to temporarily register an "alias" and a built-in command of the Bash .
Please note that this is not a Linux command, so if you are using a different shell, something with the same name may not exist or the behavior may be different.
*This is only temporary and will disappear when you restart, so if you want to register it permanently, you need to write it to the shell configuration file.
If you enter this command without arguments, you can check the currently configured 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 common distributions, "ll" is often set as the default.
Because of this, it is sometimes misunderstood, but I think it is good to be aware that it is not a "command" but an "alias".
Why it's good to be aware of such details
A1.Depending on the production environment, "alias" may not be set.
There may be environments in which no "alias" is registered at all, perhaps due to concerns that a
command that the operator does not expect may be executed if an "alias" is set *In the first place, it may not be registered by default depending on the distribution or version.
It's a problem if it takes time because you don't know the commands and options that you normally use, and
there are people who sometimes get confused because they can't use "ll" without knowing that "ll" is "alias". It's a good idea to keep it.
A2. There are things that cannot be written in the work procedure manual.
Etiquette in work procedure manuals may vary depending on the culture of each company and operational rules at the workplace, but
in general, it is common to avoid writing relative paths, and to avoid writing them using aliases. I think most people don't use aliases.
It goes without saying that relative paths in particular tend to cause major accidents when using the "rm" command, but
The presence or absence of "alias" settings differs depending on the environment, and the default contents differ depending on the distribution, so it is best to avoid using it as a common language in procedure manuals.
A3. Even if there are no rules, there are things you should be careful about.
This is similar to the answer to A2. When I was a newbie, I wrote "ll" in a procedure manual, and my superior at the time warned me, "It's an alias, so don't use it in procedure manuals." there is.
There are some people who think that this is not the case due to cultural and customary reasons.
However, this article does not say that you should never use it, but rather that you should be aware that it is an alias whose meaning changes depending on the environment.
The registered definitions differ depending on the distribution.
I wrote, ``It is best to avoid using it as a common language in procedure manuals.'' This is because there are literally cases where the definition is 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 this article, but
as mentioned above, in ubuntu 20.04.5 LTS, "ls -alF" displays "-a" hidden files and "-F" type identifiers. It looks like this.
Therefore, in an environment where only this distribution is used, for example, if you are too familiar with "ll" without knowing that it is an alias,
when you touch another server, you will see "ll" without the "-a" and "-F" options. You may be worried that "hidden files are missing" when using ".
Actually, ``ll'' itself does not have a big influence, but it is an analogy that can be said to be ``it is better not to use uncertain things in procedure manuals.''
Side note: alias in Windows PowerShell
Alias exists not only in Linux but also in Windows PowerShell, and by default it is set so that general UNIX commands can be used.
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
As shown above, when you hit cd, the corresponding cmdlet "Set-Location" is executed in PowerShell.
*Please note that in PowerShell, this is called a "cmdlet" rather than a "command."
summary
That's all.
the content of this article came to me when I reflected on myself and thought, ` `There are things that I don't notice when I use them on a regular basis,'' and ``Let's think about the things I use on a regular basis.''
All commands have surprisingly useful options and
can be used in unexpected ways, so it might be interesting for you to use ``ll'' as an opportunity to review various ways.
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