Linux is a multiuser operating system that is getting popular day by day. Many new computer users start using Linux OS on their machines. If you used Windows os previously then you might be familiar with the concept of hiding files and folders.
Now if you want to know how to hide or display a file or directory in a Linux machine then follow this article. Here we will discuss it in a simple and effective way.
How to Hide Files and directories Using Linux terminal?
In Linux when a file or directory name starts with a
. (dot) then file or directory becomes hidden by default. So whenever you need to hide a file or directory just rename it and put a dot at the beginning of the name. Suppose there is a file named
abc.txt, to hide this file rename it to
.abc.txt. Now run the command as it is given below to rename a file –
mv abc.txt .abc.txt
Or if you want to create a new hidden file then use the following command –
To hide a directory named new_dir use –
mv new_dir .new_dir
Or if you want to create a new hidden directory with the name new_dir then use the following command-
Display the hidden files and directories in terminal
To view the files and directories that are hidden, open your terminal and run the following command –
As you can see in the above image, there are many files and folders whose name is beginning with a
. (dot), these are hidden files and folders.
Hide or display the hidden files In GUI
If you are using GUI then you can toggle show/hide hidden files and folders by using the keyboard shortcut
ctrl+h. Or right-click where your hidden files or directories are located and then select show hidden files from the menu. This will display all the hidden files and folders on that location. To hide it again simply untick the show hidden files option. Now, look at the image below –
Remove hidden files and folders
You can easily delete the hidden files and folder using the terminal. Open your terminal and execute the following commands-
First, display and identify the correct file or folder that you want to delete with the –
And then to delete a file abc.txt which is marked in the above image use –
To delete a hidden folder or directory named .new_dir use –
rm -r .new_dir
I hope by reading this article you understand the concept of hiding files and folder on a Linux machine. Now if you have any query then you can write to us in the comments below.