I'm using Mac OS X. When I SSH into servers I find the
ll command useful, but it's not available on my local machine. How can I install it?
In OS X 10.9.5 since Mavericks (and at least up to El Capitan) you have to add an alias command to your .bash_profile file in your home folder:
which is equivalent to your user path at
To see that file in finder you have to activate the display of hidden files (e.g. using the app InVisible). Otherwise you can simply use your terminal to locate it and edit it with nano:
Then add an alias command to the end of that file. The standard ll alias would be
alias ll='ls -lG'
but I prefer
alias ll='ls -lGaf'
which also shows all hidden files (starting with a dot) and sorts the output case-insensitive.
Don't forget to restart your terminal app after the changes.
type ll to see where the
ll command is coming from.
ll is not a standard command, but many distributions predefine it to an alias for
ls with some preset options. The output of
type ll gives you the definition of the alias, or you can look for it in your shell configuration file (
~/.bashrc if your shell is bash). Copy the definition to
~/.bashrc on the other machine.
Bash handles its configuration file in a slightly odd way: it loads
~/.bashrc in all interactive shells except the ones that are also login shells. Bash only loads
~/.bash_profile (if it exists, otherwise
~/.profile) in a login shell. To make sure that your
.bashrc is read when it should be, put this line in your
case $- in *i*) . ~/.bashrc;; esac
(MacOS Mojave Example)
Open the hidden
.bash_profilefile in the Vim editor:
Jump to the last character of the file by pressing capital G and then $.
Press o to add a new line to the file.
Insert your new alias like:
alias ll='ls -lG'
Press Esc to exit insert mode of Vim.
Type following to write your new changes and exit the editor:
Reopen terminal and you should be able to use the alias
One thing that is missing from several answers is that this is shell-dependent. If you're using the system default shell on 10.14 on below, which is bash, then references to (.)bash_profile are correct. Modifying /etc/profile would create the alias for sh for all users (but not in bash).
If you have switched, for example, to zsh, then making a system-wide change requires adding the alias to /etc/zprofile. If you wanted to make the change for only your user, then you could add it to ~/.zprofile
On macOS Catalina:
echo "alias ll='ls -la'" >> ~/.zshrc
Don't forget to close and reopen Terminal after that.
As it's explained in article:
Apple has changed the default shell to zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile.
The difference between .bash_profile and .bashrc explained in article.