Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-16-2007, 10:55 PM   #1
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 90
Make "ls" command show colors without "--color=always" switch

I've been playing around with ls's --color=always option, it's very handy to sort files on the command line this way, but I don't like having to type it every time. So I thought I'd do LS="--color=always" to put it in the environment, but it doesn't work that way, even with
export LS="--color=always"
so how can I get this to do what I want? Thanks.
Old 07-16-2007, 11:14 PM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,903

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Edit the user .bashrc file (~/.bashrc) to add an alias: alias lc="ls --color=always". Then give the command: source .bashrc. That will reload .bashrc.

Lc is just an example. Make it whatever you want.

Last edited by bigrigdriver; 07-16-2007 at 11:22 PM.
1 members found this post helpful.
Old 07-16-2007, 11:16 PM   #3
Senior Member
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
You could use alias to make `ls` always run `ls -color=always`
alias ls="ls --color=always"
.. or do you have either /etc/DIR_COLORS or ~/.dir_colors? Not sure if it's a distro thing or not but I have /etc/DIR_COLORS which is referenced in my ~/.bashrc file like so:
eval $(dircolors -b /etc/DIR_COLORS)
The dircolors app uses the file contents to create a shell variable and export it so ls always uses the color.
Old 07-16-2007, 11:18 PM   #4
Registered: Jul 2007
Location: Argentina
Distribution: Ubuntu 13.04 , Debian Lenny 5.0.7
Posts: 223

Rep: Reputation: 21
To do so try this:
- in your .bashrc file (located in /home/USER/ if it is not there, create it) add the following line

alias ls="ls --color=always"

- save the file
- maybe restart (i don't remember if that was necessary)

That should make it... Good luck!
Old 07-17-2007, 12:00 AM   #5
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Original Poster
Rep: Reputation: 90
Okay, thanks guys for the replies. I've used alias lots, don't know why I didn't think of that. Just goes to show you two heads are better than one. Thanks again.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
So many errors when I typed the "make" and "make install" command Niceman2005 Linux - Software 23 07-22-2009 03:33 PM
C Drive "/dev/hda1" accidently used in dd command at "of=" switch M D Linux - Software 4 04-26-2007 09:56 AM
"NIM thread blocked" & "Deadman Switch (DMS) close to trigger" errors sosborne Linux - Networking 1 06-28-2006 03:07 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:03 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration