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
Key Facts
- Hidden files in Unix-like systems start with a dot (.).
- The `ls -a` command lists all entries, including hidden ones.
- The `ls -A` command lists all entries except for '.' and '..'.
- The `-l` flag provides a detailed, long listing format.
- Combining flags like `ls -la` shows all hidden files with details.
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 -aThis 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 -AThis 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 -laTo list almost all files (excluding '.' and '..') with detailed information:
ls -lAThe 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.txtIn 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.
- macOS Finder: Press
Command + Shift + .(period) to toggle the visibility of hidden files. - Linux (GNOME/Nautilus): Go to the menu (usually represented by three horizontal lines or dots) and select "Show Hidden Files", or press
Ctrl + H. - Linux (KDE/Dolphin): Go to View -> Show Hidden Files, or press
Alt + ..
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:
- Configuration Files: Many applications and the operating system itself store their settings in hidden files (e.g., `.bashrc`, `.gitconfig`, `.ssh/config`). Hiding them prevents users from accidentally altering critical settings.
- System Files: Some system-level files or directories might be hidden to avoid confusion or protect them from accidental deletion.
- Organization: Keeping less frequently accessed or system-specific files out of the default view helps maintain a cleaner and more organized file system display for everyday use.
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.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- Hidden file - WikipediaCC-BY-SA-4.0
- ls(1) - Linux man pagefair-use
- 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.