TL;DR
To show hidden files in Linux, you should know the following:
- List All Files, Including Hidden Ones: Use the command
ls -a
to list all files, including hidden ones, in the current directory. - Display Only Hidden Files: Execute
ls -d .?*
in a specific directory to display only hidden files starting with a dot (.), excluding the current and parent directories.
Read the guide below to learn various methods to show hidden files in Linux, providing different ways to manage, access, and protect them.
Struggling to locate certain files on your Linux system because they seem to be missing? Hidden files play a crucial role in managing configuration settings and maintaining an uncluttered directory. This post will guide you through step-by-step methods to view, create, and manage hidden files, along with advanced tips and best practices. Whether you use the command line or a graphical interface, you’ll learn how to handle hidden files effectively. By the end, you’ll have the knowledge to organize your system better and avoid common pitfalls. Let’s dive into making your Linux experience smoother and more efficient.
What are Hidden Files in Linux?
Hidden files in Linux are regular files that start with a dot (.) in their name. For example:
.bashrc
: A script file executed whenever a new terminal session is started in Bash..profile
: A configuration file for the user environment..gitignore
: Used by Git to determine which files and directories to ignore in a project.
These files do not appear when you list the contents of a directory using the ls
command unless you add the -a
(all) option. Hidden files are commonly used to store user preferences, system configurations, and application settings. By keeping these files hidden, the file system remains uncluttered, making it easier for users to navigate their directories.
Why Are Files Hidden in Linux?
Files are hidden in Linux for several important reasons:
- Reduce Clutter: By hiding files, the directories appear cleaner and more organized. This helps users focus on the files they work with regularly without being distracted by system or configuration files.
- Configuration Files: Many hidden files are essential for system and application configurations. Examples include:
.bashrc
: Contains commands that run when a terminal session starts..profile
: Sets environment variables and startup programs for the user..vimrc
: Customizes the behavior of the Vim text editor.
- Prevent Accidental Changes: Hidden files often contain critical settings that, if altered accidentally, could disrupt the functioning of applications or the system. Keeping these files out of sight minimizes the risk of unintended modifications.
- Security: While not a primary security measure, hiding files can add a layer of obscurity, making it less likely for casual users to stumble upon sensitive configurations.
How to Show Hidden Files in Linux
To show hidden files in Linux, use the command ls -a
in the terminal to list all files, including hidden ones. To display only hidden files, use ls -d .?*
. For editing, open hidden files with text editors like nano
or vim
by specifying the file path. In graphical file managers like Nautilus or Dolphin, enable the option to show hidden files by pressing Ctrl+H
. These methods help you easily access and manage hidden files using both command line and GUI environments.
For a better understanding of these methods, let’s explore all of them here:
1. List All Files Along the Hidden Ones
To list all files, including hidden files, in the current directory, use the ls
command with the -a
flag to display files with a dot (.) at the beginning of their names. Here’s the step-by-step guide to do this:
- Head to the command-line interface (CLI) via the Dash menu.

- Then, run the command below to list all files, including hidden files.
ls -a
- This command will display all files in the current directory, including those with a dot (.) at the beginning of their names, which denotes hidden files in Linux.

2. Display Only the Hidden Files
This method displays only hidden files starting with a dot (.), excluding the parent directories by executing the ls
command with the pattern ls -d .?*
in a specific directory. It is helpful when you want to focus specifically on hidden files in a particular directory. Follow the steps below to use this method:
- Launch the Terminal window on your Linux machine using the Application menu.

- To display hidden files in a specific directory, use the
cd
command to navigate to that particular directory. For example, if you want to go to the Documents directory, you can run the following command:
cd Documents
- Then, execute the following command to display only hidden files in the current directory.
ls -d .?*
- This command will list files starting with a dot (.), excluding the parent directory (..).

3. Open Hidden Files with Text Editors
With this method, you can open, view, and edit any hidden file in the specified directory using a text editor. It can be Vim, Nano, or even Gedit. This is often helpful when you have to configure preference settings. Here’s how this method works:
- In the Terminal window, use a text editor command like
nano
,vim
, orgedit
, followed by the file’s path, to open a hidden file.
text_editor file_path
- Replace text_editor with your preferred text editor and file_path with the path to the hidden file. Just like I did here:
nano ~/.myhiddenfile
- Once you execute the command, the specified hidden file will open in the text editor:

- Now, you can edit the file or leave it unchanged. Then, close it using the appropriate keys based on your text editor. In my case, I used Ctrl + O to save and Ctrl + X to close the Nano editor.

