Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
1  
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 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 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 at 7:30

3 Answers 3

up vote 12 down vote accepted

In most system, ll is an alias of ls -l:

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

They are the same.

share|improve this answer

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.

share|improve this answer
    
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 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. –  edvinas.me Jun 18 at 7:02

And in most cases 'll' does not work in shell scripts.

share|improve this answer
    
Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. –  cuonglm Jun 18 at 7:49
    
What happens is that typically commands like ll are really aliases, that aren't defined when running scripts. –  vonbrand Jun 18 at 7:57
    
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 at 9:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.