Table of Contents
This tip is about the how to hide files and folders using a text file in Linux. So read this free guide, How to hide files and folders using a text file in Linux. If you have query related to same article you may contact us.
How to hide files and folders using a text file in Linux – Guide
For users using a shared Ubuntu system, you may be anxious about the privacy of certain files and folders stored on your system. One of the ways to make your files/folders private is to make them “hidden”. Hidden files are not displayed or listed in the file manager or the terminal (command line) by default. The strategy here to make your files hidden is to add a period to the beginning of the filename. All these files will be known to be hidden by Ubuntu and will not be displayed in the default view. In this article, we’ll explain How to hide a file, either through the command line or through the Ubuntu user interface.
We run the commands and procedures mentioned in this article on an Ubuntu 18.04 LTS system.
Hide existing files and folders using the terminal
To hide an existing file or folder using Terminal, press Ctrl + Alt + T to open a Terminal window.
Use the cd command to go to the file or folder you want to hide. For example, let’s hide our FilesToHide folder in the Documents folder. Therefore, we use the following commands:
Documents cd / cd FilesToHide /
You can also change to a folder by putting the full path in a single cd:command.
cd ~ / Documents / FilesToHide /
The “~” character is a shortcut to your Home folder. The path above expands to /home/ lori / Documents / FilesToHide /.
We then use the ls command to list all non-hidden files and folders in the current folder. Let’s hide the HideThisFile.txt file. To hide a file or folder, add a period (.) at the beginning of the name.
To add a period to the beginning of the HideThisFile.txt file name, let’s use the mv command to rename the file:
mv HideThisFile.txt .HideThisFile.txt
Now, when using ls to list the files in the current folder, you will see that the renamed file is shown.
So how do you view files and folders in Terminal after they’re hidden? The -a option on the ls command lists all items, including hidden files and folders.
Use the cd command to go to the folder containing the hidden items. Then type the following command:
ls -a
Hidden items with a period (.) at the beginning of the name are listed.
It is sometimes easier to view items in a folder in list format, such as the Details view in Windows File Explorer. The following command lists all files, hidden and non-hidden, in a detailed list format:
ls -al
You can also create new files and folders as hidden items. Use the mkdir command to create a new folder. To hide this folder, add a period (.) to the beginning of the name, as you would when renaming an existing folder to hide it.
mkdir .FilesToHide
The tap command creates a new blank file in the current folder. For example, the following command creates a new text file called MyFile.txt.
tap MyFile.txt
To create a new hidden file, add a period (.) to the beginning of the name on the tap command.
tap .HiddenFile.txt
If you are not comfortable using Terminal to hide files and folders, you can use the file manager on your Linux system. Ubuntu is a commonly used version of Linux, so let’s show you how to view hidden items in Nautilus, the Ubuntu file manager. File managers on other Linux systems may vary but likely operate in a similar way.
Go to Edit > Preferences.
Make sure the Views tab is active. Then check the Show hidden and backup files box in the Default view section. Close the dialog.
You will see all items in the file manager now, including hidden items with a period (.) at the beginning of the name.
You can also press Ctrl + H to show and hide hidden files and folders.
Hide files and folders using Nautilus
To create a new hidden folder in Nautilus, go to File > New Folder. If you are creating a new hidden text file, go to File > New Document > Empty Document.
The folder (or file) name becomes editable and is selected. Type a period (.) and then the desired name. Press Enter.
You can also easily rename a file or folder in Nautilus to hide the item. Right-click on the item and select Rename. The item name becomes editable and is selected. Add a period (.) to the beginning of the name.
How to Securely hide files and folders on Linux
Hiding files and folders is not a safe way to protect them. Anyone else accessing your system, who knows how to view hidden files and folders, can gain access to your hidden data.
There are several ways to hide your files and folders and protect them at the same time.
Final note
I hope you like the guide How to hide files and folders using a text file in Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.