Displaying Ls In Color - Red Hat LINUX 7.2 Manual

Hide thumbs Also See for LINUX 7.2:
Table of Contents

Advertisement

164

13.4 Displaying ls in color

13.4.1 Q: How do I get ls to display in color?
How do I get ls to display in color?
13.4.2 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"
Chapter 13:Frequently Asked Questions

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the LINUX 7.2 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Linux 7.2

Table of Contents