Use the ls command to display a listing of all files and directories within the current directories.

Command Format

ls [-option(s)] [pathname]

Examples

In this example, the user moves to their home directory by typing the cd command.

$ cd
$ pwd
/home/charles
$

In the next example, the user displays the directory listing for their home directory.

$ ls
franklin pigpen
snoopy woodstock
$

In the following example, the user displays the directory listings for the snoopy subdirectory.

$ cd snoopy
$ ls snoopy
charles cooldog hero
$

In the next example, the user displays the directory listings for the /var/mail subdirectory.

$ ls /var/mail
user5
$