4. View Hidden Files Using Linux File Managers
This method enables the visibility of hidden files in Linux file managers like Nautilus or Dolphin. By accessing the file manager’s settings and enabling the option to show hidden files, you can easily navigate through directories and access hidden files in a graphical and user-friendly manner. Here’s how to do it:
- Open your preferred Linux file manager (e.g., Nautilus, Dolphin).

- Navigate to the toolbar at the top and click on the three horizontal lines. Then, tick the box of Show Hidden Files in the dropdown menu.

- Once you click the hidden files option, you’ll see all the files in the current directory, including the hidden ones. Now, you can easily navigate through directories as you normally would to access hidden files.

How to Create Hidden Files in Linux
Creating hidden files in Linux is essential for managing configuration settings, storing sensitive data, and reducing clutter in your directories. Hidden files in Linux are simply files that start with a dot (.) in their name. This convention ensures these files are not displayed by default when listing directory contents.
1. Using the Command Line
- Launch the terminal application on your Linux system.
- Use the cd command to change to the directory where you want to create the hidden file.
cd /path/to/your/directory

- Use the touch command to create a new file. Prefix the file name with a dot (.) to make it hidden.
touch .myhiddenfile

- List all files in the directory, including hidden ones, using the following command:
ls -a
You should see your newly created hidden file (.myhiddenfile) in the list.

2. Using a Graphical User Interface (GUI)
- Launch your preferred file manager (e.g., Nautilus, Dolphin, Thunar) from the applications menu. Browse to the directory where you want to create the hidden file.

- Right-click in the directory and select the option to create a new file/folder. This option might be labeled as New Document, Create New, or something similar.

- When prompted to name the new file, start the file name with a dot (.). For example, name it .myhiddenfile. Save or confirm the creation of the file.

- Ensure that the file manager is set to show hidden files. In Nautilus, you can press Ctrl+H to toggle hidden files visibility. Verify that your hidden file (.myhiddenfile) appears.

5 Advanced Techniques To Know When Working with Hidden Files in Linux
Besides the basic operations, you can also rename, move, search, and delete hidden files in Linux. Moreover, you can hide and encrypt important hidden files using tools like GPG or VeraCrypt. Here’s the breakdown of each method:
1. Rename and Move Hidden Files
With the mv
command, you can rename or move the hidden files in Linux. That is, you can use the syntax mv current_name new_name
to modify the name of the file, or mv file_path destination_directory
for relocating the hidden file in Linux. It helps in organizing and managing hidden files. Here’s the step-by-step guide to do it:
- First, run the
ls -a
command to view the hidden files in the directory:

- To rename a hidden file “.myhiddenfile”, use the
mv
command:
mv current_name new_name
- Replace current_name with the current name of the hidden file, new_name with the desired new name.

- Now, run the
ls -a
command to view the renamed hidden files in the directory:

- To move a hidden file to a different directory, you can execute:
mv file_path destination_directory
- Replace the file_path with the path to the hidden file, and destination_directory with the path to the destination directory.

- Now, use the
cd
command to navigate to the folder where you have moved the file.

- Then, run the
ls -a
command to view the moved file in the folder.

2. Delete Hidden Files
This method involves using the rm command to delete a hidden file. By specifying the path to the hidden file, you can permanently remove it from the specified directory. However, you have to be carefil when using this method, as hidden files may contain important data or configuration settings.
- In the Linux command line, use
cd
to navigate to the directory.

- Then, run the
ls -a
command to view the hidden files in this folder.

- After that, use the
rm
command to delete a hidden file:
rm ~/.filename
- Run the
ls -a
command. However, you won’t see the deleted file in the specified directory as you have removed it using therm
command.

However, you should be careful when deleting hidden files, as they may contain important data or configuration settings.
3. Manage Hidden Files in File Explorer
Once the hidden files in Linux are visible using the file manager’s settings, it let you directly manage hidden files within the file explorer interface. You can quickly right-click on any hidden file and access various options like renaming, moving, deleting, and more. This method provides a convenient and visual way to handle hidden files with familiar context menus.
- Once you enable the hidden file visibility from the File Manager’s settings, locate the desired hidden file in window explorer.

- Then, right-click on a hidden file to access various options such as renaming, moving, deleting, or more.

- In case you select to delete the file or move it to trash for any reason and later want that particular hidden file back, then you can easily get it restored via the Trash folder.

4. Search for Hidden Files
You can use the find
command with appropriate options to search for hidden files in Linux Terminal. This method makes it easier to locate specific hidden files based on criteria such as file type or name. Follow the steps below to use this method to search for hidden files on your Linux machine:
- To search for all hidden files in your home directory, run the following command in the Terminal window:
find ~ -type f -name ".*"
- This command will scan the specified directory (in this case, the home directory) and display a list of hidden files, including their paths, that match the given criteria.

