Working with hidden files in Linux

Hidden Files

Hidden files in Linux are the files that are not listed when the user runs the ls command. The name of a hidden file starts with a. dot(.) In Linux, not only files, but directories can be hidden as well. Files are hidden in Linux for many reasons. One of them is to make sure that users don’t accidentally modify the contents of these files. Another could be to prevent the accidental deletion of these files. On shared systems, files could be hidden for privacy issues.

Most hidden files contain environment settings or data that are accessed by programs being run by the user. They’re not intended to be edited by the user, only the application should have access to them. That’s why they’re hidden from the user’s normal view. These can be configuration files, log files. Examples of system files that are hidden are “.profile“, “.bashrc,”  “.vimrc”

How do I show hidden files in Linux?

In the Linux terminal, the ls command is used to list all the files, but as we discussed, this will not list hidden files. Running simple ls will yield output like the one shown below.

Ls Command

To show hidden files in Linux, you can use the ls -a option as shown below to display “all” files:

$ ls -a
Ls -a Command

We can now see hidden files being listed. All the files starting with a dot are hidden files. In GUI this can be done by pressing Ctrl+H while viewing a directory. That will list all the hidden files in that directory.

To get a more verbose output in a list manner, use :

$ ls -al
ls -al

View hidden files and directories using ‘find command’

We can use the find command in the following manner to find and list all the hidden files, starting from the current directory:

find . -name ".*"
Display Hidden Files Using Find Command
Display Hidden Files Using Find Command

For displaying the hidden directories, we enter the following command,

find . -type d -name ".*"
Display Hidden Directories Using Find Command
Display Hidden Directories Using Find Command

View hidden files and directories using ‘dir command’

With the dir command, we can display a list of hidden files in the current directory.

dir -d .*
View Hidden Files And Directories Using Dir Command
View Hidden Files And Directories Using Dir Command

Viewing Exclusively Hidden Files 

Let’s first understand what exclusively hidden files are. In Linux, “exclusively hidden files” refer to files that are hidden but are not part of the parent directories . (current directory) and .. (parent directory).

To unhide them we use the following command,

ls -dl .[^.]* <directory path>
Viewing Exclusively Hidden Files In Linux
Viewing Exclusively Hidden Files In Linux

Create hidden files in Linux

To create hidden files, just create a file with the filename starting with a dot. This will let the Linux system know that the file is meant to be hidden.

$ touch .[filename]
Create Hidden Files

A file named .hidden.txt was created. The dot at the beginning of the filename rendered it hidden. When we run a normal ls, the file is not listed. However, upon running ls -a command the file is listed (4th row, 2nd column).

How do I view hidden files in Linux using the GUI?

The steps may vary depending on the type of desktop environment your Linux distribution is using.

In our case, we are using Ubuntu, which uses the Gnome desktop environment. Also, since I am using Ubuntu on my current system, we will be covering how to display hidden files in Gnome using the GUI(Graphical User Interface). The process to view hidden directories should be similar in any Linux Distro.

By Default, the hidden files and directories are not visible in the file manager of Ubuntu. FYI, Nautilus was the default file manager that used to ship with Ubuntu out of the box; now it has been rebranded as just Gnome Files.

In order to, make the hidden files and folders visible, open your file manager and go to the hamburger menu (one with three lines) next to the window commands, i.e minimize, maximize, and close window. when you press on it, you will get multiple options One of them is ‘Show hidden files’, Just check that, and you should immediately be able to unhide files on Linux.

Enable Hidden Files And Folders In Ubuntu Using GUI

Keyboard Shortcut to View hidden files in Linux using GUI

Pressing Ctrl + H can display the hidden folders and files in the GUI without having to go through the above approach, which is a handy shortcut.

Hiding an existing file or directory in Linux

Converting an existing file into a hidden file is simple and can be done with the following command :

$ mv [filename] .[filename]

mv command simply renames the file to have a name that begins with a dot. The same result can be obtained by editing the name of the file using the GUI. Edit the filename and add a dot at the beginning to hide the file in Linux.

Moving File

This command moved the existing input.txt to the list of hidden files. The opposite of this can also be achieved using the mv command, i.e., a hidden file can be converted into a normal file.

$ mv .[filename] [filename]

Password-Protect the hidden files in Linux

We learned that just by hiding files and directories in Linux, it is very easy to unhide them using simple Linux commands. In order to truly protect the sensitive files, we need to go the extra mile and password protect them. To do this, we can use the following command,

Password-protecting the hidden file using ‘zip command’ in Terminal

First, let’s create a hidden text file,

touch .hiddenFile.txt

Now we add content to the file using a text editor like nano,

nano .hiddenFile.txt

Now that we finally password-protect the file using the zip command,

zip -e .hiddenFile.txt

Now, We’ll be prompted to enter and verify a password.

Password Protecting The Hidden File Using Zip Command

Lets verify if the above process hid the password protected zip file

Verifying If The Zip File Is Hidden
Verifying If The Zip File Is Hidden

Password-protecting the hidden file using GUI

First Step. Create a file using any program; in my case, I have already created a file (hiddenfile.txt) using text editor inside the Documents directory.

Second Step. Make a folder for the file to be put into. I created a folder called ‘test folder’ and moved the hiddenfile.txt in this folder.

Third Step. Open the archive manager from the activities menu and make the window smaller then place the archive manager to the side.

Forth Step. Navigate to the folder that needs to be compressed, drag the folder into the archive manager window. Archive Manager will give us the option to change the name(we can put the ‘.’ here itself to make the archive file hidden) of the archive file, compression algorithm. I’m choosing zip as it allows us to enter the password to encrypt the file. Enter the password under the other options menu, then hit the Save button.

Fifth Step. Hide the encrypted zip folder. We can do so by just renaming the zip file with a ‘.’ dot in front of the name. And Voila! We have an encrypted hidden file.

Password Protecting The Hidden File Using GUI In Linux


Files in Linux are Hidden to limit their visibility. These can be system files, application files, or files created by users. There are ways to view these files, however, one should be careful while dealing with files that are hidden (they are hidden for a reason). To learn more about hidden files, refer to the official documentation of Linux. Understanding how to manage hidden files is essential for Linux users to ensure both system integrity and data privacy.