Why are some files and folders hidden

directorydot-filesfiles

I can understand the rationale of hiding files and folders in the /home/user directory to prevent users from messing around with things. However, I do not see how the same rationale can be applied to files in the /etc, /boot and /var directories which is the domain of administrators.

My question is why are some files and folders hidden from administrators? Example:

/boot/.vmlinuz-3.11.1-200.fc20.x86_64.hmac
/etc/.pwd.lock
/etc/selinux/targeted/.policy.sha512
/etc/.java
/etc/.java/.systemPrefs
/etc/skel/.bash_profile
/root/.ssh
/root/.config
/var/cache/yum/x86_64/20/.gpgkeyschecked.yum
/var/spool/at/.SEQ
/var/lib/pear/.filemap

Best Answer

You've misinterpreted the primary rationale for "hidden files". It is not

to prevent users from messing around with things.

Although it may have this consequence for very new users until they learn what a "dot file" is (dot file and dot directory are perhaps more appropriate and specific terms than "hidden"). All by itself it doesn't prevent you from messing around with things -- that's what permissions are for. It does perhaps help to indicate to new users that this is something they should not mess around with until they understand what it is for.

You could thus think of the dot prefix as a sort of file suffix -- notice they usually don't have one of those, although they can. It indicates this file is not of interest for general browsing, which is why ls and file browsers usually will not display it. However, since it's a prefix instead of a suffix, there is the added bonus, when you do display them (ls -a) in lexicographical order, to see them all listed together.

The normal purpose of a file like this is for use by an application (e.g. configuration). You don't have to use them directly or even be aware of them.

So, this "hiding" isn't so much intended to literally hide the file from the user as it is to reduce clutter and provide some organization conceptually.

Related Question