Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

This chapter is from the book

This chapter is from the book

Display Contents in Color

ls --color

In addition to the symbols that are appended to files and folders when you use the -F option, you can also ask your shell to display things in color, which gives an additional way to classify items and tell them apart. Many Linux installs come with colors already enabled for shells, but if yours does not, just use the --color option (I know you can’t see the colors, so just pretend).

$ ls --color
adblock_filters.txt   fixm3u       pix2tn.pl
addext                flash.xml    pop_login
address_book.csv      getip        procmail
address_book.sxc      homesize     programs_kill
address_book.xls      html2text.py programs_usual
backup_ssh_to_chaucer list-urls.py quickrename

In this setup, executable files are green, folders are blue, and normal files are black (which is the default color for text in my shell). Table 2.2 gives you the full list of common color associations (but keep in mind that these colors may vary on your particular distro).

Table 2.2 Colors and File Types

Color

Meaning

Default shell text color

Regular file

Green

Executable

Blue

Directory

Magenta

Symbolic link

Yellow

FIFO

Magenta

Socket

Red

Archive (.tar, .zip, .deb, .rpm)

Magenta

Images (.jpg, .gif, .png, .tiff)

Magenta

Audio (.mp3, .ogg, .wav)

With the combination of --color and -F, you can see at a glance what kinds of files you’re working with in a directory. Now we’re cookin’ with gas!

$ ls -F --color
adblock_filters.txt    fixm3u*       pix2tn.pl*
addext*                flash.xml*    pop_login*
address_book.csv       getip*        procmail/
address_book.sxc       homesize*     programs_kill*
address_book.xls       html2text.py* programs_usual*
backup_ssh_to_chaucer* list-urls.py* quickrename*
  • + Share This
  • 🔖 Save To Your Account