Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was wondering what the difference between these two were:

~/somedirectory/file.txt

and

~/.somedirectory/file.txt

It's really difficult to ask this on Google since I didn't know how to explain the . when I didn't even know what to call it. But can someone describe the difference between including the dot and excluding it?

share|improve this question

migrated from programmers.stackexchange.com Sep 30 '11 at 15:15

This question came from our site for professional programmers interested in conceptual questions about software development.

add comment

5 Answers 5

up vote 3 down vote accepted

Under unix-like systems, all directories contain two entries, . and .., which stand for the directory itself and its parent respectively. These entries are not interesting most of the time, so ls hides them, and shell wildcards like * don't include them. More generally, ls and wildcards hide all files whose name begins with a .; this is a simple way to exclude . and .. and allow users to hide other files from listings. Other than being excluded from listings, there's nothing special about these files.

Unix stores per-user configuration files in the user's home directory. If all configuration files appeared in file listings, the home directory would be cluttered with files that users don't care about every day. So configuration files always begin with a .: typically, the configuration file for the application Foo is called something like .foo or .foorc. For this reason, user configuration files are often known as dot files.

share|improve this answer
add comment

To start with ~/somedirectory and ~/.somedirectory are different directories (mkdir wont fail with a File Exists message).

The ls command will not show those entries starting with the ..

If you ls -a, then ls will show both directories.

share|improve this answer
2  
ls -A displays files and directories that start with . but doesn't include the . and .. entries. –  Julian Sep 30 '11 at 15:47
add comment

For details on the Unix file system check the standard. Specifically, dot files are used for configuration files in a users directory, and if a program has more than one, it should put them into a dot directory.

This hides the files from the user, unless they want to find them. That way they don't get in the way, and tools don't go messing with them accidentally.

share|improve this answer
add comment

The leading "." in a directory or file name causes that directory or file to be hidden when doing a ls command.

share|improve this answer
    
You can view all files starting with "." with ls -a. –  Sardathrion Sep 30 '11 at 15:06
add comment

Like @DaveNay already said, that period will cause the file or directory to be hidden.

For your second implicit question, this is how you search for that in google:

Just type in the search box: linux period before name

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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