Introduction
In Linux, many sensitive system files and user configuration files are hidden by default. These hidden files are also called dotfiles because their names begin with a dot (.) They are concealed to prevent accidental modifications that affect system behavior or application settings.
This guide will show you how to show hidden files and directories in Linux and help you better understand and manage them.
Prerequisites
- A system running Linux.
- Access to the terminal.
- Root or sudo access for some files or directories.
How to Show Hidden Files and Directories in Linux?
In Linux, you can view hidden files and directories using various methods, depending on whether you're in the terminal or using a graphical user interface (GUI).
These methods work on Ubuntu, Debian, Fedora, and other Linux distributions. Follow the steps below to display hidden files and directories.
Show Hidden Files and Directories From the Command Line
There are several ways to show hidden files and directories from the command line. The following text elaborates on those methods.
ls -a Command
To display all the files in a directory, including hidden files, enter the following command:
ls -a
The ls command lists the contents of the current directory. The –a
option lists all files, including hidden files. The hidden files are those starting with a dot.
To list regular and hidden files in a different directory than your current working location, use:
ls -a [directory_path]
For example, to list files in the /etc directory, run:
ls -a /etc
find Command
The find command is more flexible and searches for hidden files within directories. For example, to search recursively in the current directory and its subdirectories for files with a dot, run:
find . -name ".*"
The dot (.
) specifies the current directory as the starting point, while -name ".*"
instructs the command to search for files starting with a dot.
tree -a Command
The tree
command with the -a
option shows a hierarchical tree view of both visible and hidden files. Execute the following:
tree -a
Note: If tree
is not installed, run: sudo apt install tree
.
dir -a Command
Another option is to use the dir -a
command to display hidden files and directories. Run the following command to print all files, including hidden ones:
dir -a /home/sara
The -a
option ensures any file or directory name beginning with a dot (.
) is included in the output.
Show Hidden Files in a Graphical Interface (GUI)
In Linux, the method for showing hidden files in a graphical user interface (GUI) depends on the specific file manager you are using. Each file manager has specific features for displaying hidden files. However, the methods are quite similar.
The following text elaborates on ways to show hidden files in Linux using popular file managers.
Nautilus (GNOME Files)
Nautilus or GNOME Files is the default file manager for GNOME desktop environments. To show hidden files, open the file manager and take the following steps:
1. Navigate to the desired directory.
2. Select the menu button.
3. Choose Show Hidden Files.
Hidden files and directories are those starting with a dot.
An alternative option is to press Ctrl + H when in the selected directory.
Dolphin
Dolphin, the file manager for KDE Plasma, offers a quick way to view hidden files and directories. To view hidden files in Dolphin, take the following steps:
1. Access the desired directory.
2. Open the menu.
3. Select Show Hidden Files.
The process allows you to view hidden files and directories. Apart from starting with the dot, hidden files in Dolphin are slightly paler than regular files and directories.
The Ctrl + H shortcut also works with this file manager.
Thunar
Thunar is the default file manager for the XFCE desktop environment. To show hidden files and directories in Thunar, use the shortcut Ctrl + H or take the following steps:
1. Navigate to the directory of choice.
2. Select View from the menu.
3. Click Show Hidden Files.
The action reveals all hidden files and directories in the Thunar file manager.
Conclusion
This article explained how to show hidden files and directories in Linux using the command line or GUI. These steps can be especially useful if you need to find configuration files.
Next, learn how to create files in Linux, how to create hidden files or how to work with Linux file systems.