How to hide and unhide files or folder on a Linux computer

From time to time, we need to hide files on Windows, and most users already know how to do that on Windows computers. However, talking about other platforms, especially on Linux, hiding files and folders is a little different from that on Windows. You might not get the option to directly hide files and folders and later show them from the file manager or file explorer that you are using. Though you can configure displaying and not displaying hidden files on the file manager that you are using on Linux, you might not get an option to mark the items as hidden files and folders.

Well, you have to go through digging into the properties of the elements to hide and unhide files and folders on Windows, it is a lot easier on Linux computers, and you can simply do that either from the Linux Terminal or from the file manager that you are using. Hiding files and folders on Linux is the simplest ever, and once you come to know how to do that, you will question yourself why didn’t you knew it earlier.

So, without any further delay, let’s get started without you can hide and unhide files and folders on your Linux computer, and choose whether you want to display them or not.

Hiding and unhiding items on Linux

Open a Linux terminal and navigate to the location of the file or folder, which is meant to be hidden. For example, if you want to hide a file, navigate to the folder, where it is present or if you want to hide a folder, navigate to the location, where the folder is present. Note: Depending upon, where you are hiding the files and folders, you might need to have administrator privileges and you will have to enter the ‘sudo’ keyword before writing the commands.

Now type in the following command and hit the enter key.

mv [File/Directory name] .[File/Directory name]

Note: Replace File/Directory name text with your file or folder

Alternatively, you can even enter the path of the target file or folder, instead of manually navigating to the location of the file or folder.

Let’s find out two examples. Here I will hide a file with the name abc.txt,  and a folder with the name private.

So the command will go as follows for each of them.

For the file abc.txt, the command will be as given below.

mv abc.txt .abc.txt

While for the folder, the command is given below.

mv private .private

Hide files and folders on Linux 1 2

If you enter the complete path, for example, if the file, i.e. ‘abc.txt’ is present in ‘/Documents’, the command will go as follows.

mv /Documents/abc.txt /Documents/.abc.txt

Hide file or folder in Linux Graphically

Now the file or the folder is hidden. You can even do the same by using the ‘Rename’ option from the right-click context menu on your file browser and change the name of the file or folder to add a dot ‘.’ in the beginning.

Hide file or folder in Linux Graphically

Depending upon whether your file manager is configured to display hidden files or not, the files and folders might not be invisible or hidden from you. Besides that, the process to hide or unhide the files is also different, depending upon the individual file manager you are using on your Linux computer

However, if you are using the default File Manager on Ubuntu i.e. the Nautilus File Manager, simply click on the hamburger icon, and mark the option that says ‘Show Hidden Files’.

Show Hidden Files ubuntu

Show Hidden Files in Linux

Now the hidden files should be visible to you. If you want to hide the hidden files, simply unmark the option, and the hidden files will be hidden all over again.

To unhide the files you can simply remove the dot by renaming them within your file manager or by using the same command, but obviously in the opposite way, to unhide the files and folders that you have hidden. Just use the following format if you want to unhide files and folders on a Linux computer.

mv .[File/Directory name] [File/Directory name]

So for me, the commands for the text file and the folder will go as follows.

mv .abc.txt abc.txt
mv .private private

Now, you can understand, hiding and unhiding files and folders on a Linux computer is just a piece of cake. You just need to know the appropriate command and execute it. Well, that all depends upon the privileges that you have on a Linux computer. No matter, which distribution of Linux you are using, this tutorial is applicable for all Linux-based computers.

So that was all about how you can hide and unhide files and folders on a Linux computer. Do you have any questions in mind? Feel free to comment on the same below.