List Directory Contents Using the Dir Command

List files and folders from within a Linux shell prompt

Although most people who use Linux from a shell prompt traverse the file system using the ls command, Linux also supports a dir command that functions similarly, but with a few key differences.

Some distributions do not include dir by default.


Both programs display a listing of files within a directory.

Dir is functionally equivalent to the command ls -C -b in which the output lists in columns, sorted vertically, and with backslashed escape sequences to represent special characters.


linux ls vs dir

Dir provides output that doesn't vary regardless of whether it displays to a terminal or is piped to a file.

Also, given the philosophy of the Gnu Project, dir meets a design-philosophy standard prohibiting the behavior of a command-line program from depending on the type of output device.

Was this page helpful?