MIAP Digital Literacy Command Line Guide

Learn about BASH commands!

View on GitHub

The ls Command

Summary

The ls command lists the contents of a directory including both files and directories. The command has many options which are described below.

Basic command structure

For all descriptions below, the dollar sign indicates that BASH command prompt.

$ ls [options] [directory path]

Note: If you do not specify a directory path, running ls will show you the contents of the current directory you are in within your terminal window, i.e., your current working directory.

Possible Flags

-a

The -a flag shows files that are normally hidden by BASH. These are files that begin with a . such as .DS_Store, .bashrc, or .bash_history.

-l

The -l flag gives a column view of files and directories. It also gives information about those files and directories including permissions, last date modified and size.

-h

When used in combination with the -l flag, the -h flag displays file size in human-readable units such as kilobytes, megabytes, and gigabytes.

Output

The ls command has many different kinds of outputs as described below:

Examples

Go back to the main list of commands