What are hidden files in Linux and how do you create them?

A Gnome desktop showing three windows

Gnome.org

Linux is a very powerful operating system. Although having that much power at your fingertips might give you the impression that Linux is quite challenging, modern Linux distributions go a long way to proving that assumption wrong.

Take, for instance, the hidden file, which is a file that is not visible by default. The file is still there, unencrypted for anyone to view, so long as you know where it is and how to view it.

That brings up an important point. Hidden files are not password-protected, so anyone can view the contents of the file, so long as they know how.

Because of that, you should not keep sensitive information (such as bank accounts and passwords) in these files. Although you’re tucking those files away from the casual viewer, any user with even the slightest bit of Linux experience will be able to view those files.

But, for files containing information that doesn’t require encryption, where you simply want the file to not be in plain sight, the hidden file is a great way to go.

Let me show you how to create a hidden file from both the command line and the GUI file manager.

Requirements

The only thing you’ll need for this is a running instance of Linux. As hidden files are available to all Linux distributions, it doesn’t matter which you use. As far as the GUI is concerned, the process is mostly the same, but I’ll be demonstrating with GNOME Files (aka Nautilus).

That’s it…let’s make some Linux magic.

How to use hidden files from the command line

1. Open your terminal window

The first thing to do is open the terminal window, which can be done from your desktop menu.

2. Name and create hidden file

The secret to hidden files is that they begin with a period. So instead of hidden_file, you would create a file named .hidden_file. From the command line, that can be done with one of the following two commands:

touch .hidden_filenano .hidden_file

The first command above creates the empty hidden file, named .hidden_file. The second command opens a new file, named .hidden_file, for editing. Either way, you create a new file that is hidden from plain sight.

3. Viewing/editing hidden files

Here’s the trick. If you just issue the command ls those hidden files won’t show up. However, if you issue the command ls -a, the hidden files will appear in the output. If you want to open that file for editing, you could issue a command like nano .hidden_file to open it with the nano editor.

How to use hidden files from the GUI

If you use a GUI, you can easily work with hidden files. The Nautilus file manager doesn’t enable the viewing of hidden files by default. Fortunately, it’s as simple as clicking the Ctrl+H keyboard shortcut to enable or disable the viewing of hidden files. So, hit Ctrl+H on your keyboard and hidden files will appear.

Click the Ctrl+H keyboard shortcut a second time and hidden files will vanish from sight.

To create a hidden file in Nautilus, you first must create a TXT Template. For that, go back to the terminal and issue the command:

touch ~/Templates/text.txt

Once you’ve created the template, navigate to the directory you want to house the hidden folder in Nautilus, right-click any empty spot in the directory, and select New Document > text. This will automatically create a file named text.txt. Right-click that file and click Rename.

In the Rename File popup, give the new file a name that starts with a . and hit Rename. If the hidden file is viewable, hit the Ctrl+H keyboard shortcut again to hide the file. If you need to open that file from the file manager, you’ll need to unhide it and then double-click it to open it for viewing and editing.

And that’s all there is to using hidden files in Linux. Although this simple trick won’t keep those in the know from finding your files, it can at least obfuscate them from those who might not know about the ls -a or Ctrl+H tricks. Remember, this should never be considered a way to hide sensitive information, but rather a means of simply keeping a file out of plain sight.

, , ,
Previous Post
This supermarket doesn’t trust self-checkout shoppers, so it installed — oh, this
Next Post
Change one iPhone setting to foil thieves from stealing your phone and selling it

Related Posts