In the Linux system, there are a lot of hidden files which include mostly the user configuration file and the application files. You can also hide your files in your system if you are sharing them with some other person or due to any reason. However, remember that hiding the files does not protect your privacy, as anyone can see hidden files. Hiding files just makes the file invisible for the regular user exploring or listing the files. Also, it prevents the directory from being cluttered.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux System files and directories queries.
In this context, we shall look into how to view and create hidden files and directories in Ubuntu 20.04 LTS Linux OS.
You can create hidden files and directories in Linux:
1. Creating hidden files / directories Via Command Line
To hide a file or a directory in Linux, you simply need to add a dot (.) at the beginning of the filename. Let's say there is a file named testfile1.txt. To hide this file, we will have to rename the file to .testfile1.txt. You can use the command below to rename the file:
$ sudo mv testfile1.txt .testfile1.txt
After renaming the file, it will be hidden. Now, if you view this directory using the ls command, you will not be able to see the file.
2. Creating hidden files / directories Via GUI
If you prefer working graphically, you can hide your files via Linux File Manager. All you need is to just rename the file and insert a dot (.) at the beginning of the filename.
For instance, to hide a file named testfile1.txt, right-click it and choose Rename option.
Then add a dot (.) before a filename and then click Rename.
The file will be hidden after renaming. Now, if you view this directory in the File Manager, you will not be able to see the file.
You can view hidden files and directories in Linux:
1. Viewing hidden files / directories Via Command Line
To view hidden files and directories in Linux, use this command in the Terminal:
$ ls -a
This command will display all the hidden files (whose names start with a . (dot) symbol) in your current Terminal directory.
2. Viewing hidden files / directories Via File Manager Toolbar (GUI)
To view hidden files and directories in Linux File manager, click the three horizontal bars icon at the upper right corner of the File Manager. By doing so, a drop-down menu will show up. From there, check the Show Hidden Files check box.
This will display all the hidden files (whose names start with a . (dot) symbol) in your current opened directory.
3. Viewing hidden files / directories Via Keyboard Shortcut
You can also view hidden files by using the keyboard shortcut.
To view hidden files contained in a directory, open that directory in your File Manager. Then use the Ctrl+H keyboard shortcut to display the hidden files. To hide them again, use the same Ctrl+H keyboard shortcut.
You can unhide the files and directories in Linux:
1. Unhide files / directories Via Command Line
To unhide a file or a directory, you only need to remove the leading dot (.) from its name.
For instance, you have a hidden file named .testfile1.txt. To make this file unhidden, use the below command:
$ sudo mv .testfile1.txt testfile1.txt
This will rename the .testfile1.txt file to testfile1.txt and now the file will be unhidden.
2. Unhide files / directories Via GUI
To unhide a file graphically, open the File Manager in your Linux OS. Press Ctrl+H or check the Show Hidden Files box to view all the hidden files.
Then select your desired hidden file and then using the right-click menu, remove the leading dot (.) from its name. For instance, if your hidden file is .testfile1.txt, it should be renamed to testfile1.txt.
This article covers how to create and view hidden files and directories in Linux via command line and GUI. We also covered how to unhide the files and directories in Linux through a keyboard shortcut, command line, and File Manager. In fact, Linux, by default, hides many of the sensitive system files. Hidden files are usually system or application files, concealed to prevent accidental changes.