Raspberry Pi

How to Hide Files and Directories in Raspberry Pi

Sometimes if multiple users have access to the same system and the main user feels the need to hide a few important files or directories for privacy concerns, then for such cases; hiding the important data files or directories from the system is an ideal way to protect your data.

In this article, we will show you the easy way to hide files and directories in the Raspberry Pi system.

How to Hide Files and Directories in Raspberry Pi?

There are two ways to hide any file or directory in Raspberry Pi which are as follows:

Now let’s discuss each of these.

Method 1: Hiding Files/Directory Through Terminal

To hide any file, the user just has to use the below-mentioned mv command with “.” at the beginning of the file name:

Syntax

$ mv <file name> .<file name>

Example

$ mv my_newfile .my_newfile

Now let’s use the ls command to see the list of the files and see if the file is hidden or not:

$ ls

In the output you can see that the file is not displayed which means the file is hidden now:

To display the hidden file, use the below-mentioned command:

$ ls -a

If you scroll down a little bit, you will find out the hidden file in the list of files.

The directories can also be hidden and displayed in the same way just add a “.” before the name of a directory, here I am hiding the videos directory:

$ mv /home/pi/Videos /home/pi/.Videos

Now let’s see if the directory is hidden or not:

$ ls

And to display the directory same ls -a command can be used:

$ ls -a

Method 2: Hiding Files/Directory Through GUI

To hide files and directories through the GUI method just open the file, and select the file/directory you want to hide:

Then right-click on the file or directory and choose the “Rename” option from the drop-down list:

And add a “.” before the name of the file/directory and click “OK”:

As soon as you will click Ok, the file/directory will disappear immediately which means the file/directory is hidden now:

To display the hidden file or directory, click on the “View” tab and then click on “Show Hidden” option as shown in the image below:

And all the hidden files/directories will be displayed:

Similarly, to hide any directory just right-click onto the directory name and click Rename:

And Rename the directory by adding “.” before the name, then click Ok and directory will get hide automatically:

Just like files hidden directories can also be accessed from the Show Hidden Files option of the View tab:

And that’s all by following the same methods you can hide as many files or directories as you want.

Conclusion

Adding a “.” sign just before the file or directory name will hide the file from your Raspberry Pi system. Either you can use the terminal to rename the file or using the GUI method. For the terminal method, the hidden files can be displayed using the “ls -a” command while for the GUI method, the hidden files can be viewed from the “View” tab option as shown in the above guidelines.

About the author

Zahra Zamir

An Electronics graduate who loves to learn and share the knowledge, my passion for my field has helped me grasp complex electronics concepts and now I am here to share them with others.