Skip to main content
0 reactions

How to List the Files in a Folder in the Terminal with ls

Card titled List Files in the Terminal, labelled shell basics, with four ticked lines: the command ls notes and the three files it lists, monday.txt, tuesday.txt and wednesday.txt.

ls lists what’s inside a folder: its files and the folders within it. Type ls and the folder’s name.

Every command and output on this page is real, run in Terminal with zsh 5.9 on macOS 26.

Syntax

SyntaxBash
ls [folder]
  • ls: the command that lists a folder.
  • folder: the folder to list. Leave it out to list the folder you’re in.

See ls (opens in a new tab) in the POSIX standard.

The Example

A folder named notes with three text files, and next to it a file named todo.txt.

Step 1: List a Folder

TerminalBash
ls notes
OutputPlain text
monday.txt      tuesday.txt     wednesday.txt

Step 2: List the Folder You’re In

TerminalBash
ls
OutputPlain text
notes           todo.txt

With no name, ls lists the current folder: here the notes folder and the todo.txt file.

Common Mistakes

MistakeWhat happensDo this instead
A wrong folder name, such as ls notels: note: No such file or directoryCheck the name’s spelling

FAQ

Why are the names side by side?

In a Terminal window, ls arranges the names in columns to fit the width of the window.

Conclusion

Type ls and a folder’s name to see what’s in it, or ls alone for the folder you’re in.

Additional Resources

macOS is a trademark of Apple Inc.

0 comments