Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other


Distinguishing directories from files in ls

Normally when you type 'ls' in the console you won't be able to distinguish regular files from directories. There is more than one way to make 'ls' show the difference.

Long listing

ls -l

Each file's description will fill a line, the first character of a line shows the type:

Code: ls -l
drwxr-xr-x   10 user      users        4096 jan 1  2005 directory
-rw-r--r--    1 user      users       25721 jan 1  2005 me.jpeg
-rwxr--r--    1 user      users         325 jan 1  2005


ls --classify or ls -F will append characters to files to show their type:

Code: ls -F
directory/         me.jpeg*


ls --color=tty

Will color the 'ls' output. Directories are blue, regular files stay black (or white) and executable files are green.

directory         me.jpeg


Make an Alias of your prefered method.


alias ls='ls --color=tty --classify'

List only directories

ls -d */

Will list only entries ended by a "/", and with the "-d" option, will not descend into the next level of directory.

Retrieved from ""

Last modified: Fri, 05 Sep 2008 23:10:00 +0000 Hits: 15,680