Where is the alias for "ll" defined?
Solution 1
In Ubuntu, this alias is defined by default in the ~/.bashrc
file, in mine like this:
$ grep "alias ll" ~/.bashrc
alias ll='ls -alF'
Another file read by default is the ~/.bash_aliases
. It may not exist until you create it, but it's the recommended way of storing aliases as keeping them in a separate file provides clarity. Your ~/.bashrc
contains the following section, the if expression in which loads this aliases file if it exists:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
As for zsh
I suppose the alias is defined in the same manner in your ~/.zshrc
file or any file sourced by it. If you use oh-my-zsh
it may be contained in lib/directories.zsh
or plugins/common-aliases/common-aliases.plugin.zsh
.
sh
(= dash
in Ubuntu) reads only ~/.profile
, which normally doesn't contain any aliases as they are defined shell-specific. In the case of an alias as simple as alias ll='ls -lh'
however you could go for a definition in ~/.profile
. Further reading: Is there a “.bashrc” equivalent file read by all shells?
Solution 2
For zsh, aliases can be added in .zshrc
. ll
must have been defined in that file.
You can add an alias in .zshrc
by editing it with any file editor such as nano.
For example:
alias ll="ls -lh"
Eliah Kagan
Updated on September 18, 2022Comments
-
Eliah Kagan over 1 year
I often find myself using
ll
which is an alias.$ type ll ll is an alias for ls -lh
I always wondered where this was defined as it works both on
bash
,zsh
but not onsh
:# THIS IS SH $ ll sh: 1: ll: not found
-
Eliah Kagan over 4 yearsMost people don't use
dash
much as an interactive shell. But if one does, and wishes to define aliases indash
, their definitions should not go in~/.profile
. Likebash
and other POSIX-compatible shells,dash
sources~/.profile
only when run as a login shell--and aliases are not inherited. When anENV
environment variable is set, all interactivedash
shells source the file named in it. Such a file is a good place for aliases. (Setting and exportingENV
can be done in~/.profile
.) Seeman dash
for details. -
dessert over 4 years@EliahKagan Please feel free to edit and correct me there!
-
Aindriú over 3 yearsIf you use the above you can run the following after to make changes take effect : source ~/.zshrc