With the first method you are not creating an alias, you are creating a symlink. Symlinks are short for symbolic links:
Symbolic links are files that act as
pointers to other files. [...] A
symbolic link is a special type of
file whose contents are a string that
is the pathname another file, the file
to which the link refers. In other
words, a symbolic link is a pointer to
another name, and not to an underlying
object.
Read more about symlinks here and here.
Only with the second method you are, in fact, creating an alias.
Aliases allow a string to be
substituted for a word when it is used
as the first word of a simple command.
The shell maintains a list of aliases
that may be set and unset with the
alias and unalias builtin commands
(see SHELL BUILTIN COMMANDS below).
The first word of each simple
command, if unquoted, is checked to
see if it has an alias. If so, that
word is replaced by the text of the
alias.
You can define an alias anywhere where you can type a command and have the shell (bash in this case) interpret it, however in order for the alias to be available in other shells it needs to be defined in a file that's interpreted by the shell on startup (shell startup, not computer startup).
For bash these are /etc/bash.bashrc
(system wide) and ~/.bashrc
. These files are interpreted when the shell starts in interactive mode (like when using Terminal
). I'm not going to mention the profile files because they serve a different purpose.
So, you want to add your aliases to ~/.bashrc
to have them available in every interactive shell.
The .bash_aliases
method accomplishes exactly the same thing as putting the aliases in ~/.bashrc
but has the added benefit of being easier to be parsed and manipulated by programs.
The . ~/.bash_aliases
means source (load) _~/.bash_aliases_
in the context of the currently running shell.
dir
and ls
are part of coreutils
and dir
is almost the same as ls
, just with different default options.
The GNU Core Utilities are the basic file, shell and text manipulation utilities of the GNU operating system. These are the core utilities which are expected to exist on every operating system.
info dir
says:
dir
is equivalent to ls -C -b
; that is, by default files are listed
in columns, sorted vertically, and special characters are represented
by backslash escape sequences.
Oh and there is also vdir
! info vdir
says:
vdir
is equivalent to ls -l -b
; that is, by default files are
listed in long format and special characters are represented by
backslash escape sequences.
Most likely dir
exists for backwards compatibility or due to historical reasons.
Best Answer
This is located in your
.bashrc
:By taking a look at the manual pages for the command
ls
, you can see what those two attributes accomplish together:-a
: do not ignore entries starting with.
.-l
: use a long listing format.So you can understand that
ls -l
would ignore any entry starting with.
. That's their only difference.EDIT:
Let me note, that, as commented, the
ll
alias differs from installation to installation. In case you are wondering what's yours, please open up a terminal and enter:This will show you how
ll
is set. You can then look up the additional attributes by typing: