How to hide a File or Folder in Ubuntu

If you are using a shared Ubuntu system, you might be concerned about the privacy of certain files and folders residing on your system. One of the ways to make your files/folders private is to make them “hidden”. The hidden content is not listed in your File Manager or the Terminal (command line) by default. The trick here to make your files hidden is to add a dot at the beginning of the filename. All such files are considered hidden by Ubuntu and are not listed in the standard view. In this article, we will explain how you can make a file hidden, both through the command line and the Ubuntu UI.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.

Hide a File/Folder on the Command Line

Open the Terminal application either through the Application Launcher search or by using the Ctrl+Alt+T shortcut.

Here, I will be hiding a file named ‘PrivateFile’ as an example. When I list the contents of my Home folder, I am able to see the mentioned file as follows:

Hide files in Ubuntu

In order to make a file hidden, you need to add a dot ‘.’ before its name. We will make use of the Ubuntu mv command to rename the file by using the following syntax:

$ mv [filename] [.filename]

For example, I will add a dot to my file named PrivateFile as follows:

$ mv PrivateFile .PrivateFile

Hide a file

Now my PrivateFile is truly private. If I list the contents of my Home folder again with the help of the ls command, as shown above, I will not see the hidden file listed.

Tip: If you want to list all the files of a folder, including the hidden ones, you can use the -al flag with the ls command as follows:

$ ls -al

Hide a File/Folder using the Ubuntu GUI

Open the File Manager (Nautilus for Ubuntu 18.04). By default Ubuntu does not display any hidden files and folders; these are the ones that start with the dot ‘.’ character. In order to hide a file, right-click on it, and then select the Rename option from the menu. Then add a dot to its name as follows and click the Rename button.

Hide a file using Ubuntu GUI

Ubuntu will now consider this file as hidden and will not display it in the standard view.

Tip: There are two ways through which you can view hidden files and folders in the Ubuntu File Manager:

  • The simplest way to view hidden content is by using the Ctrl+H key combination while your file browser is open.
  • Another way that will display the hidden files and folders by default whenever you open the File Browser is as follows:

Click on the Options button indicated by three lines, from the top bar in the File Manager. From the menu that opens, check the Show Hidden Files option.

Show hidden files

Your file browser will now, and always, display the hidden contents available to you. Hope this small trick will give you access to the files and folders that you might sometimes need to view and configure private settings in Ubuntu.

After reading this article, you can make your files private by adding just a dot before them, either through the UI or the command line.