Most of the time, you share your Linux desktop with friends or colleagues while working in your workplace. So, you need to hide your personal files as well as directories from others. To do this, you need to create hidden files or folders that will not be visible to everyone. Some Linux users don’t have enough knowledge to create a hidden file on their system.
In this article, I will provide you with a complete guide on 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 must perform the following operations:
- Click Actions on the desktop and open a terminal application in CentOS 8.0.
- You will now list the actual files and directories on the terminal. To list files and directories, you need to run the below command on a terminal:
Create hidden directory
To create a new hidden directory, you will first create a directory using the following command:
You can see the result in the above image. We have created a directory called .mydirectory. Here ‘.’ used to create a hidden directory. If you list directories and files, this hidden directory will not show up on the terminal.
You can also hide the existing directory. 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 the Documents folder. You made this directory hidden by running $ mv personaldrive .personaldrive. If you specify the Documents folder, it will not be visible on this drive.
Using the graphical interface, you can also create a hidden directory. On CentOS 8.0, under Actions, click Files to select it. You will create a hidden directory and name it .personaldrive.
Create hidden file
You can create a hidden .txt file using touch or echo command. To make a hidden file, you write the following command in a terminal window:
For example, you created a hidden file called .private.txt using a touch command.
Similarly, you can also make an existing file hidden. Enter the following command to convert an existing file as hidden:
$mv file_name .file_name
For example, you have created a hidden file “resume.txt”. Use the command ‘$ mv resume.txt .resume.txt’ to create a hidden file from an existing file.
When you list the files down, they won’t show up on the terminal.
Using the graphical interface, you can also create a hidden file. You will create a hidden text file named ‘.resume.txt’ or you can customize it according to your requirements.
How to see hidden files and folders in CentOS
You can see the hidden file using both the GUI and the terminal.
List hidden files or directories using terminal
To display hidden files or folders. You will type the following command in a terminal window:
In the above command, you can also view those files that have certain permissions.
Viewing hidden files using a GUI on CentOS
Using the graphical interface, you can also view hidden files. Open the “Home” directory on CentOS 8.0. You will click the top right icon that is present with the window’s undo icon. A drop-down list will appear where you check “Show hidden files”. You can see in the image below:
You can now view hidden files on your CentOS 8.0. You can also change the permission on the hidden drive for security purposes. Right click on a hidden drive. Select “Properties” among all the options and click on it. A dialog box will appear on your system screen.
Click “Permissions” and change the access settings according to your needs.
In this article, we have learned how to create hidden files and directories using terminal or GUI. You also learned how to view hidden files on CentOS. I hope you find this guide helpful in the future. For more information, in case of any problems, you can leave a comment in the comment box below.
How to hide a file or directory on CentOS