Hiding a file or folder is a feature that helps you increase your device’s privacy and security. You wouldn’t want a 5-year-old child to mess up your most essential documents. And how would you feel if someone deleted your hours of work just as a prank?
The easiest way to tackle such ‘accidents’ is to keep your files hidden and later unhide them when needed. If you don’t know how to hide and unhide files on Ubuntu, then good news for you. Because that’s exactly what we will cover here.
Let’s show you how.
Show Hidden Files in Ubuntu 22.04 LTS (Jammy Jellyfish)
You can see hidden files using the terminal or the GUI. We’ll show you both ways so you can choose your preferred method.
Method-1: Using the ls command (terminal)
Open your terminal. The current directory is the home directory when you open the terminal. You can navigate to the destination directory where you want to see the hidden files. Use the cd command to go to the directory. Say, you would like to see the hidden files inside Pictures. This is how you go into the Pictures directory.
For this tutorial’s purpose, I’m just going to stay on the home directory. So I don’t need to apply the cd command.
To display the files and directories within a directory, you use the ls command.
But there are no hidden files shown here. To show hidden files, you need to use the -a flag with the ls command.
After using the above command, you will see some new files appearing with a period(.) in front of them(without parentheses).
These are the hidden files. -a stands for all. So when you add the -a flag with the ls command, the files starting with a period(.) (in other words, hidden files) are not ignored and are shown.
Method-2: Using the dir command
The dir command works in a similar way as the ls command. It displays the content inside a directory. In order to display hidden files, you have to use the -a flag again
Show hidden files only
If you want to show hidden files exclusively, and no other files, then use this command
ls -d .[^.]*
Likewise, you can also use the dir command in the same way.
dir -d .[^.]*
It will only display the hidden files and directories.
Method-3: Using the file manager(GUI)
If the terminal isn’t your thing then you can show hidden files from the GUI as well.
Go to the destination directory using the file manager.
For me, it’s the home directory. There are two ways you can reveal the hidden files.
- Using the keyboard shortcut
- Ticking Show Hidden Files from the view options
To show the hidden files using the keyboard shortcut, press Alt + H.
The other way is to click buttons to unhide files. First, click the view options button. Then tick Show Hidden Files.
After ticking the option, the hidden files will appear.
Since the files and directories are sorted alphabetically, the hidden files will be listed after the unhidden files. This is because hidden files start with a period(.) and symbols come after alphabets in the sorting order.
Hide files on Ubuntu (Terminal & GUI)
Now that you know how to show hidden files, it’s time to learn how to hide files.
There is no ‘Hide file’ option on Ubuntu. However, you can hide a file using the knowledge of how to show hidden files. Hidden files start with a period, remember? So all you have to do is add a period in front of the file or directory to hide it.
For test purposes, I’m going to create a new file first. You can create a new file using the touch command.
Now, you need to rename the file and put a period(.) in front of it. There are three ways you can rename a file.
Method-1: Use the mv command
In case you thought the mv command is used only for moving files, it can be used for renaming files as well. This is the full syntax of renaming a file using the mv command
mv oldname newname
So to rename your file or directory to make it hidden, you need to use the command like this
mv newfile .newfile
The file will be hidden automatically.
Method-2: Press F2 to rename the file
Left-click on the file. Now press F2. You will get a prompt to rename the file. Type in the new name with a period(.) in the front. Press Rename to complete the action. Your file is now hidden.
Method-3: Rename file from file options
Right click on the file. You will see many options related to the file. You only need two. The Rename option or the Properties option.
If you press the Rename option, you’ll get prompted to the rename window as before. You can rename the file with a period(.) in front of it.
Pressing the Properties option will open a different window with all the properties of the file. You can rename the file from there in the same way to hide the file.
Ubuntu Show Hidden Files -- Conclusion
Knowing how to hide and unhide your files can secure your important data from falling into the wrong hands. In this tutorial, we tried to cover every method to show or hide files and directories on Ubuntu. Hope this will help you as a beginner Ubuntu user.
Let us know in the comments which method you liked most.