Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In linux, why are folders for configuration files always named *.d?


  • /etc/init.d
  • /etc/grub.d
  • /etc/apparmor.d
share|improve this question
AskUbuntu has the answer to your question. – Mehper C. Palavuzlar Jan 7 '11 at 13:00
So does the Linux and Unix StackExchange site:… – frabjous Jan 7 '11 at 16:51
This same question was asked on Server Fault about 8 hours ago. – Dennis Williamson Jan 7 '11 at 18:50
up vote 15 down vote accepted

The .d stands for directory. It is a convention to distinguish the directory-based configuration from a configuration based on a single configuration file. Often you will have both in some capacity, for example /etc/logrotate.conf and /etc/logrotate.d/.

It is also usually the case that all (reasonably-named) files in such a directory are automatically combined into a single configuration. Packages can then install files into a directory like that, and they will be used automatically. Again, /etc/logrotate.d/ is a good example. By constrast, a directory of configuration files that does not end in .d probably just contains random collation of configuration files belonging to the same package, and you cannot infer anything about how they are processed, example /etc/zsh/.

share|improve this answer

To expand a bit on Peter's answer, this .d pattern allows for simpler addition and removal of configuration files: for a given .d program, the admin has the ability to simply copy or remove a file into the .d directory without having to edit an existing config file.

For instance, if you wanted to add a cron job to your system, you could edit /etc/crontab with your new scheduled job using your favorite text editor. This is fine for a single server or handful of servers, but try doing that on 100 servers if you work in a datacenter/cloud environment. In the latter case, you could use something like sed with a temp file or a tool like ex to write the file in place, but there's a bit of risk here if you haven't crafted your command properly. Indeed, I've seen config files completely nuked due to a typo in these edit commands.

Now compare that to placing a file with your scheduled jobs into /etc/cron.d. You just copy the file into it, and the next time cron runs (typically every minute), it'll see the new file and will source/process it accordingly. This is great as Peter states if you like to roll your own packages: the /etc/cron.d file is just another file in the package archive that gets installed. On removal of the package, the cron.d file is removed and your cron no longer runs.

Finally, every program that has a .d directory may have their own implementation as far as how the files are sourced, such as include order and configuration overriding. So whenever you decide to place a file in a .d directory, always verify that it does what you want and don't just assume it works like it does for another program that has a .d directory.

share|improve this answer

You must log in to answer this question.

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