How to hide files and directories in Linux

In Linux, you can use the “.” (dot) character at the beginning of a file or directory name to make it hidden. (https://spellpundit.com/) When a file or directory is hidden, it will not be displayed when using the ls command without the -a option (which shows hidden files) and by default in most file managers. Here are a few ways to hide files and directories in Linux:

  1. Renaming the file or directory:
mv file.txt .file.txt

or

mv directory/ .directory/
  1. Creating hidden files and directories:
touch .hiddenfile

or

mkdir .hiddendirectory
  1. Using the chflags command:
chflags hidden file.txt

or

chflags hidden directory/

It’s important to note that while hiding files and directories can help keep your file system organized, it does not provide any security or encryption. Anyone who has access to your system can still access hidden files and directories.

Leave a Comment