How to Hide Files and Folders in Linux

Wondering how to hide files and folders on Linux?

Hiding files serves different purposes. Usually, users hide their files for privacy reasons. When there are multiple users on the same device, there may come the need to protect some personal files or folders. The privacy of your personal stuff can be protected by hiding them.  

Similarly, some of the system configuration files are also hidden by default so that they can not be accessed easily, preventing the system from unwanted disasters.

Every operating system provides you with the option of hiding files. In the case of Linux, this can be done using either the GUI or executable commands on the Terminal. In this article, you’ll learn how to hide files and folders on Linux.

So, let’s get started!

Hide New Files Using the Terminal.

Every file and folder present on your computer can be accessed and modified using the Terminal.

These files are named and saved in directories with their names. If you hide a file, the only difference made to the file is that a dot (.) is added at the beginning of the name.

So, follow these steps if you want to hide files and folders on Linux using the Terminal:

  1. First, open the Terminal.
  2. Once it starts, you can use the $ pwd command to check for your current directory and the $ cd command to change to the directories in which you want to create your file. 
  3. To create a new hidden file, you need to use the $ touch command and the dot (.) operator in tandem, as shown in the image below:
$ touch .filetobehidden.txt
  1. When you press Enter after typing the command mentioned above, a new hidden text file by the name “filetobehidden” is created. 
  2. You can see the file using the $ ls -a command.
Hide Files and Folders in Linux

These were the steps using which you can create a new hidden file. All it takes is the dot (.) operator to create and hide files and folders on Linux using the Terminal

Hide Existing Files Using the Terminal.

We first looked into creating new hidden files using the Terminal. In addition to that, you also have the provision of hiding existing files and folders on your Linux systems. 

To hide existing files, you will use the $ mv command with the dot (.) operator rather than the $ touch command. You also need to make sure that the current working directory contains the file you want to hide. 

Follow these steps to hide existing files using the Terminal:

  1. Start by opening the Terminal.
  2. Once opened, check for your current directory using the $ pwd command. Use the $ ls command to check for the unhidden files and folders present in the directory.
Hide Files and Folders in Linux
  1.  If the file you want to hide is not present in the home directory, use the $ cd command to navigate to the required directory.
  2. After reaching the respective directory, use the following command as a template to hide the file you want to.
$mv filename .filename
  1. Upon pressing the Enter key, the file has now been hidden. As you can see in the image below, the file named “box” is not listed.
Hide Files and Folders in Linux
  1. To verify whether the file was successfully hidden or not, use $ls with the “-a” operator to view all the hidden files in the current directory. 
  2. When you use the $ls -a command, you can see that the text file we hid is now visible. 

We used the $mv command to move the existing file to its hidden version. These were the steps you must follow to hide existing files or folders on your Linux system. 

Hide Files on Linux Using the GUI.

We discussed the different commands you can use to hide files on your Linux system using the Terminal. In case the Terminal isn’t your cup of tea, and you prefer to get on with things swiftly, there is always the option to use the GUI to perform all the tasks. 

Hiding files and folders using the Linux GUI is simple and easy to do. The only work you need to do is find the location of the file or folder you want to hide from other users. After locating them, hiding them requires just a few clicks of your mouse or touchpad and the keyboard.

Follow these steps if you want to hide files and folders on Linux using the GUI. 

  1. Open the Files application.
  1. When it opens, you can see all the files and folders present on your system.
  1. Locate the file you want to hide.
  2. To hide the file, we simply need to rename it and add a dot (.) at the start of the name. 
  3. We will hide the text file “ball1”  by renaming it “.ball1”.
  4. After renaming it, you can see that it is not present where it was before. 
home desktop
  1. To view the hidden file, choose the “show hidden files” option from the drop-down menu.
  2. Now you can see “ball1” with its name highlighted.
hidden files

These were the simple and easy steps of hiding a file on Linux using GUI.

Hiding files and protecting your privacy is necessary in certain cases. If those aren’t enough, you can always implement an additional layer of security by protecting your account altogether. One of the commonly used methods to implement this would be using fingerprint login for your Linux distribution.

This article aimed to guide and help you out in learning how to hide files and folders on Linux. We hope that we were able to solve your problem. If there are any queries related to this guide, please let us know in the comment section.


Leave a Reply

Your email address will not be published. Required fields are marked *