Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.
If friends or family members use your computer on a regular basis, it’s a good idea to create separate user accounts for them. But if someone you know wants to use your computer, you might want to hide some of your private files and folders.
We’ve covered how to hide files and folders on Windows and on a Mac. Here’s how to hide files and folders on Linux using the Terminal and the file manager, Nautilus, in Ubuntu. We’ll also talk about several ways to securely hide files and folders.
Hide Existing Files and Folders Using the Terminal
To hide an existing file or folder using the 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, we’re going to hide our FilesToHide folder in the Documents folder. So we use the following commands:
cd Documents/ cd FilesToHide/
You can also change to a folder by putting the full path in a single cd command:
The “~” character is a shortcut for your Home folder. The above path expands to /home/lori/Documents/FilesToHide/.
Then, we use the ls command to list all the unhidden files and folders in the current folder. We’re going to hide the HideThisFile.txt file. To hide a file or folder, add a dot (.) at the beginning of the name.
To add a dot at the beginning of the HideThisFile.txt file name, we’re going to use the mv command to rename the file:
mv HideThisFile.txt .HideThisFile.txt
Now when you use ls to list the files in the current folder, you’ll see the file you renamed is now shown.
View Hidden Files and Folders Using the Terminal
So how do you view files and folders in the Terminal once they’re hidden? The -a switch on the ls command lists all items, including hidden files and folders.
Use the cd command to go to the folder containing hidden items. Then, type the following command:
Hidden items with a dot (.) at the beginning of the name are listed.
Sometimes it’s easier to view the items in a folder in a list format, like the Details view in File Explorer in Windows. The following command lists all files, hidden and not hidden, in a detailed list format:
Create a New Hidden File or Folder Using the Terminal
You can also create new files and folders as hidden items. Use the mkdir command to create a new folder. To make that folder hidden, add a dot (.) at the beginning of the name, just like you would when renaming an existing folder to hide it.
The touch command creates a new blank file in the current folder. For example, the following command creates a new text file called MyFile.txt.
To create a new hidden file, add a dot (.) at the beginning of the name in the touch command.
View Hidden Files and Folders Using Nautilus
If you’re not comfortable using the Terminal to hide files and folders, you can use the file manager in your Linux system. Ubuntu is a commonly used version of Linux, so we’re going to show you how to view hidden items in Nautilus, Ubuntu’s file manager. File managers in other Linux systems may vary but likely operate similarly.
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 box.
You’ll see all items in the file manager now, including hidden items with a dot (.) at the beginning of their 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’re creating a new hidden text file, go to File > New Document > Empty Document instead.
The name of the folder (or file) becomes editable and is selected. Type a dot (.) and then the name you want. 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 name of the item becomes editable and is selected. Add a dot (.) to the beginning of the name.
How to Securely Hide Files and Folders on Linux
Hiding files and folders is not a secure 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 you can hide your files and folders and secure them at the same time.
If you’ve set up user accounts for others so they can use your Linux computer, you can protect the files in your account by changing their permissions.
If a nosy tech-savvy friend or family member signs into their account, they may try to access your Home folder from their account and view your files. Changing permissions on a file prevents them from viewing that file. You can change permissions on hidden files as well as non-hidden files.
If someone temporarily uses your account, they can change the permissions and view your files. We provide three additional options for securely hiding files and folders in the following sections.
There are three triplets of permissions that can be set in this order: Owner, Group, and World. Permissions for each triplet are read (r), write (w), and execute (x), in that order. To turn off a permission, replace the letter (r, w, or x) with a dash. The first position indicates whether the item is a directory (d) or not (-).
For example, say you have a document you want to protect and you want to give read and write permissions to the owner (yourself), read-only permission to the group, and no permissions to the world. The permissions for your document would look like the following:
If the item is a directory, the permissions would be the following:
For more information, see our article about permissions in Linux.
To change permissions on the command line, you use the chmod command. Here we’ll show you how to change permissions using Ubuntu’s file manager, Nautilus. File managers in other Linux systems most likely use similar options.
The permissions on files and folders are not shown by default in Nautilus. To show them, go to Edit > Preferences. Click the List Columns tab on the Files Preferences dialog box. Then, check the Permissions box under Choose the order of information to appear in the list view.
You’ll see the Permissions column in Nautilus, which shows a set of letters and dashes. Basically, the last three spots are the permissions allowed on this file or folder for other users, or the World.
On the following image, other users can currently read the selected file because there is an “r” (read) in the first of the last three spots. We want all three of the last spots to be dashes.
To change the permissions on a file, right-click on the file and select Properties.
Click the Permissions tab on the Properties dialog box. To prevent anyone else from viewing the file, select None from the Others (which is equivalent to World) dropdown list.
The last three spots in the Permissions column for the selected file are now all dashes. Other users do not have any access to this file or folder.
Compressing Files and Folders With a Password
If you have some files and folders to protect that you don’t use often, but you want to keep on your computer, you can store these files in a ZIP file protected with a password. Then, you can hide the ZIP file by putting a dot (.) at the beginning of the file name.
Open Nautilus and find the file or folder you want to compress. Right-click on it and select Compress.
On the Compress dialog box, enter the file name without the extension in the Filename box. Add a dot (.) at the beginning to hide the ZIP file.
Select .zip from the dropdown list to the right of the Filename.
Specify the Location where you want to save the ZIP file. Select Other from the dropdown list if the location you want is not listed.
Enter a Password to protect the ZIP file.
Click Create. You’ll see a dialog box saying the ZIP file was created successfully. Click Close.
You’ll now see a ZIP file that will be hidden when you press Ctrl + H to hide files in Nautilus.
Creating an Encrypted Folder
If you want to protect a folder containing files you use often, you can encrypt the folder and mount it like a drive. This makes it easy to access your protected files and protect them when you’re not using them.
We’ve talked about how to use Gnome Encfs Manager to encrypt folders. To hide a folder encrypted using Gnome Encfs Manager, add a dot (.) to the beginning of the folder name. The folder will be hidden and secure at the same time.
Hiding a File Inside an Image
If password protecting ZIP files or creating an encrypted folder is overkill for your purposes, but hiding files and folders only using the dot (.) method too insecure, there is another way.
You can hide a file inside an image using a method called steganography. We’ve talked about how to do this using the Terminal and using a tool called Steg.
Protect Your Data From Prying Eyes on Linux
Remember that hiding files and folders using the dot (.) method is not secure. But you can use some of the more secure options we provided along with the dot method to secure and hide your files and folders on Linux.
For extra protection, you can also secure Ubuntu with two-factor authentication.