102

I'm relatively new to programming as a whole and some tutorials have been telling me to use ls -l to look at files in a directory and others have been saying ll. I know that ls is a short list, but is there a difference between the other two?

4
  • 15
    You may want to take a look at which ll. You will probably discover that ll is actually an alias for ls -l.
    – HalosGhost
    Jun 17, 2014 at 23:04
  • So then what is the difference between ls any other command I put into the shell? If I type which ls I get alias ls='ls --color=auto' /bin/ls, but if I type (for example) which cd I get /usr/bin/which: no cd in (........). EDIT: I tried it again with which mkdir and I got /bin/mkdir. What is the distinction between these commands that some of them are stored(?) in /usr/bin and some are apparently not?
    – Jon
    Jun 18, 2014 at 21:45
  • this is an affect of your distro's default $PATH. ls is very often aliased, so your shell reports the alias (which takes precedence over the binary) and the binary's actual location (in your case, /bin/ls). If which could not find cd, then something appears terribly wrong.
    – HalosGhost
    Jun 20, 2014 at 7:30
  • 3
    cd is a shell builtin keyword, not a program found in a filesystem. Use type cd and type ls to see what I mean. Some commands are simply overriden by shell builtins: echo exists in /bin/echo, but in bash and in fact most of modern shells, a builtin echo function is called instead (which usually has extended features). type actually tells you which one it is.
    – orion
    Feb 4, 2015 at 10:00

6 Answers 6

137

On many systems, ll is an alias of ls -l:

$ type ll
ll is aliased to `ls -l'

They are the same.

9
  • 4
    ll is aliased to `ls -ltr' - I am using red hat 6
    – rdp
    May 27, 2015 at 14:51
  • 5
    in Ubuntu 14.04 ll is aliased to 'ls -alF'
    – Viktor
    Apr 12, 2016 at 3:15
  • 7
    Also ls -alF in Ubuntu 12.04, 16.04, and likely many more.
    – Paul
    Nov 5, 2016 at 16:58
  • 3
    For me on macOS Sierra ll is aliased to ls -lh
    – Zorgatone
    Apr 20, 2017 at 12:44
  • 1
    zsh: command not found: ll :(
    – Harinder
    Jan 10, 2020 at 22:33
20

As noted, ll is often defined as an alias of ls -l. In fact, ls is often an alias itself:

$ which ls
alias ls='ls --color=auto'
/usr/bin/ls

The actual command is ls which above is found in /usr/bin. ll is intended as a convenience, but you cannot rely on it being defined on all *nix systems, so it is good to know what it is really doing.

2
  • Great answer. I can't help by add that this is one of the reasons why relying on ls in automation (especially ad-hoc one-liners) is usually a bad idea. It has several options that change its output, and many ways to specify them. With different distributions choosing different defaults, it tends to lead to headaches.
    – ctt
    Jun 18, 2014 at 2:30
  • I haven't seen any popular distribution to alias ls to anything else than ls --color=auto. It's either that or there is no alias.
    – ek9
    Jun 18, 2014 at 7:02
10

Ubuntu 12.04, 14.04, 16.04, 18.04:

laike9m@laike9m1:~$ type ll
ll is aliased to `ls -alF'
2
  • 1
    Also 12.04 and 16.04, but that is all I have available to test right now.
    – Paul
    Nov 5, 2016 at 17:00
  • I can confirm also 18.04
    – Max Yudin
    Nov 20, 2019 at 9:21
4

In most cases, ll does not work in shell scripts.

4
  • 1
    What happens is that typically commands like ll are really aliases, that aren't defined when running scripts.
    – vonbrand
    Jun 18, 2014 at 7:57
  • 3
    Some people have the alias in the .profile, and the alias is working in an interactive shell. After debugging/testing a new script, the script suddenly fails in crontab. Cron does not read the .profile.
    – Walter A
    Jun 18, 2014 at 9:49
  • 1
    This is not an answer to the question, but should be a comment instead. From my little understanding, aliases are deprecated in shell scripts. Jan 23, 2016 at 20:21
  • I say "most" but it does not on mine, and i use ls -l Apr 27, 2017 at 16:26
2

ll is an alias for ls -l.

The option -l tells the command to use a long list format. It gives back several columns, not shown when the simple ls command is used. These columns include:

  • Permissions

  • Number of hardlinks

  • File owner

  • File group

  • File size

  • Modification

  • time

  • Filename

0

ll is actually aliased to `ls -l' If you run ll, then it will show you files in the shell then you to press Enter to see the next files (more.. option). If you run ls -l, then all files will be displayed at a time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .