Ubuntu

How to View and Create Hidden Files and Directories in Linux

How to View and Create Hidden Files and Directories in Linux

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.

In this post, we will cover how to view and create hidden files and directories in Linux OS.

Note: The command line and GUI procedure described here have been tested on Ubuntu 20.04 LTS.

Create Hidden Files and directories in Linux

You can create hidden files and directories in Linux:

  • Via Command Line
  • Via GUI

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.

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 as can be seen in the below screenshot 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.

View Hidden Files and Directories in Linux

You can view hidden files and directories in Linux:

  • Via command line
  • Via File Manager toolbar (GUI)
  • Via Keyboard shortcut (GUI)

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.

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.

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.

Unhiding Files and Directories in Linux

You can unhide the files and directories in Linux:

  • via Command Line
  • via GUI

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.

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.

That is all there is to it! In this post, we covered 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.

Similar Posts