Can someone tell me what terminal command the alias ll
is for? All I can find online is many people saying that it is an alias for ls -l
or ls -la
or ls -ltr
. But that's simply wrong. The result looks different. Is there any way to locate ll
and look at its syntax?
5 Answers
You can use the alias
or type
commands to check what a specific alias means:
$ alias ll
alias ll='ls -alF'
$ type ll
ll is aliased to `ls -alF'
Note however that aliases might use other aliases, so you might have to check it recursively, e.g. in the case of ll
, you should also check the ls
command it calls:
$ alias ls
alias ls='ls --color=auto'
$ type ls
ls is aliased to `ls --color=auto'
So ll
actually means:
ls --color=auto -alF
-
11Note that in the general case, a command could have several simultaneous definitions.
type -a commandname
will reveal all - it will tell you if the command is one or more of an alias, function, builtin or one or more executable files in your PATH, in that order of precedence. This aids in understanding why, for example, unaliasing a command does not return it all the way to the expected behavior. May 9, 2018 at 21:06 -
2I'd recommend
alias ll='ls -lh'
. You can runls -l
if you want sizes in bytes instead of human-friendly B / kiB / MiB / GiB. May 10, 2018 at 17:58
ll
is an alias defined in your ~/.bashrc
, provided you didn't change it it's ls -alF
:
$ grep ll= <~/.bashrc
alias ll='ls -alF'
These three options are:
- -a, --all – do not ignore entries starting with .
- -l – use a long listing format
- -F, --classify – append indicator (one of */=>@|) to entries
As
$ grep ls= <~/.bashrc
alias ls='ls --color=auto'
shows, ls
itself is again an alias for ls --color=auto
:
With
--color=auto
,ls
emits color codes only when standard output is connected to a terminal. TheLS_COLORS
environment variable can change the settings. Use thedircolors
command to set it.
-
1Not necessarily .bashrc. If you use a different shell, it will be defined in the .rc file for that shell - ,cshrc, .tchshc, and so on.– jamesqfMay 9, 2018 at 18:18
-
@jamesqf I think someone who uses a different shell also knows which aliases are predefined in it – I took the question to be about the default Ubuntu setup, where
bash
is the default shell for users and the aliasll
is defined in/etc/skel/.bashrc
which is copied into every new user's home directory. Of course you could use any file to store your own aliases – all you need is source it.– dessertMay 9, 2018 at 18:25 -
2It's not necessary to redirect the file into
grep
, it will take the filename as an argument. While grepping startup files will help you find where the alias is (re)defined (note that it might be in a file in/etc
- knowing that will save you some head scratching if you remove it from the user startup file and it still persists or even changes its behavior), if you just want to quickly know what the definition is, the alias command, as noted in the accepted answer, will do the job. May 9, 2018 at 20:50 -
@DennisWilliamson It's not necessary to let
bash
open the file, but it's much better! The last sentence in the question post reads Is there any way to locatell
and look at its syntax?, that's what my answer answers.– dessertMay 9, 2018 at 21:11
You can look in your ~/.bashrc (or some file where your aliases are) or you can write some of these commands in your shell:
command -v ll # "command" is a shell built-in that display information about
# the command. Use the built-in "help command" to see the
# options.
type -p ll # "type" is another built-in that display information about how the
# command would be interpreted
grep -r "alias ll=" ~ # and don't worry about de .file that contains your
# alias. This command search recursively under each
# folder of your home. So it's something rude.
find ~ -maxdepth 1 -type f | xargs grep "alias ll" # Just look in
# the files (not folders) in your home folder
But why use find without the -name ".*" ? Cause you can put this in your .bashrc
source bash_hacks # where the file bash_hacks, in your home directory can
# contain the alias ll='ls -la etc etc'.
Since "ll" it's an alias, it's not necesary that have just one meaning (ll='ls -alF --color'), you can alias your "ll" like another comand like, i don't know, "rm". I think it's more a convention (product of common uses).
But "ll" could be a program stored in any folder of your PATH. For example, if you have a folder named "bin" in your home, make a "ll" script that contains something like
#!/bin/bash
ls -lhar
But, what if your PATH have been altered to add another folder that contains the new "ll" command? For more interesting information, you can consult the following link to a related question.
There is no need to parse ~/.bashrc or any other script. You can check your current values of all aliases typing alias
command in terminal. It will bring all defined aliases with their definitions onto your screen.
-
Hello and welcome to askubuntu. How is this answer adding something to the accepted one?– BruniMay 16, 2018 at 9:52
It should be ls -la
.
See Linuxize.com:
https://linuxize.com/post/how-to-create-bash-aliases/