What is the difference between ls and l?

50,879

Solution 1

SHORT ANSWER: understand what exactly this alias does, you can check out the ~/.bashrc file and search for the term "alias l=". It is nothing but ls -CF

LONG ANSWER A good way to inspect what a command is:

type l

If it's a program or a script, it will give you its location, if it is an alias, it will tell you what it's aliased to, if it's a function, it will print the funciton; otherwise, it will tell you if it is a built-in or a keyword.

Examples:

$ type l
l is aliased to `ls -CF'
$ type find
find is /usr/bin/find
$ type connecthome
connecthome is hashed (/usr/local/bin/connecthome)
$ type grep
grep is aliased to `grep --color=auto --binary-files=without-match --devices=skip'
$ type hello_se
hello_se is a function
hello_se () 
{ 
  echo 'Hello, Stack Exchangers!'
}
$ type type
type is a shell builtin
$ type for
for is a shell keyword
$ type nosuchthing
-bash: type: nosuchthing: not found

Solution 2

$ l --help
l: command not found

Looks like you have an alias set up in your environment. Perhaps you have inherited a .profile, .bashrc or similar containing something like alias l='ls -F'.

-F, --classify
              append indicator (one of */=>@|) to entries

Try which l and alias to track down its definition.

Solution 3

FIXED: l is an alias for ls -CF ( I am not really sure ) in the default .bashrc in ubuntu

You can just type alias to check out all the aliases. It would be mentioned there.

Solution 4

I redefined all my ls shortcuts in my .zshrc.

This is the relevant section:

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    if [ -n ~/.dir_colors ]; then
        eval "`dircolors -b ~/.dir_colors`"
    else
        eval "`dircolors -b /etc/DIR_COLORS`"
    fi
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi

# some more ls aliases
alias l='ls -CF'
alias ll='ls -ClhF'
alias la='ls -CaF'
alias lla='ls -CalhF'
alias l.='ls -CAF --ignore=\*'
alias ll.='ls -CAlhF --ignore=\*'
alias t='tree -C'

Note that ls is redefined itself:

% type ls
ls is an alias for ls --color=auto

Solution 5

By default, it is an alias for ls -CF in ubuntu.

Share:
50,879

Related videos on Youtube

Rupert Madden-Abbott
Author by

Rupert Madden-Abbott

Updated on September 17, 2022

Comments

  • Rupert Madden-Abbott
    Rupert Madden-Abbott almost 2 years

    I accidentally typed l instead of ls today and found that the command still printed a list of the files in my current directory. Trying l --help brings up the help file for ls suggesting that l is just an alias of ls.

    Howver, each file was suffixed by a *. Why is this and what does it mean?

    In case it makes a difference, this is when running the latest stable version of Ubuntu.

    • AnneTheAgile
      AnneTheAgile over 9 years
      I came here after seeing the tweet, Unix commands turned into companies , twitter.com/valaafshar/status/540694808382431232 and 'l' doesn't work on my mac! lol
    • muru
      muru over 8 years
      @don_crissti the other one is broader, since it names about one more alias, and asks about more.
    • Admin
      Admin over 8 years
      @muru The other answer does not explain what the * in front of each file is.
    • muru
      muru over 8 years
      @BinaryZebra Considering the accepted answer here doesn't explain it either, I'm inclined to think it's a minor point. :shrug:
    • Admin
      Admin over 8 years
      Use type l to find what is l (if anything), the try alias l to see what is the alias of l.
    • Vthechamp
      Vthechamp over 3 years
      l was created so that you get (almost) the same output as ls when you are typing so fast and miss the last s :P
  • Eric
    Eric over 13 years
    Now that's a cool trick. I'll have to remember that one.
  • xenoterracide
    xenoterracide over 13 years
    ls -d that seems like the most useless alias ever. all that prints is .
  • Mark Norgren
    Mark Norgren over 13 years
    This command (A bash builtin) is very useful. I'm amazed that I've never seen it mentioned everywhere.
  • badp
    badp over 13 years
    -1: in Ubuntu 10.10 it's disabled (commented) by default, and it aliases to ls -CF.
  • Rohan Monga
    Rohan Monga over 13 years
    but it was there in previous versions. and yes, it was ls -CF, i just didn't have access to an older ubuntu machine to test it out.
  • johndpope
    johndpope almost 6 years
    You may like exa the.exa.website alias l='exa --long'