How to ls hidden 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: To list hidden files and directories in Linux and macOS, use the `ls -a` command. This will display all files, including those starting with a dot (.), which are conventionally hidden. For more detailed information, you can add the `-l` flag for a long listing format: `ls -la`.

Key Facts

Overview

In Unix-like operating systems such as Linux and macOS, files and directories that begin with a period ('.') are conventionally treated as hidden. This convention is used to keep configuration files and other system-related items out of view by default, helping to declutter directory listings and prevent accidental modification of important files. However, there are times when you need to see these hidden items, such as when troubleshooting, managing configuration files, or accessing specific application settings.

How to List Hidden Files

The primary command used to list files in Unix-like systems is `ls`. By default, `ls` does not show hidden files. To reveal them, you need to use specific options (flags) with the `ls` command.

The `-a` Option: Show All

The most common and straightforward way to list hidden files is by using the `-a` (all) option. When you execute `ls -a`, the command will display every file and directory within the current directory, including those whose names start with a dot.

Example:

ls -a

This command will output a list that includes entries like `.bashrc`, `.profile`, `.ssh`, and also the special directory entries `.` (representing the current directory) and `..` (representing the parent directory).

The `-A` Option: Almost All

Sometimes, you might want to see hidden files but prefer not to see the `.` and `..` entries, as they can be redundant. The `-A` (almost all) option is useful for this purpose. It lists all hidden files and directories except for the current and parent directory entries.

Example:

ls -A

This command provides a cleaner list of hidden items without the clutter of `.` and `..`.

Combining Options: Detailed Listings

Often, you'll want to see more information about the files, not just their names. The `-l` option provides a long listing format, which includes permissions, owner, group, size, and modification date. You can combine this with the `-a` or `-A` options for a comprehensive view.

To list all files (including hidden ones) with detailed information:

ls -la

To list almost all files (excluding '.' and '..') with detailed information:

ls -lA

The output of `ls -la` might look something like this:

total 48drwxr-xr-x 5 user user 160 Oct 26 10:30 .drwxr-xr-x 22 root root 704 Oct 25 09:15 ..-rw-r--r-- 1 user user 3106 Oct 20 15:45 .bash_history-rw-r--r-- 1 user user 220 Aug 15 11:30 .bash_logout-rw-r--r-- 1 user user 3761 Aug 15 11:30 .bashrc-rw-r--r-- 1 user user 807 Aug 15 11:30 .profiledrwxr-xr-x 2 user user 60 Oct 26 10:25 .ssh-rw-r--r-- 1 user user 0 Oct 26 10:30 my_hidden_file.txt-rw-r--r-- 1 user user 1234 Oct 26 09:00 my_visible_file.txt

In this output, files starting with `.` are the hidden ones. The `-l` flag shows details like permissions (`drwxr-xr-x`), number of links (`5`), owner (`user`), group (`user`), size (`160`), and modification date/time (`Oct 26 10:30`).

Viewing Hidden Files in File Managers

Most graphical file managers in Linux (like Nautilus, Thunar, Dolphin) and macOS (Finder) also provide a way to toggle the visibility of hidden files. Typically, this is done through a menu option or a keyboard shortcut.

These graphical methods offer a convenient way to manage hidden files without needing to use the command line.

Why are Files Hidden?

The convention of hiding files starting with a dot originated in early Unix systems. Its primary purposes include:

Conclusion

Understanding how to list hidden files using `ls -a` or `ls -la` is a fundamental skill for anyone working with the command line in Unix-like environments. Whether you need to edit configuration files, manage application settings, or simply explore the contents of your home directory more thoroughly, these commands provide the necessary access. Remember that while hidden files are not shown by default, they are still regular files and directories, and should be treated with the same care, especially when making modifications.

Sources

  1. Hidden file - WikipediaCC-BY-SA-4.0
  2. ls(1) - Linux man pagefair-use
  3. Show or hide invisible files and folders in Finder on Macfair-use

Missing an answer?

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