List Hidden Files in Linux: ls, find & More
To list hidden files in Linux, use ls -a or ls -A in the directory you want to inspect. Hidden files are those whose names begin with a dot (.), and these commands reveal them alongside normal files. This article explains the commands, their differences, and how to find hidden files recursively or with specific details.
What Are Hidden Files in Linux?
In Linux and other Unix-like systems, a file is considered hidden simply because its name starts with a dot (.). This is a convention, not a security feature. The system does not treat these files differently in terms of permissions or access; they are just not shown by default in directory listings. Common examples include .bashrc, .profile, and .gitignore. Many programs store configuration settings in hidden files or directories in your home folder, keeping the main directory view uncluttered.
The Basic Commands: ls -a and ls -A
The most direct way to list hidden files is with the ls command and its flags.
ls -a— Lists all entries, including the current directory (.) and the parent directory (..).ls -A— Lists all entries except.and... This is often more convenient because it reduces clutter.ls -laorls -lA— Adds the long format, showing permissions, owner, size, and modification date.
For example, running ls -A in your home directory might show .bashrc, .config, and .local alongside your visible folders. The -a flag is the most commonly used, but -A is a cleaner option when you don’t need the dot entries.
Using find to List Hidden Files Recursively
If you need to list hidden files in subdirectories as well, the find command is more flexible. The basic syntax is:
find /path/to/start -name ".*"
This searches for any file or directory whose name begins with a dot. To restrict the search to regular files only, add -type f:
find /home/username -type f -name ".*"
To exclude the current and parent directory entries from the output, you can use find /path -name ".*" -not -name "." -not -name ".." or simply rely on find not listing them unless you explicitly include the start directory itself. The find command is particularly useful when you want to locate hidden files across a whole directory tree, such as finding all .git folders in a project.
Listing Hidden Files with Details and Sorting
Often you need more than just names. The ls -l long format gives you permissions, number of links, owner, group, size, and last modification time. Combine it with -a or -A to include hidden files:
ls -lA
You can also sort the output. For example, ls -lat sorts by modification time (newest first), and ls -laS sorts by file size (largest first). To reverse any sort, add the -r flag. If you want to see hidden files in a color-coded format, most distributions enable colors by default with ls --color=auto. This helps distinguish directories, executables, and symlinks.
Common Mistakes and Misconceptions
A frequent mistake is thinking that hidden files are invisible to programs or that they offer security. In reality, any user with read permission can list them with ls -a. Another misconception is that the dot prefix is a file extension; it is not. A file named .bashrc has no extension; the entire name is .bashrc. Also, note that ls will not show hidden files unless you use a flag, but shell globbing (e.g., echo *) also ignores dotfiles by default. To match hidden files in a glob, you need to use .* explicitly, as in ls .* — but be careful because that will also match . and ...
Alternatives: Using Midnight Commander and GUI File Managers
If you prefer a graphical interface, most Linux file managers (like Nautilus, Dolphin, or Thunar) have a keyboard shortcut to toggle hidden files. Typically it is Ctrl+H. In the terminal, you can also use the mc (Midnight Commander) file manager, which shows hidden files when you press Ctrl+H or select the “Show hidden files” option in the menu. For a quick one-off, ls -a is usually enough, but for interactive browsing, the GUI toggle is handy.
Frequently Asked Questions
How do I list only hidden files, not normal files?
You can pipe the output of ls -A through grep to filter names that start with a dot: ls -A | grep '^\\.'. Alternatively, use find . -maxdepth 1 -name ".*" to list hidden entries in the current directory only.
What is the difference between ls -a and ls -A?
ls -a shows all entries including the special directories . (current directory) and .. (parent directory). ls -A shows all entries except those two. For most purposes, -A gives a cleaner output because you rarely need to see . and ...
How do I make hidden files visible in a GUI file manager?
In most Linux file managers, press Ctrl+H to toggle the visibility of hidden files. This works in Nautilus (GNOME), Dolphin (KDE), Thunar (XFCE), and many others. Some file managers also have a menu option under “View” or “Preferences”.
Why are hidden files hidden in the first place?
The dot-prefix convention dates back to early Unix. It was originally a simple way to keep configuration files and other clutter out of the default ls listing. It is not a security mechanism; it just reduces visual noise. Hidden files are still fully accessible and can be edited or deleted like any other file, provided you have the necessary permissions.
Can I change a file to be hidden by renaming it?
Yes. Simply rename the file so that its name begins with a dot. For example, mv notes.txt .notes.txt will make it hidden. To unhide it, rename it back to a name without a leading dot. This works for directories as well.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.