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:
- Click on the ‘Activities’ from the desktop and open the terminal application on your CentOS 8.0.
- 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
Create a hidden directory
To create a new hidden directory, you will create a directory first by using the following command:
$mkdir .directory_name
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.
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’.
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
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:
$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.
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
Or
$ls -al
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:
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.
Click on ‘Permissions’ and change access settings according to your needs.
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.