- To help you understand the output of this command, here’s the breakdown:
find
: The command used to search for files and directories.~
: Represents the home directory.-type f
: Specifies that only regular files should be included in the search (excluding directories).-name ".*"
: Sets the search pattern to match hidden files, as their names start with a dot (.) in Unix-like systems.
5. Encrypt and Secure Hidden Files
This method involves encrypting important hidden files in Linux using tools like GPG (GNU Privacy Guard) or VeraCrypt. Encryption adds an extra layer of security to protect sensitive information within hidden files. Here’s how you can easily encrypt your important hidden files in Linux:
- Update your package repository with the command below to ensure you have the latest package information before installing any software.
sudo apt update && sudo apt upgrade
- Type y and press Enter to continue with the update installation.

- Install and set up an encryption tool like GPG or VeraCrypt on your Linux machine. In my case, I executed the following command:
sudo apt install gnupg
- If this tool is already installed on your machine, it’ll display the following output:

- Next, run the
ls -a
command to list all the files in the current directory, including the hidden ones. Then, identify the hidden files that you want to encrypt.

- Use the encryption tool’s commands to encrypt the hidden files. For example, with GPG, you can run the following command to encrypt a file:
gpg --encrypt filename
- Replace the filename with the actual name of the hidden file that you want to encrypt. Make sure that you’ve already generated the key using
gpg --gen-key
to make this method work.

- Follow the tool’s instructions to set a strong passphrase or password for accessing the encrypted hidden files.

- When you are done, you’ll have the encrypted hidden file in that particular folder.

Remember to keep your passphrase or password secure and confidential.
How to Hide Files and Directories in Linux
To hide files or directories in Linux, you can rename them by adding a dot (.) at the beginning of their names. Here’s how this method works:
- Locate the file or directory you want to hide.

- Then, right-click on the file and click the Rename from the context menu.

- Adding a dot (.) at the beginning of the file name. Then, click the Rename button.

- Now, this file has become a hidden file as its name starts with a dot.

5 Best Practices When Working with Hidden Files in Linux
By following the best practices when working with hidden files in Linux, you can ensure the effective management, security, and usability of hidden files in your Linux system. Here are the five best practices to keep in mind when working with hidden files in Linux:
- 💾 Regular Backups: Regularly back up hidden files and directories. This ensures their safety and recoverability. Use commands like
rsync
to back up hidden files while excluding other files from the backup. - 📝 Descriptive Names: Use descriptive names for hidden files and directories. This enhances organization and readability. For example, rename
.folder2
to.webserver-config
to make file management easier and more organized. - 📂 Consistent Organization: Maintain consistent file organization for hidden files and directories. Create dedicated hidden directories like
.hidden-data
and categorize files by purpose, such as configuration files or personal scripts. - ⚠️ Backup Before Modifying: Always create a backup copy before modifying hidden configuration files. Use the
cp
command to make a backup. This ensures you can restore the original if something goes wrong. - ❌ Understand Before Deleting: Avoid deleting hidden files without understanding their purpose. Hidden files often contain crucial settings. Research their purpose to avoid issues or malfunctions in your system or applications.
To Sum Up
In this article, I have walked you through the step-by-step methods to show hidden files in Linux using both the command line and graphical user interface. I have also explored how to create hidden files and hide files and directories efficiently. Additionally, I have also covered advanced techniques along with best practices for managing these files securely and effectively.
To further enhance your Linux skills, I recommend:
- Reading about different ways to set special permissions in Linux, which will help you manage file access and security more effectively.
- Learning to unzip
.gz
files in Linux to improve your file-handling capabilities. - Exploring the best ways to use the
grep
command, which will significantly enhance your ability to search and filter text efficiently within files.
Frequently Asked Questions
How can I restore visibility to hidden files in Linux?
ls -a
command in the command line interface. That is, in most graphical Linux file managers, there is usually a setting or option to display hidden files. Once enabled, hidden files will be visible alongside other files in the file manager. Similarly, when using the command line interface, the ls -a
command lists all files, including hidden files, in the current directory.Are hidden files and folders the same in Linux?
Can hidden files impact system performance?
Are hidden files recoverable if accidentally deleted?
How do I change permissions on hidden files?
chmod
command with permission codes or symbolic notation. For example, chmod 644 .hiddenfile
sets read and write permissions for the owner and read-only permissions for others. Symbolically, chmod u+rw,go+r .hiddenfile
achieves the same result.