Displaying ls in color

Q: How do I get ls to display in color?

How do I get ls to display in color?

A: Login as root and add the --color option to the command.

If you want to add color to the ls command, just include the --color option as root:

	ls -al --color /etc 

Some users feel that adding --color does more than add a splash of color; it gives a clue about the types of files in a directory. For example, directories might all be a royal blue, program files would be green, and so on.

Displaying the listing in color all the time involves a little more work. You will need to add one line to the .bashrc file in your /home/login directory. The .bashrc file is used by your shell when you login. Make sure you're in your /home/login directory and copy the .bashrc file, keeping it in the same directory, but with a name like .bashrc2.

	cp .bashrc .bashrc2 

If you make a mistake or have trouble, you can replace your .bashrc file by typing:

	cp .bashrc2 .bashrc

at the shell prompt.

Open the .bashrc file with your favorite text editor. For example, you could type pico .bashrc at the command line to open the file. You should see something like this:

# .bashrc

# User specific aliases and functions

# Source global definitions

if [ -f /etc/bashrc ]; then

. /etc/bashrc

Under the line "# User specific aliases and functions" type:

alias ls="ls -al --color"

Make sure to write your changes to the file and save them. The changes will not take effect until you close your xterm window and open a new xterm.