Linux files starting with dot

Filename with dot in front [duplicate]

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?

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 .

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 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.

1 Answer 1

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». However, they are only hidden from ls and filename globbing patterns, and not hidden in the sense of «being a secret», or being malicious, or being 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). For example, some applications create directories with hidden names (for storing configurations and cache files, etc.), and others create hidden files.

  • 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). Upon starting up, the shell will also use .bash_profile and .bashrc in your home directory. If these files exist, they were likely copied to your account when it was created.
  • If you use SSH, you will likely have a hidden directory called .ssh in your home directory. This directory contains public and private SSH keys and may include some configuration files. This directory should not be accessible by others. It is unlikely that you created this directory manually.
  • 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 manually.
Читайте также:  Удалить файл командная строка линукс

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 present in any Unix directory).

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 .

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

Источник

What’s so special about directories whose names begin with a dot?

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?

5 Answers 5

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.

«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.» This sounds like the following: The concept of hiding files/directories that start with a dot has actually appeared to hide . .. . But later, people realized that being able to hide some files/directories has a value in it and hence, they began to put a dot at the beginning of the files which they want to be hidden. Is that really the case or just a speculation?

@Utku Actually, it was the other way round, as least at first: the original developer intended to hide only . and .. but made a mistake. It’s however possible that he was dissuaded from fixing it because some users found it useful, and the reason why user configuration files start with . is definitely so that they don’t clutter the output of ls in the home directory. I think we have a question about this here but I can’t find it, it may have been mistagged.

Early Unixes stored user configuration files in the user’s $HOME directory, so they’d be easily findable. As the number of user configuration files grew, «namespace pollution» was seen as a problem (why does ls show me 17 configuration files, plus the 4 I care about?). So, it was decided to preface the user configuration files with a » . «, and cause ls to default to not listing them. There are ls -a (list ALL) and ls -A (ALL except . , and .. ). This convention (don’t list dotfiles) only applies to ls (and shell wildcards). Other tools see all the files all the time

Читайте также:  Изображения в pdf linux

Источник

Linux directory starting with dot

Is there anything special about directories which start with a dot . in Linux (Ubuntu), such as ~/.vim ? Thanks.

3 Answers 3

Files and directories whose names begin with a dot ( . ) by default are not displayed in directory listings by the standard command ls . Therefore, they are traditionally used to store settings, preferences, etc.. Directory ~/.vim in particular surely contains personal preferences and settings for the text editor vim .

There are also two special directory names in this class: the directory named simply . is an alias for the same directory in which it appears (a self reference), and the directory named .. refers to the parent directory of . .

Many graphical file browsers ignore the convention of hiding file names beginning with a . , so it is not necessarily correct any longer to call these files «hidden». Nevertheless, that terminology persists.

Thanks for the great explanation. When I wanted to install ‘rails vim’ which is for editing rails code using Vim, all I had to do was to download a zip file ( rails.zip ) and unzip it inside .vim directory. Does that mean every time I start the program Vim it goes to folder .vim and loads the settings inside that directory? Is that how installation works in Linux? Just copying files in a correct directory? Thanks.

Yes, every time you start vim , it reads your personal settings from files in subdirectory .vim of your home directory. This is a common behavior of UNIX programs, but it is by no means universal.

In a sense, yes, software installation for the most part does simply involve dropping files in the correct places, but your particular experience was a special case. What you installed was not actually a program, but only Vim settings. Most Linux distributions have one form or another of system for managing software «packages», and this is the preferred mode for installing software that will be accessible to all users of the system. Ubuntu is such a distribution, but I cannot advise you about details.

Источник

Dot in front of file [duplicate]

If there is a file and the filename starts with a dot in front of it. Does that mean that 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. I’m just saying I have files with dots in front of them but I didnt create them.

Hello and welcome to the U&L stack exchange site! Please read over the help center to get more information on how to best post to this site. To get to your question, dotfiles or files starting with a dot character are hidden files. They can used for configuration files for applications you have installed or as profiles for your user settings. What files are you having an issue with? Please edit your post to include more context. Thank you!

I’m not having a problem with mybfilea never looked at my files I’m getting accused of hiding things in files and also that I have hidden apps and I’ve never downloaded hidden apps

Читайте также:  Зачем люди ставят линукс

Don’t worry and don’t let people accuse you of doing covert operations on your file system. Everyone can type in ls -alF in a command shell, and all hiding goes away. BTW you might want to use alias l=’ls —color=tty -alF’ and with it just type one single l to see it all. Try echo ‘set nu’ > .vimrc and voila, you’ve line numbers in your vi or vim editor. That’s all there is to it with «hidden» files.

1 Answer 1

This can likely be explained by a google post by Rob Pike about the origin of hidden files.

In the early days of Unix there was no concept of hidden files but the files . and .. existed to represent the current directory and parent directory. It became annoying to list these files every time ls was used so a simple change was made to the ls program to hide any file beginning with a . . This change, had the unplanned effect of allowing for «hidden files».

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.

So to answer your question those hidden files you didn’t create are likely some sort of config files from applications you have installed.

Источник

Is it bad practice for folder name to contain a dot (.)? How about a file name with multiple dots?

Sometimes it makes practical sense for a folder name to contain a dot ( . ). For example, you are storing data for an experiment conducted at L=0.5. So the folder might be named:

If the dot is the first character, the folder will be hidden. Other than that, I don’t think it matters.

5 Answers 5

As far as I know there are no issues with naming folders and files with a single or multiple dots.

Ubuntu generally does not use the dot and three characters (such as .txt) to identify the file type. So this has no special meaning in the Ubuntu context. This is useful when sharing files with Windows. Ubuntu uses Magic Numbers in the first few bytes of the file to identify the file type. However, Nautilus ignores the magic numbers if the dot and three characters extension is available to identify the file type. This setting can be changed. See Force nautilus to ignore extensions

In Ubuntu, starting a file or folder names with a dot, such as .experiment_L0.5 , makes the file or folder hidden. You can toggle the display of hidden files by pressing Ctrl + H in Nautilus. In Windows a file name starting with a . in front of it is not hidden. So if you transfer a hidden file named .experiment_L0.5 into a Windows system, it will be plainly visible.

In Ubuntu a file name can end with a dot, as it has no special meaning placed at the end. However, in Windows a dot separates the file name and extension, and a file name ending with a dot but no extension is not allowed. When I tried to create such a file in Windows I got a file with just the name, no dot, no extension.

Источник

Оцените статью
Adblock
detector