How to ls all files

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: The `ls` command in Unix-like operating systems lists files and directories. To list all files, including hidden ones (those starting with a dot), you typically use the `ls -a` command.

Key Facts

Overview

The `ls` command is one of the most frequently used commands in Unix-like operating systems, such as Linux and macOS. Its primary function is to list the contents of a directory. When you execute `ls` in your terminal, it displays the names of files and subdirectories within the current working directory. However, by default, `ls` does not show files or directories that are considered 'hidden'. These hidden items are conventionally named with a leading period (.). This convention is used to prevent clutter in directory listings and to protect configuration files from accidental modification.

What are Hidden Files?

In Unix-like systems, files and directories whose names begin with a dot character (`.`) are treated as hidden. This is a convention, not a strict rule enforced by the filesystem itself, but it's widely adopted by most command-line tools and graphical file managers. Examples include configuration files for applications (like `.bashrc`, `.vimrc`) or directories containing application settings (like `.config`, `.local`). Graphical file managers usually have an option to toggle the visibility of these hidden items.

Listing All Files with `ls -a`

To view all files and directories, including the hidden ones, you need to use an option with the `ls` command. The most common and straightforward option for this purpose is `-a`, which stands for 'all'.

When you run the command:

ls -a

The output will include:

This is particularly useful when you need to manage configuration files or when troubleshooting issues that might involve hidden files.

Detailed Listing with `ls -la`

Often, just seeing the names of all files isn't enough. You might need more information, such as file permissions, the number of hard links, the owner and group, the file size, and the last modification date. The `-l` option provides a 'long listing' format, displaying these details.

To combine the functionality of listing all files and displaying them in a detailed format, you can use the `-a` and `-l` options together:

ls -la

or

ls -al

The order of flags generally doesn't matter. The output of `ls -la` will show each file and directory on a new line, prefixed with its permissions, owner, group, size, modification timestamp, and name. This is one of the most commonly used combinations for inspecting directory contents thoroughly.

Other Useful `ls` Options

While `ls -a` and `ls -la` are very common, `ls` offers many other options to customize its output:

Practical Examples

Let's say you are in your home directory (`~`).

1. List only visible files:

ls

2. List all files, including hidden ones:

ls -a

Output might look like:
. .. .bashrc .config .local my_document.txt pictures/

3. List all files with details (permissions, size, date):

ls -la

Output might look like:
drwxr-xr-x 5 user group 4096 Jan 15 10:30 .
drwxr-xr-x 20 root root 4096 Jan 10 09:00 ..
-rw-r--r-- 1 user group 3500 Jan 12 14:20 .bashrc
drwxr-xr-x 3 user group 4096 Jan 14 11:05 .config
drwxr-xr-x 4 user group 4096 Jan 13 08:15 .local
-rw-rw-r-- 1 user group 1024 Jan 15 09:55 my_document.txt
drwxrwxr-x 2 user group 4096 Jan 11 16:00 pictures/

4. List all files with details, sizes in human-readable format, sorted by modification time (newest first):

ls -lahT

Understanding how to use `ls` effectively, especially with the `-a` flag, is a fundamental skill for anyone working with the command line.

Sources

  1. Ls - WikipediaCC-BY-SA-4.0
  2. ls(1) - Linux man pagefair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.