How to hide files and directories in Linux

In Linux, files and directories can be hidden by adding a dot (.) at the beginning of the name. When a dot is added to the beginning of a file or directory name, it is treated as a hidden file or directory and is not visible in the default directory listing.

  1. To hide a file in Linux, simply rename the file by adding a dot at the beginning of the name, for example:
mv file.txt .file.txt
  1. To hide a directory in Linux, simply rename the directory by adding a dot at the beginning of the name, for example:
mv directoryname .directoryname
  1. To unhide the files or directories, you can remove the dot from the file/directory name.
mv .file.txt file.txt
mv .directoryname directoryname

Note that this method of hiding files and directories is not secure and can be easily circumvented by someone with access to the file system. If you need to protect files and directories from unauthorized access, you should use file permissions and access controls. (https://www.whitestallion.com/)

Leave a Comment