How to hide or unhide files and folders in Linux
Linux considers a file or folder hidden if the name starts with a dot (.). File managers such as GNOME Files or Dolphin will not show hidden files and folders by default. It is also the case when using command-line tools such as ls.
You can rename a file or folder and prepend a . to its name to hide, and removing the leading . to unhide. It is different from Windows as files and folders are visible or hidden based on file/folder attributes rather than the name.
You can rename a file or folder to hide and unhide them using graphical files managers or by using mv command at the terminal.
Steps to hide and unhide files and folders in Linux:
-
Launch terminal
-
List files and folders in a folder using ls.
$ ls temp/ file folder
-
Rename an existing file by prepending . to its name using mv to hide a file.
$ mv temp/file temp/.file
-
Run ls to list files and folders in the previous folder.
$ ls temp/ folder
-
Rename the hidden file by removing the leading . using mv to unhide the file.
$ mv temp/.file temp/file
-
Run ls again to list the files and folders in the folder.
$ ls temp/ file folder