How to create and manage hidden files in Linux

penguin hiding in a bush

Maria Korneeva/Getty Images

Hidden files are a standard feature in Linux. Some applications save configuration files and other data in hidden files or folders that aren’t visible by default. Fortunately, Linux makes working with hidden files very easy, whether in a GUI file manager or the command line.

Also: The first 5 Linux commands every new user should learn

Let me show you how.

How to create a hidden file

Let’s work with the example .zdnet.txt, which is a fairly straightforward text file. Either open your file manager to the folder containing the file or issue the command ls within that folder, and you’ll see the zdnet.txt file ready to be used.

Also: Thinking about switching to Linux? 10 things you need to know

To create a hidden file, all you have to do is save the file with a leading dot before the name. So, instead of zdnet.txt, the filename would be .zdnet.txt.

If you already have a file named zdnet.txt, rename it to .zdnet.txt with either your file manager or the command line. With the file manager, right-click the file, select Rename, and add the leading period. The command to rename zdnet.txt to .zdnet.txt is:

mv zdnet.txt .zdnet.txt

You could also copy a standard file to a hidden file with the command:

cp zdnet.txt .zdnet.txt

The only difference is that you’ll retain the original file, which is not hidden and can be viewed via standard means.

How to view a hidden file from the command line

To view hidden files from the command line, you use the same command as you would for viewing standard files, which is ls. The difference is that you can use the -a option, which stands for all. When you issue the ls -a command, you’ll see all files within the current directory, whether hidden or not. You can use -a in conjunction with -l (for long list, which gives you more information about the files) like this:

How to view a hidden file in your file manager

Most file managers on Linux can present hidden files. Even better, most file managers in Linux use the same keyboard combination to do so.

Also: There’s a new coolest Linux distribution ready to wow you 

Open your file manager (such as GNOME Files, Dolphin, or Thunar). Once opened, navigate to the folder housing the hidden files and hit the Ctrl-H keyboard combination, which will show hidden files. Find the file you need, work on it, and then hit the Ctrl-H keyboard combination again to hide those files.

One thing to remember is that you can hide files of nearly any type. It doesn’t matter if the file is a .docx, PDF, png, jpg, html, or any other file type. You can hide them all in the way presented above.

Batch rename

There are several ways to batch rename files (renaming similar files simultaneously). One of my favorites is the Smart File Renamer, which allows you to rename several files. With this GUI application, you can easily rename as many files as you want and they are hidden. Smart File Renamer can be installed with Snap, like so:

sudo snap install smart-file-renamer

Open the app, add the files you want to rename, select Insert in the left dropdown of the right pane, add a dot in the next field, select Start from the right dropdown, and then click Rename at the bottom of the left pane.

The Smart File Renamer app.

Using Smart File Renamer to batch rename files so that they are hidden.

Screenshot by Jack Wallen/ZDNET

With Smart File Renamer you can not only rename the files but also move them. So, you might create a hidden folder (one that starts with a dot) and then batch rename all those files while simultaneously moving them to the newly created hidden folder.

Also: The best old-school Linux window managers that still hold up

And that is all you need to know about managing hidden files in Linux. This technique is a handy way to hide files away from plain sight. The only caveat is that anyone who understands Linux can reveal those files and view them. Therefore, you should consider encrypting or password-protecting files that contain sensitive data.

Source Link

LEAVE A REPLY

Please enter your comment!
Please enter your name here