I keep reading/hearing that
/etc is for system configuration files. Can someone explain/give me some intuition for why these scripts that start/stop/restart various programs are usually in
/etc instead of
/usr or something similar?
Early on (both historically, and in the process of booting...),
/etc is a part of
/ (the first mounted filesystem), while
/usr was not (until disks got large).
/var holds temporary data, while these scripts are not temporary.
It's not that simple, but it started that way and there's little reason to rework the entire directory layout.
Startup scripts are actually an important part of the system configuration.
Even though the boot-up process is much less customized than it was 15-30 years ago, and most of the startup configuration has been automated, all those administrative choices that determine the start-up sequence are still present in
This represents a very centralized way to maintain and backup the system's configuration. On most systems, backing up
/etc is enough to allow a reinstallation of the whole system with ease. You simply do a full reinstall with the needed programs, and restore your
M. Dickey and M. Pelletier have both bought into the premises of the question. But the premises are wrong.
If you've read that "
/etc is for system configuration files" then you've read something that doesn't paint the full picture for you. Look at the name. It's "et cetera". People have put everything bar the kitchen sink in there at one time or another.
/etc/rcused to be (and on some systems still is) the program run to start everything up.
- The program image file for the first user process was
/etc/initat one point (in XENIX, for example, long before upstart was even an idea).
/etc/zprofile, and all of the rest are definitely scripts.
/etc/netstartis a program; as is FreeBSD's
- So too are FreeBSD's
/etc/rc.resume; and indeed
Similarly, if you've read that "scripts that start/stop/restart various programs are usually in
/etc instead of
/usr or something similar" then you've read something else that doesn't paint the full picture for you.
- FreeBSD/PC-BSD convention is to have a
/usr/local/etc/rc.d/directory for non-operating system
rcscripts for all sorts of things live there rather than under
- You'll find daemontools-family people putting some service management things into
/var/service, and similar places. (My nosh toolset, for one example, provides almost a thousand service bundles in
/var/sv. The only service bundles that go in
/etc/service-bundlesare the between 60 and 70 that are needed before
/usris mounted, including the services that mount and check
- systemd operating system conventions have some stuff living in
/etc/systemd, some stuff in
/run/systemd, some stuff in
/usr/lib/systemd, and (even though it's undocumented for inapplicable reasons) some stuff in
/usr/local/lib/systemd. Again, the majority of "things for starting/stopping services" are to be found under
/usrrather than under
You would do well to review the Filesystem Hierarchy Standard. It will explain (in detail) exactly why this is, but it also contains such information on many other paths you may be curious about.
The filesystem standard has been designed to be used by Unix distribution developers, package developers, and system implementors. However, it is primarily intended to be a reference and is not a tutorial on how to manage a Unix filesystem or directory hierarchy.
Digital UNIX quite sensibly placed the scripts under the
/sbin/init.d directory. And also HP-UX, according to the rosetta stone.