Linux Command to Show Hidden Files: ls -a and More
In this article
To show hidden files in Linux, run ls -a in a terminal. Hidden files are usually names that begin with a dot, such as .bashrc; the -a option tells ls to include them in its listing.
Quick commands for hidden files
The right command depends on whether you want a quick list, file details, or a recursive search. These are the most useful starting points:
ls -a— list all entries in the current directory, including hidden ones and the special entries.and...ls -A— include hidden entries but omit.and.., which is often a cleaner view.ls -la— show all entries in long format, including permissions, ownership, size, and modification time.ls -lhA— show hidden entries in long format with file sizes in readable units, while omitting.and...
For example, after running cd ~/Documents, use ls -A to see hidden configuration files alongside ordinary files. Options can be combined: in ls -la, -l requests long format and -a includes all entries.
Why Linux files are hidden
On Linux and other Unix-like systems, a leading dot in a filename conventionally marks it as hidden. It is a naming convention, not a special permission or a security feature. A file called .config is hidden from a normal ls listing, while changing its name to config makes it appear in that ordinary listing.
Many hidden files and directories store user or application settings. Examples include .bashrc for Bash shell configuration, .ssh for SSH-related files, and .config for application settings. The exact files present depend on the programs installed and how the account is configured. Hiding them keeps routine directory listings less cluttered; it does not prevent users or programs with appropriate access from reading them.
The dot convention applies to names in any directory, not only a user's home directory. A hidden name can be listed by specifying it directly, such as ls -l .bashrc, even without using -a.
What the ls options mean
ls displays directory contents. Its options control which entries appear and how their information is formatted:
-ameans “all”: include names beginning with a dot, including.(the current directory) and..(its parent directory).-Aalso includes dot-prefixed names but leaves out those two directory-navigation entries.-luses a long listing. It shows information such as file type and permissions, link count, owner, group, size, and modification time.-hmakes sizes easier to read when used with a size-displaying format such as-l, using units such as K or M where supported.
These options are not commands to change files. Listing with ls -a does not reveal or modify file contents; it only shows names that a basic listing leaves out. A long listing can help distinguish a directory from a regular file and check who owns an entry, but it does not by itself explain what an unfamiliar configuration file does.
Show hidden files in a specific directory
To list hidden entries somewhere other than the current directory, give ls a path. For instance, ls -A ~/.config lists the contents of the current user's .config directory without changing the shell's current location. The tilde (~) stands for the current user's home directory in typical shell usage.
You can also inspect a particular hidden directory with ls -la ~/.ssh. If the path contains spaces, quote it, for example ls -A "$HOME/My Folder". Use pwd to check the current directory if you are unsure where a pathless ls -a will look.
To search below a directory as well, use find. For example, find . -name '.*' searches from the current directory for names beginning with a dot. This pattern can match the special names . and .. as well; to exclude those while finding hidden entries, use find . -name '.*' -not -name . -not -name ... Recursive searches may produce a lot of output, so narrow the starting path when possible.
Common problems and misconceptions
If ls -a appears not to show hidden files, check that you are looking in the intended directory and that the names actually begin with a dot. A file is not hidden merely because its name contains a dot elsewhere: notes.txt is an ordinary visible name, while .notes.txt follows the hidden-file convention.
Permission errors are separate from hidden status. A dot-prefixed name may be visible in a listing while its contents are unreadable to your account. Conversely, a directory's permissions can prevent you from listing its entries. Do not use sudo automatically to work around an error; first check the path and permissions, and elevate privileges only when you understand why it is necessary.
Also, “hidden” does not mean “safe to delete” or “secret.” Configuration files may affect logins, applications, or command-line behavior. Avoid removing unfamiliar dotfiles just to tidy a listing, and do not assume that putting a dot at the start of a name protects sensitive data.
Frequently Asked Questions
What is the Linux command to show hidden files?
Run ls -a in the directory you want to inspect. Use ls -A if you want to omit the . and .. entries.
How do I show hidden files with permissions and details?
Use ls -la for a detailed listing that includes hidden names, or ls -lhA for long format with readable sizes and without the two special directory entries.
How do I show hidden files in the home directory?
Run ls -A ~. To inspect a specific hidden folder there, provide its path, such as ls -la ~/.ssh.
Does ls -a show hidden files recursively?
No. It lists entries in the directory you specify, not every nested directory. Use a tool such as find when you need to search through subdirectories.
Can I make a hidden file visible by renaming it?
Yes. Removing the leading dot makes the name visible to a normal ls listing. Renaming changes the file's name, however, and applications may expect configuration files to keep their original names.