How to Show Hidden Files in Ubuntu 22.04 LTS (and hide them)

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?

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.

cd [parent/destination]

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.

ls-command-to-check-the-files

But there are no hidden files shown here. To show hidden files, you need to use the -a flag with the ls command.

ls -a

After using the above command, you will see some new files appearing with a period(.) in front of them(without parentheses).

Files-starting-with-dot
Files starting with a period(.)

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

dir -a
Showing-hidden-files-using-dir-command

Show hidden files only

If you want to show hidden files exclusively, and no other files, then use this command

ls -d .[^.]*
Display-only-hidden-files-in-Ubuntu

    

Likewise, you can also use the dir command in the same way.

dir -d .[^.]*

It will only display the hidden files and directories.

dir-command-for-hidden-files

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.

File-manager

For me, it’s the home directory. There are two ways you can reveal the hidden files.

  1. Using the keyboard shortcut
  2. Ticking Show Hidden Files from the view options

To show the hidden files using the keyboard shortcut, press Alt + H.

Hidden-files-in-GUI-Linux-644x302

The other way is to click buttons to unhide files. First, click the view options button. Then tick Show Hidden Files.

File-and-folder-options
Show Hidden Files button

After ticking the option, the hidden files will appear.

Can-see-the-files-now
Hidden files appearing now

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.

touch newfile
Create-a-new-file

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
Rename-a-file-in-Ubuntu-Linux
Renaming a file to hide it

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.

Rename-the-file-to-hide-it

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.

rename-option-in-GUI
Options for tweaking your file

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.

file-properties

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.

Zunaid Ali writes for businesses that breathe Technology. His tech tutorials have helped thousands understand the use of tech for a better life. He loves to code and learn new technologies.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.