- List Files and Folders
- List the Contents of Other Folders
- List Folder Contents Using Wildcards
- View a List of Files in Subfolders
- View a List of Contents in a Single Column
- View Contents As a Comma-Separated List
- View Hidden Files and Folders
- Visually Display a File's Type
- Display Contents in Color
- List Permissions, Ownership, and More
- Reverse the Order Contents Are Listed
- Sort Contents by Date and Time
- Sort Contents by Size
- Express File Sizes in Terms of K, M, and G
- Display the Path of Your Current Directory
- Change to a Different Directory
- Change to Your Home Directory
- Change to Your Previous Directory
- Conclusion
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*