Saturday, February 15, 2014

How to hide file/folder in linux ?

Method 1:
Make a file named .hidden in the same directory where our to-be-hidden file/directory lies. In our case, we want to hide /home/friend/Desktop. So we make a file named .hidden (don't miss the dot in front of hidden) in /home/friend. Next we add the name of the file/directory to be hidden into the .hidden file, one name in each line. Since we wanted to hide only the Desktop directory, we add a single line: Desktop into it. This was the solution to my friends problem as he needed to hide a file without renaming it. However, if you have the freedom to rename the file, then below two methods will be easier than this one.

Method 2:
Just rename the file/directory and prefix the name with a ' . ' (a dot). Files starting with a ' . ' are considered to be hidden files by linux.

Method 3:
Rename the file/directory and add a ' ~ ' to the end. eg: if the file name was secretfile.mk the new name will be secretfile.mk~. Linux considers files ending in ~ as backup files and hence hides them.

Note: In some machines you need to refresh the GNOME file browser to see the effect.

Do not use above methods to protect confidential data, as the hidden files can be easily seen using View -> Show Hidden Files (Ctrl + H) in Nautilus and ls -a in a terminal.

No comments:

Post a Comment