71

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.

However, 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.

6
  • 1
    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 Jan 10, 2015 at 23:55
  • @don_crissti the other one is broader, since it names about one more alias, and asks about more.
    – muru
    Feb 17, 2016 at 18:14
  • @muru The other answer does not explain what the * in front of each file is.
    – user79743
    Feb 17, 2016 at 18:46
  • @BinaryZebra Considering the accepted answer here doesn't explain it either, I'm inclined to think it's a minor point. :shrug:
    – muru
    Feb 17, 2016 at 18:48
  • Use type l to find what is l (if anything), the try alias l to see what is the alias of l.
    – user79743
    Feb 17, 2016 at 18:49

5 Answers 5

112

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
3
  • 15
    Now that's a cool trick. I'll have to remember that one. Nov 26, 2010 at 6:15
  • 4
    This command (A bash builtin) is very useful. I'm amazed that I've never seen it mentioned everywhere. Nov 28, 2010 at 4:37
  • Excellent examples, I think you covered it thoroughly. Since I've seen people use type to check if a command is installed, I'll just mention here that it's possible for the hashed commands to be out of date, in which case type <binary-name> will return success for some time after <binary-name> has actually been deleted.
    – Wildcard
    Jan 6, 2016 at 5:40
9
$ 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.

1
  • 3
    specifically the * after a file name means that the file is executable
    – phunehehe
    Nov 26, 2010 at 2:27
5

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.

3
  • ls -d that seems like the most useless alias ever. all that prints is . Nov 28, 2010 at 0:48
  • 1
    -1: in Ubuntu 10.10 it's disabled (commented) by default, and it aliases to ls -CF.
    – badp
    Nov 28, 2010 at 15:10
  • 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. Nov 29, 2010 at 5:31
3

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
3
  • You may like exa the.exa.website alias l='exa --long'
    – johndpope
    Aug 30, 2018 at 15:51
  • @johndpope yeah, coming back to this after so many years, I did use exa (and now eza) every now and then, but only on my machines. Anything that isn't mine, I still just use ls with a bunch of aliases... ¦D
    – polemon
    Feb 4 at 13:58
  • created this the other day - wired to "lls" - good for me to visually highlight git repos that I've recently cloned chat.openai.com/share/654db02c-3a52-4056-9cde-d3f969b0802e
    – johndpope
    Feb 5 at 12:25
2

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

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