How do I set ls
so that when I type ls
it actually runs ls -l
.
This Sounds minor but I'm trying to save keystrokes wherever I can. This is on Ubuntu 10.10.
4 Answers
Look up the alias command.
alias list='ls -l'
If you want this to "stick" add it to your .bashrc
file.
-
As mentioned in another answer, you can also create an alias called
ls
, to "replace" the regularls
shell built-in.– oKtosiTeMar 29, 2011 at 10:22 -
Thanks, I was just making it explicit that you could rename the shortcut. Mar 29, 2011 at 11:58
-
Thanks! Works great...I went with alias l="ls -l" and commented out the previous "l" alias in the .bashrc file.– user73919Mar 30, 2011 at 17:57
The normal pattern is to have ll
aliased to this.
In Ubuntu 10 it is already done.
Here is an extract from the default .bashrc
:
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
My .bashrc
looks like this:
alias l='ls --color=always -F'
alias ll='ls --color=always -F -lh'
alias L='ls --color=always -F -L'
alias LL='ls --color=always -F -lh -L'
alias la='ls --color=always -F -a'
alias lla='ls --color=always -F -lh -a'
alias l.='ls --color=always -F -A --ignore=\*'
alias ll.='ls --color=always -F -lh -A --ignore=\*'
Note: changing the meaning of an existing command is considered dangerous, e.g., alias ls='ls -l'
. It can change the behavior of (badly written, though most) scripts.
You can use the alias
command.
alias ls="ls -l"
You can either type this out in a shell session, or you can put it in a file to be sourced, a good one would be ~/.bashrc
. If you run it in a shell session, the alias will exist until you exit the shell. If you put it in your a file and source it each time the shell is run (such as by simply putting it in ~/.bashrc
), the alias will be created each time you open a shell.