Seeing what’s in a folder is one of the first things you’ll do in a Linux terminal. The ls command lists a folder’s contents, and its options can show hidden files or add details like size and modification time.
Below are the ls options that change which entries appear and how they’re sorted.
What is the ls command?
With no path, ls lists entries in the current working directory, showing names or the requested details.
A file operand asks ls to show that file’s information. A directory operand normally makes it list the directory’s contents, and options change which entries appear or which details accompany each name.
These examples use GNU ls on Linux. Other Unix variants can differ in supported options and output.
ls
Step 1: List entries in a directory
Run ls without a path to list the current directory, or name a directory to list somewhere else. Add -1 when you want each entry on its own line rather than in columns.
ls
ls -1
ls /etc
The retained terminal image shows names and colors arranged in columns, as an example from its own terminal rather than files on your machine.

When you pass a directory operand, ls normally shows the names inside it, while a file operand displays information about that single file. If you need a test file, see how to create a file in Linux first.
A listing shows names rather than file contents, so use the site’s guide to read a file with cat or more when you need to inspect its text.
Step 2: Show hidden entries
Plain ls omits names that begin with a dot, while -a includes them and -A leaves out the implied current and parent directory entries.
ls -a
ls -A
- -a includes every entry, including . and ..
- -A includes dot-prefixed names but excludes . and ..

The leading dot is a naming convention that ls recognizes, not a permission setting. For more on dot-prefixed names, see the guide to show hidden files in Linux.
Step 3: Read file details with long format
The -l option adds a row of metadata for each entry. On GNU ls, add -h to show readable size units.
ls -l
ls -lh
| Field | What it reports |
|---|---|
| First character and permission bits | Entry type, followed by its access modes. |
| Owner and group | The user and group recorded for the entry. |
| Size and timestamp | The reported entry size and modification time. |
| Name | The entry name, or a symbolic link and its target. |

The size beside a directory describes its directory entry, not the space used by files beneath it. For ownership changes, see the chown command guide, and use the guide to symbolic links in Linux to understand link targets.
Step 4: Sort entries by size or modification time
GNU ls sorts names alphabetically by default. Use -S for descending reported size, or -t for newest modification time first, then add -r to reverse that order.
ls -lSh
ls -lt
ls -ltr
In the first command, -S chooses the order and -h changes the displayed units. The size sort still uses the reported size, not the human-readable label.
I saw ls -lt put the newest modification times first. Adding -r in ls -ltr reversed that order.

Time and size are different sort keys. The retained size example uses -S, while -h changes the units it prints.

When a row is a directory, its size still describes that directory entry rather than its contents. For total directory usage, use du instead of treating -S as a recursive size sort.
Step 5: List a directory entry or descend into it
A directory operand normally opens that directory for listing. GNU ls -d reports each operand itself, while -R descends through subdirectories.
ls -d *
ls -ld */
ls -R
| Command | What it lists |
|---|---|
| ls -d * | Each non-hidden name matched by the shell, including files and directories. |
| ls -ld */ | Paths that match */ in the shell, shown with their long details. |
| ls -R | Entries beneath the current directory and its subdirectories, grouped by path. |
I ran ls -d * in the example directory, and its output included directories, a symbolic link, and regular files. The shell expanded * before ls received the names, so -d did not filter for directories.

The screenshot shows the matched directories themselves. Use the retained recursive listing when you need the names inside each directory, not just the directory entries.

For counting rather than displaying names, use the guide to count files in a directory.
When ls output looks different
An unexpected listing often comes from an option, shell setting, or a misunderstanding of directory metadata. Check which command the shell resolves before changing files.
| What you see | Why it happens | Next action |
|---|---|---|
| Dot-prefixed names are absent | Plain ls omits them. | Run ls -A or ls -a. |
| A directory’s size seems small | Long format reports the directory entry. | Run du -sh Docs for its tree usage. |
| Names have unexpected colors | An alias or color option changes presentation. | Run type ls to inspect the shell command. |
| A wildcard result includes files | The shell expands the wildcard before ls runs. | Use a directory glob such as */. |
Use du to measure directory-tree usage, then check the local manual when an option behaves differently on your system.
du -sh Docs
man ls
ls --help
ls –help is available on GNU systems, while man ls opens the manual installed for the local implementation. The Linux ls manual page documents GNU/Linux options, so use your system’s own manual when you are working on another Unix family.
GNU ls can add colors for terminal output, but color is presentation rather than proof of permissions or file type. In an interactive Bash shell, define a shortcut with an alias. It applies only in that shell unless you add it to a startup file.
type ls
alias lsa='ls -la'
lsa
ls --color=auto
For directory usage sorted by size, see the site’s guide to listing directories by size. An ls size sort and a disk-usage report answer different questions.
Keep the path attached to the listing
A listing is useful only when you know which directory it describes. Pass the path explicitly when you are checking a location other than the current working directory.
ls -lh /var/log
For the manual command, see the site’s guide to using man pages in Linux.
Frequently asked questions about ls
Does ls -l show the total size of a directory?
No. The size field describes the directory entry itself, not the space used by its contents. Run du -sh Docs when you want a total for that directory tree.
How do I print one entry per line?
Run ls -1. The flag forces one entry per output line instead of arranging names in columns.
