If there is a file and the filename starts with a dot, does that mean you created the file and you are hiding stuff in it, or can the files get created on their own without you creating the filename?

marked as duplicate by Olorin, roaima, ilkkachu, Mr Shunz, Thomas Mar 16 at 10:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    It means the file is hidden. Period. You may create such a file, or it can be generated by the system. There are many hidden files in your home folder storing your configurations. If you use bash, one important file among those is .bashrc. – Weijun Zhou Mar 14 at 8:25
  • 1
    WeijunZhou, "It means the file is hidden. Period." I'm afraid that's just wrong. The default position of ls, most GUI file managers, and shell globs is to ignore such files, but that is all. Nothing else differentiates or even cares. – roaima Mar 14 at 23:20
  • @roaima That is pretty much one can say about file names. It's like asking about what .txt means in Windows. You may say that only some programs care about the .txt suffix and others don't, but that is the convention people use. There's nothing special at all in the file system for .txt files but I think no one will question the answer that .txt means the file is a text file in general if asked about. – Weijun Zhou Mar 15 at 10:40
  • @Olorin The main point of this question seems to be "what created the hidden file?". – Kusalananda Mar 15 at 10:42
  • 1
    @Kusalananda maybe, but that's not what's been asked. – roaima Mar 15 at 11:15

The only thing "special" about a file or directory with a leading dot in its name, such as .myfile, is that it will not show up in the output of ls by default. It will also not be matched by a file name globbing pattern that does not explicitly match filenames starting with a dot.

Assuming an initially empty directory:

$ touch .myfile    # this creates an empty hidden file
$ ls               # this will output nothing
$ echo *           # this will echo a *

These files are usually called "hidden", although they are only hidden from ls and filename globbing patterns, and not hidden in the sense of "being secret", or being malicious, or being totally undetectable, or being unreadable by others (that depends on the file's permission and the permission of its parent folder(s)).

Anyone can create hidden files, it's just a matter of putting a dot at the start of the name. The fact that a file is hidden says nothing about how it was created (explicitly by a user, or by running some program). Some applications create directories with hidden names (for storing configurations and cache files etc.) and others create hidden files.

For example,

  • The bash shell will often create .bash_history in your home directory, containing the commands that you have typed at the command prompt (so that you can easily recall them in a later session without having to retype them). The shell will also use .bash_profile and .bashrc in your home directory upon starting up. If these files exists, it is likely that they were copied to your account when it was created.

  • If you use SSH, then it's very likely that you have a hidden directory called .ssh in your home directory. This directory contains public and private SSH keys and may also contain some configuration file. This directory should not be accessible by others. It is unlikely that you created this directory.

  • Many desktop utilities will store their configuration files somewhere under .config in your home directory, and cache files under .cache. Again, it is unlikely that you created these directories.

Configuration files in users' home directories (and elsewhere) are often hidden in this way so that they don't clutter the output of ls.

To view all files in a directory, including hidden files, use the -a or -A option with ls (using -A will not show the . and .. names that are present in any Unix directory).

$ ls -a
.       ..      .myfile
$ ls -A

In the bash shell, * and other shell globbing patterns will not match hidden names. To get them to do that, enable the dotglob shell option with shopt -s dotglob.

$ echo *
$ shopt -s dotglob
$ echo *            # the * now matches a filename, so it is replaced by it

Not the answer you're looking for? Browse other questions tagged or ask your own question.