List directory contents

« Back to list of missions

Missions: Using command line shell

Using ls for listing directory contents

ls: List directory contents

1. List files using ls with no options:

$ ls

ls command with no option will list files and
directories in bare format and you won’t be able to view details like file
type, size, modification date, permissions etc.

2. List files using -l option:

$ ls -l

The ls command with option -l (i.e.
ls -l) will list files and directories along with their
size, modified date and time, owner of the file, and permissions.
It will look something like this:

    drwxr-xr-x   2 root root  4096 Oct 11 00:20 bin

3. View hidden files:

$ ls -a

The ls command with option -a
(i.e. ls -a) will list all files, including hidden
files (whose names start with ‘.’).

There are many other options available. For more options, type
ls --help in your shell and you’ll get a list of
available options along with a short description for each option.
(if you are using OS X or zsh man ls)