Most of the time you share your Linux desktop system with your friends or colleagues while you are working at the workplace. So, you need to hide your personal files as well as directories from others. For this purpose, you have to create hidden files or folders that are not visible to everyone. Some Linux users, don’t have enough knowledge to create a hidden file in their system.

In this article, I will provide you a complete tutorial about how to create a hidden file and directory on your CentOS 8.

Create hidden files and directories

To make a file and directory hidden, you need to perform the following operations:

  1. Click on the ‘Activities’ from the desktop and open the terminal application on your CentOS 8.0.
  2. Now, you will list down the actual files and directories on the terminal. To list down files and directories you need to execute the below-given command on the terminal:
$ls

File and Directory Listing

Create a hidden directory

To create a new hidden directory, you will create a directory first by using the following command:

$mkdir .directory_name

Create hidden directory

You can see the output in the above-mentioned image. We have created a directory with the name ‘.mydirectory’. Here, the ‘.’ is used to create a hidden directory. If you list down the directories and files then, this hidden directory will not be displayed on the terminal.

You can also make an existing directory as hidden. To do this, you need to run the following command on the terminal:

$mv existing_directory  .existing_directory

For example, you have a directory name as ‘personal’ in your ‘Documents’ folder. You made this directory as hidden by executing this command “$mv personaldrive .personaldrive”. If you will list down the ‘Documents’ folder then, it will not visible in this drive.

Hide existing directory

Using GUI, you can also make a hidden directory. In CentOS 8.0, from ‘Activities’ you will click on ‘Files’ to select it. You will make a hidden directory to set the name as ‘.personaldrive’.

Hide directory by using GNOME GUI

Create a hidden file

You can create a hidden ‘.txt’ file using touch or echo command. To make a hidden file you will write the following command on the terminal window:

$touch .file_name

Create hidden file

For example, you have created a hidden file with the name ‘.private.txt’ using touch command.

Similarly, you can also make an existing file as hidden. Type the following command to convert an existing file as hidden:

Hide existing file
$mv file_name .file_name

For example, you have made a ‘resume.txt’ as a hidden file. Use ‘$mv resume.txt .resume.txt’ command to create a hidden file from the existing file.

When you list down files, it will not be displayed on the terminal.

Using GUI, you can also create a hidden file. You will make a hidden text file with a name as ‘.resume.txt’ or you can adjust it as per your requirement.

Hide file by using GNOME file browser

How to see hidden files and folders in CentOS

You can see the hidden file using GUI as well as from the terminal.

List down the hidden files or directories using terminal

To display the hidden files or folders. You will type the following command on the terminal window:

$ls -a

List hidden files

Or

$ls -al

List hidden files with file details

In the above-mentioned command, you can also view those files that have certain permissions.

View hidden files using GUI in CentOS

Using GUI, you can also view the hidden files. Open the ‘Home’ directory on your CentOS 8.0. You will click the top right icon that is present with a window cancel icon. A dropdown list will be displayed from where you will mark ‘Show Hidden Files’. You can see in the below-mentioned image:

List hidden files with the GUI

Now, you can view the hidden files on your CentOS 8.0. You can also change permission on a hidden drive for security purposes. Right-click on a hidden drive. Select ‘Properties’ among all options and click on it. A dialogue box will have appeared on your system’s screen.

File properties

Click on ‘Permissions’ and change access settings according to your needs.

Access permissions

Conclusion

In this article, we have learned how to make hidden files and directories using the terminal or GUI.  You have also learned how to view the hidden files from your CentOS. I hope this tutorial would be useful for you in the future. For more information, in case of any problem, you can do comment in below comment box.

How to hide a file or directory on CentOS

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn