Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set default arguments for "ls" in Linux? [closed]

Tags:

Im constantly doing "ls -ahl" whenever I want to list what is in the directory. Is there a way for me to make -ahl the default args passed when I do "ls" or should I just create an alias like "alias lsa=ls -ahl" in bash_profile?

like image 790
JoshL Avatar asked Feb 02 '12 21:02

JoshL


People also ask

How do I change the ls command in Linux?

Simply do alias ls='ls -tU' and in the future all ls commands would be replaced by ls -tu . This solution persists until your close your terminal window, but you can always add it to a startup script (for example, .

How Stop ls command?

You can stop the output by pressing Ctrl + C (like it's the case with most programs inside the linux shell).

What does ls do by default in bash without any aliases parameters )?

The default output of the ls command shows only the names of the files and directories, which is not very informative.


2 Answers

You could just alias ls itself. So something like:

alias ls='ls -ahl' 
like image 196
dlannoye Avatar answered Oct 16 '22 23:10

dlannoye


Set an alias in your ~/.bash_profile file.

alias ls="ls -ahl" 

A couple of common aliases that I use all the time are:

alias ll="ls -lh --color" alias l="ls -1" 
like image 35
Chris Seymour Avatar answered Oct 16 '22 23:10

Chris Seymour