To create a hidden file, you simply need to make sure the filename starts with a dot (.).
You can use the touch command, which is the easiest way to create a new, empty file in Linux. Try running this in your terminal:
touch .my_hidden_file
How to verify it:
-
If you run the normal
lscommand, you won't see it:ls(The output will look empty or only show your regular files).
-
Now, run
ls -a(the "all" flag):ls -aNow you will see
.my_hidden_fileappearing in the list!
Summary:
- Standard file:
myfile.txt - Hidden file:
.myfile.txt
It's that simple! In Linux, the leading dot is the only thing that tells the system to hide the file from the default view. Do you want to try creating a hidden directory (folder) as well? The rule is exactly the same!