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?
11 Answers
MacOS:
alias ll='ls -lG'
Linux:
alias ll='ls -l --color=auto'
Stick that in the appropriate startup file for your shell, e.g. ~/.bashrc or ~/.zshrc. To apply the setting, source the file, or quit and restart your terminal.
-
4Ah right, BSD ls doesn't support
--color.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2012-01-06 07:12:55 +00:00Commented Jan 6, 2012 at 7:12 -
9One more, I had to add the command
~/.profileinstead of~/.bashrcto make it work. Maybe this is Mac OS X specific.Eonil– Eonil2012-01-06 12:12:47 +00:00Commented Jan 6, 2012 at 12:12 -
9You need
alias ll='ls -lG'for the same effect in macosx.Burhan Khalid– Burhan Khalid2012-01-06 13:01:27 +00:00Commented Jan 6, 2012 at 13:01 -
8I needed to add
alias ll='ls -lG'to my ~/.bash_profile to make it work (in Lion, if that matters)jessica– jessica2012-07-28 01:58:32 +00:00Commented Jul 28, 2012 at 1:58 -
2Even lazier:
$ echo "alias ll='ls -lG'" >> ~/.bashrcAvishai– Avishai2014-03-06 21:28:56 +00:00Commented Mar 6, 2014 at 21:28
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:
~/.bash_profile
which is equivalent to your user path at
/Users/YOUR_USER_NAME/.bash_profile
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:
nano ~/.bash_profile
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.
-
12you don't need to restart the terminal, it is enough to use
source ~/.bash_profileto reload the new settingsAsped– Asped2016-08-26 09:38:06 +00:00Commented Aug 26, 2016 at 9:38
macOS with zsh shell should put
alias ll='ls -lG'
to ~/.zshrc instead of ~/.bash_profile nor ~/.bashrc
-
very good one. I like to use alias ll='ls -laG' So, the files size is displayed in MB, KB, etcxCovelus– xCovelus2023-02-15 21:09:49 +00:00Commented Feb 15, 2023 at 21:09
Run 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 ~/.bash_profile:
case $- in *i*) . ~/.bashrc;; esac
Run:
echo "alias ll='ls -la'" >> ~/.zshrc
Don't forget to close and reopen Terminal after that.
Add alias ll='ls -lG' to your ~/.profile with your favorite $EDITOR.
With this method, remember that you'll have to start a new terminal session (or source ~/.profile to be able to use ll).
If you want it to apply in all accounts, you can also put
alias ll='ls -lG'
in /etc/profile.
-
1Does OSX even have an
/etc?jasonwryan– jasonwryan2016-05-02 00:11:26 +00:00Commented May 2, 2016 at 0:11
To summarize the best of all answers:
Mac OS X (tested on El Capitan)
echo "alias ll='ls -lGaf'" >> ~/.bash_profile
source ~/.bash_profile
Linux
echo "alias ll='ls -la --color=auto'" >> ~/.bash_profile
source ~/.bash_profile
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
(MacOS Mojave Example)
Open the hidden
.bash_profilefile in the Vim editor:vim ~/.bash_profileJump 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:
:wqReopen terminal and you should be able to use the alias
ll
I don't have the rep points yet to comment directly on someone else's comment but, I just wanted to clarify that "alias ll='ls -lGaf'" is partly redundant. Using -f automatically enables -a as well. You can verify this in the man page for ls. So, all that's truly needed is "alias ll='ls -lGf'".