chmod -R 421 .gimp, what does the period mean directly preceding the
gimp? Is that similar to the
The dot in that situation is part of the filename and has in the Linux/Unix context the meaning that the file or directory is hidden, you cannot see it in the file explorer (Nautilus, which is default on the vanilla Ubuntu), unless you press CTRL+H.
And, if you only use
ls in the terminal, you will not see it either unless you use the
-A flag with it (i.e.
ls -a or
ls -A or
ls --all or
However, the dot (
.) has different meanings in different contexts:
- For example in a path (
./file) it describes the current directory you are in, while
filein the parent directory.
- And there is even a command
.which sources (runs) bash script files. So
. ./file(mind the spacing) would source the script named
filein the current directory.
- and in a REGEX context, the dot means "any character".
.gimp in your example is a filename, the "." is the first character.
The significance of it is a normal
ls (ls=list files) won't show files with "." as the first character, it only lists with ls -a (or list files --all)
Nothing. It's part of the filename.
You appear to have a directory called
Any other discussion about it belongs in a question about why people choose certain filenames for things.
The leading dot in file or directory names doesn't carry any particular significance, as far as Linux itself is concerned. However, certain utilities (such as
ls or Nautilus file manager) consider such filenames as "hidden", that is they ignore them in their output, and will only show them if you provide a specific option.
Long ago, as the design of the Unix file system was being worked out, the entries . and .. appeared, to make navigation easier. I'm not sure but I believe .. went in during the Version 2 rewrite, when the file system became hierarchical (it had a very different structure early on). When one typed ls, however, these files appeared, so either Ken or Dennis added a simple test to the program. It was in assembler then, but the code in question was equivalent to something like this:
if (name == '.') continue;
This statement was a little shorter than what it should have been, which is
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) continue;
but hey, it was easy.
Two things resulted.
First, a bad precedent was set. A lot of other lazy programmers introduced bugs by making the same simplification. Actual files beginning with periods are often skipped when they should be counted.
Second, and much worse, the idea of a "hidden" or "dot" file was created. As a consequence, more lazy programmers started dropping files into everyone's home directory. I don't have all that much stuff installed on the machine I'm using to type this, but my home directory has about a hundred dot files and I don't even know what most of them are or whether they're still needed. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.
I'm pretty sure the concept of a hidden file was an unintended consequence. It was certainly a mistake.
Nowadays, this sort of became a convention to call them "hidden" even though their contents are not hidden at all. A real hidden, or anonymous file/anonymous inode, would be implemented via opening file and holding its file descriptor open, but unlinking it from the directory, which makes the data itself to be accessible only to the program that is holding that file, and its child processes (preferably forked after unlinking the file), since child processes inherit file descriptors. In fact, this is how bash implements here-docs.
Very different story is when filename is itself a dot
.., which actually have a bit of history behind them, and I suggest you read Why is the current directory in the ls command identified as linked to itself?
A dot at the beginning of a filename hides the file in common file managers and for common shell programs.
The reason is historical, when
ls hid the special directories
.. by hiding everything which starts with a period. Then people used filenames starting with a period to hide files, so they are only listed with
ls -a, for example to make configuration files invisible which are not needed in the ls output usually.
So the dot in
chmod -R 421 .gimp is not a modifier of the command, but a part of the actual directory name.