Access the Terminal

To access the command-line terminal, either click on the black box icon in the top menu bar of the Raspberry Pi OS desktop, or select it from the raspberry icon menu: Accessories > Terminal.

Use the ls Command

By default upon opening a Terminal window, you’ll be in the /home/pi directory (folder). To list the files and directories in it, type the following command, followed by the Return key.

To list the contents of a different directory, you could use the cd command to switch to it. Alternatively, simply use ls followed by the directory name (with a preceding slash, /). For example:

You can also list the files in a subdirectory. For instance:

In addition, you can list files in multiple directories by separating their names with a space:

List Options

By default, the ls command lists files and directories in alphabetical order. This can be altered by appending the command with an option. For instance:

This sorts them by time of creation or modification, with the most recent appearing first.

Other sorting options include -r (reverse alphabetical) and -S (file size).

Another useful option, to show the contents of subdirectories recursively, is:

You might also want to see hidden files, such as those whose names start with a period (.). In which case, enter:

To see more details for files and directories, in a long listing format, enter:

This shows details including the file type, permissions, owner, group, size, date and time.

To see other available options, enter:

For more information on all the options and how to use them, check out our full guide on how to use the ls command in Linux.