48

I am having a hard time grasping what dot-files are or what they are for. Are they directories? How do I navigate to them?

1

5 Answers 5

61

In Unix/Linux dot-files refers to files/directories with a . prepended to their name. Examples are ~/.bashrc, ~/.bash_profile, etc. The leading dot . is used as an indicator by software like bash and nautilus to not list these files normally but only when they are specifically requested like pressing Ctrl+H in Nautilus. This is because, generally, dot-files are used to store configurations for different applications but they are sometimes used otherwise as well. For example Mozilla creates a .mozilla folder which contains their configuration files as well as browser cache.

People tend to backup & also share their dot-files so others can boot-strap their own applications using those configuration files. An example of a site dedicated to sharing dot-files is http://dotfiles.org.

6
  • I would put 'configuration' in parens, and 'hidden' not. For example mozilla creates a .mozialla folder, which does not only contain configuration, but Cache too. Similar .mozialla-thunderbird, where all my emails live. Jan 12, 2012 at 4:59
  • these are almost exactly what I was looking for. The only thing I would like to know is how you would navigate to these hidden files or directories after they become hidden?
    – RafLance
    Jan 12, 2012 at 5:58
  • 1
    Hiding these files is a convention, not an OS service. Any program can access them normally; how to tell programs to display them depends on the program itself. You can see them on the console using ls -a, for example. Jan 12, 2012 at 7:51
  • In some (most?) open/save dialogs, you can also right-click in the file list and choose "Show hidden files" or something similar.
    – user
    Jan 12, 2012 at 8:34
  • 1
    Ctrl+H toggling hidden files visible/invisible was mentioned in the answer and is fairly common, not specific to Nautilus or whatever unknown "file explorer" you mentioned. It's a shortcut in many file managers and (e.g. PCManFM in my case) - and the file-managing dialogs of programs using the GTK+ GUI toolkit, which (and this is pure speculation) might be what popularised it in the first place. Sep 14, 2015 at 22:24
5

If you mean when there's a . in front of a file name... The file is hidden. It won't show up unless you make your computer show hidden files and folders.

Try making a new folder, and renaming it to something that starts with a . and then watch it disappear.

4

Dot files are hidden, as Daniel and Sai said before. If you list files in the directory, they normally don't show up.

In a GUI, mostly file-open/file-save dialogs, you hit the right mouse button, and get a context-menu, allowing you to show hidden files.

Here is, how to handle them in the shell:

example:

$ > touch a b c .d .e f.f g. 

(generated testdata)

$ > wc -l *
0 a
0 b
0 c
0 f.f
0 g.
0 total

As you can see, the first command does not reveal .d and .e

$ > wc -l .*
wc: .: Is a directory
      0 .
wc: ..: Is a directory
      0 ..
      0 .d
      0 .e
      0 total

wc -l .* shows them, and the 2 special files, . which is the PWD, the present working dir, and .. which is the parent of the pwd.

$ > wc -l .* *
wc: .: Is a directory
      0 .
wc: ..: Is a directory
      0 ..
      0 .d
      0 .e
      0 a
      0 b
      0 c
      0 f.f
      0 g.
      0 total

wc -l * .* works on normal and hidden files (which again repeats PWD and the upper directory, but for other commands, * .* might fit better, for example

 find -type f \( -name "*" -or -name ".*" \) -execdir wc -l {} ";"

Which will not show the directories . and ...

If you use firefox for file system browsing, file://home/joe you have an option box to show/hide those files.

2
  • 3
    ls -a also shows all and is a bit shorter than ls * .* ;)
    – Rinzwind
    Jan 12, 2012 at 8:31
  • Nice catch, you're right. ls is a bad example, I changed the example to use wc -l instead. Jan 12, 2012 at 9:34
3

To clear up some possible confusion... there is nothing special about files or folders beginning with a dot, but by convention, they are simply not displayed unless you specifically request them to be. They are, by convention, for configuration files or directories in your home folder, with the dot prepended (not appended) to keep the directory listings cleaner.

The conventional way to see them is by adding an a, for all, to the ls command if you are using a terminal. This can be combined with other switches (letters following a hyphen):

ls -a

In a graphic file manager, you will need to choose either "show hidden" or use the hotkey (in Nautilus, it is Ctrl-H) to see these files.

Note that you can still enter the name if you know it's there - it is a valid filename, and is no different than any other file or directory. It is opened and saved just like any other.

1

The how do I navigate to them wasn't answered from a GUI perspective. In nautilus do a Ctrl-H and you'll toggle visibility for "." files and folders in that nautilus window. There's also a selection for visibility in the View text menu.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .