15

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
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Question Overflow
  • 4,568
  • 19
  • 57
  • 84
  • 1
    possible duplicate of [Why are filenames that start with a dot hidden? Can I hide files without using a dot as their first character?](http://unix.stackexchange.com/questions/88875/why-are-filenames-that-start-with-a-dot-hidden-can-i-hide-files-without-using-a) – vfbsilva Aug 01 '14 at 13:25
  • @vfbsilva, I am not asking why a file with dot is hidden. I want to know why are some files hidden. – Question Overflow Aug 01 '14 at 13:32
  • 1
    look the second answer. The reason for those files you listed are either they are config files which should not be changed daily and are always present as .ssh and .bash_profile so you don't wanna know they are there.It is just a convention. Files at spool are temp files same as many of the others you listed so they should not be edited manually hence they are hidden – vfbsilva Aug 01 '14 at 13:36
  • @vfbsilva, if according to your reasoning, then we should have `/.etc` instead, since most files inside are not changed daily. And why would an administrator not want to know they are there? Doesn't make sense, at least to me. – Question Overflow Aug 01 '14 at 13:45
  • 3
    .ssh and .config are always named that, whether they're in a normal user's home directory or the root user's home directory. /etc/skel is supposed to be a prototype for new users' home directories, and the files have the same names there as they will in the newly-created directories. – Mark Plotnick Aug 01 '14 at 13:49
  • @Question Overflow well now its my opinion ahead. :) /etc/ are config files mostly which should be changed ie they are where the configurations are set. – vfbsilva Aug 01 '14 at 14:06
  • 2
    But those files are not _hidden_. The `ls` command just doesn't list files beginning with a dot by default(see `info ls`) - it's the design of this particular piece of software. –  Aug 01 '14 at 14:24
  • 1
    @illuminÉ: So how exactly would you define "hidden" if not as "not shown by default"? Note that this is not a property just of `ls`; also shell expansion of globs will not include those files unless the leading dot is explicitly included in the pattern, and usually file managers will not show them unless you choose the option "Show hidden files" (yes, the option does use that term). – celtschk Aug 02 '14 at 12:10

4 Answers4

17

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.

goldilocks
  • 86,451
  • 30
  • 200
  • 258
  • Thanks for your answer. Does it imply that these files are of lesser significance and hence are hidden to reduce clutter? – Question Overflow Aug 01 '14 at 14:16
  • 1
    I guess that depends on your perspective. It does say something about what the significance of the file (likely) is. They're used in home directories for *per user* configurations, but they're also used in directories generally to indicate *per directory* configuration. Two examples: [Version control systems](http://en.wikipedia.org/wiki/Revision_control) such as git will use them; when `git` scans a given directory, if there is a `.gitignore` file present, it will read it; and when you start `gdb`, it will read a `$PWD/.gdbinit` file if present (*and* a `~/.gdbinit`; another common method). – goldilocks Aug 01 '14 at 14:32
4

/etc/skel contains files to be copied to new user's home directories, therefore the names are, of course, the same as in an user's home directory. This explains /etc/skel/.bash_profile. The directory /root also is a home directory, namely the home directory of the user root. This explains /root/.ssh and /root/.config.

/etc/.pwd.lock seems to be a lock file. You normally are not interested in lock files, therefore it makes sense for it to be hidden.

For the other files, I don't know what they are for, but I'm sure there's also a good explanation why they are hidden.

And of course goldilocks is right that dotfiles are hidden not in order to prevent anyone to mess with them (the basic idea of Unix is to assume that the user knows what he does), but in order to prevent them cluttering up your directory listings (although for configuration files in the home directory I would have considered an etc subdirectory a better solution).

celtschk
  • 10,644
  • 1
  • 19
  • 27
  • +1 "configuration files in the home directory" was a pretty stupid idea. They're hidden just to appear whenever you really don't want see them. – maaartinus Jun 14 '16 at 03:01
3

This might be a highly opiniated answer, but I think the main reason dot files and dot directories are marked like that is not to hide or obscure them - I think it's just to let the user know that within those files and directories are program's and user's settings that can be changed by them or by the programs themselves.

The fact that dot files and dot directories are omitted by default by the command line ls and from the views in most file managers is just a commodity - you don't want to show the internal/details for everything, unless requested by the user; if the user wants to change a setting, and he/she can't do it through a GUI, then is very likely to find the setting he/she is looking for in a dot files.

e.g.> inside $HOME/.vimrc you will find the config setting for vim.

jimm-cl
  • 1,108
  • 9
  • 16
1

Dot files are meant to represent internally generated / manipulated files, mostly for configuration or log purposes. These are files which are not meant to be edited directly by the user and by doing so they might interfere with the source's ability to update the file.

Now both system and application can work with hidden files and it is up to application developers to correctly use hidden files.