Site icon JD Bots

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

Syntax

ls [folder]

See ls 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

Terminal

ls notes

Output

monday.txt      tuesday.txt     wednesday.txt

Step 2: List the Folder You’re In

Terminal

ls

Output

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.

Exit mobile version