Hot answers tagged

121

/tmp is meant as fast (possibly small) storage with a short lifetime. Many systems clean /tmp very fast - on some systems it is even mounted as RAM-disk. /var/tmp is normally located on a physical disk, is larger and can hold temporary files for a longer time. Some systems also clean /var/tmp, but less often. Also note that /var/tmp might not be available ...


69

In general, if a non-system installed and maintained binary needs to be accessible system-wide to multiple users, it should be placed by an administrator into /usr/local/bin. There is a complete hierarchy under /usr/local that is generally used for locally compiled and installed software packages. If you are the only user of a binary, installing into $HOME/...


62

The POSIX.1-2008 standard says A pathname consisting of a single / shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. The standard further makes a distinction between filenames and pathnames. / is the pathname for the path of the root directory. The name of the directory is "the root directory", ...


50

First, an up-front conflict-of-interest disclaimer: I am a long-time GoboLinux developer. Second, an up-front claim of domain expertise: I am a long-time GoboLinux developer. There are a few different structures in current use. GoboLinux has one, and tools like GNU Stow, Homebrew, etc, use something quite similar (primarily for user programs). NixOS also ...


47

What cd am I using? If you're in Bash cd is a builtin. The type command even bears this out: $ type -a cd cd is a shell builtin cd is /usr/bin/cd cd is /bin/cd The system will use the first thing in this list, so the builtin will be the preferred option, and the only one that works (see the section below on What is /bin/cd). What's a builtin? I like to ...


37

slash is a separator; directory names do not include separators, but full pathnames include the separators. So the "root-level" / has no name. On most Unix-like systems, this is treated as a special case like . and .. (though of course there is no difference between the two at the root level). Nomenclature can differ. POSIX.1-2017, for example, lists some ...


35

This is a limitation imposed by having a very old BIOS and bootloader rather than Linux itself. The BIOS would only be able to access the first 1024 cylinders of the disk (see here for more information on what cylinders/heads/sectors are). This limitation would extend to bootloaders which, due to their simple nature, would not have their own disk drivers and ...


30

In the Debian Policy is written that Debian follows the File Hierarchy Standard version 2.3. Note #19 on the standard says: Deciding what things go into "sbin" directories is simple: if a normal (not a system administrator) user will ever run it directly, then it must be placed in one of the "bin" directories. Ordinary users should not have to place ...


30

To use your example: /sys/ doesn't contain "real" files, but is entirely provided by the kernel. Do you want all READMEs to become part of the kernel? You probably don't. Documentation is in /usr/share/doc. Which contains normal files on your harddisk. Some documentation about /sys and /proc is in the kernel source, that is in /usr/src/linux/Documentation (...


29

In my opinion, the right place is /srv/movies-enthusiast. A "service" does not have to be a daemon or program, it just has to be a service that the system provides (such as being able to get your movies there). Here's a quote from the FHS: /srv contains site-specific data which is served by this system. I definitely think your usage falls under that ...


29

As uther mentioned, /usr/local is intended as a prefix for, essentially, software installed by the system administrator, while /usr should be used for software installed from the distribution's packages. The idea behind this is to avoid clashes with distributed software (such as rpm and deb packages) and give the admin full reign over the "local" prefix. ...


27

/tmp may be, and sometimes is, cleaned on reboot. /var/tmp is preserved between reboots. See the Wikipedia article on the FHS.


26

By default, the owner and group of /usr/local and all subdirectories (including bin) should be root.root and the permissions should be rwxr-xr-x. This means that users of the system can read and execute in (and from) this directory structure, but cannot create or edit files there. Only the root account (or an administrator using sudo) should be able to ...


25

This change was introduced by BSD after 1985 (BSD 4.2 was still documenting /usr) and in or before 1988 (BSD 4.3/SunOS 4.1 hier(7) manual page already documents /home). It was quickly followed by Solaris 2.0 (which kind of merged System V and BSD) and was later adopted by most other Unix vendors. This is from the Solaris 2.0 useradd manual page: -D ...


25

The history /boot contains files that aren't used by the operating system, but by its bootloader. You'll find both files of the bootloader itself (like /boot/grub/* for Grub) and the Linux kernel (/boot/vmlinuz*) and often an associated initrd or initramfs. On a PC with legacy BIOS (as opposed to the newer UEFI found on most recent computers), the software ...


23

The directories /tmp and /usr/tmp (later /var/tmp) used to be the dumping ground for everything and everybody. The only protection mechanism for files in these directories is the sticky bit which restricts deletion or renaming of files there to their owners. As marcelm pointed out in a comment, there's in principle nothing that prevents someone to create ...


22

Another reason beside the mentioned BIOS problem is that a separate /boot partition allows the use of a file system for the / volume which the boot loader does not understand (without being limited to block list loading like with lilo).


21

/var/backups is specific to Debian. It is not specified in the FHS, and its use is not documented in Debian policy (See Debian Bug report logs - #122038). The behavior is described in http://ubuntuforums.org/showthread.php?t=1232703. While I agree with @fpmurphy that there is little danger of Debian ever removing your backup files in /var/backup, I think ...


19

In Unix, files (and directories are just files) don't have "names". Links have names, links are entries in a directory that map names to files. You might say, that links give names to files, but note: this implies that a file can have more than one name, since it can have more than one link. Since the root directory is, well, the root directory, there is ...


19

I would place them in /var/log/package_name; it satisfies the principle of least surprise better than /var/opt/package_name/log. I don't have a citation for this; it simply matches where I'd look for logs. I might also forego writing my own log files, and instead log to syslog with an appropriate tag and facility; if I'm looking for clean integration with ...


18

BOOTING IS HARD Booting... well... it really is the hardest part. Every time a computer boots it basically meets itself anew. It acquaints itself with its various parts, and for each one it meets it gains capability. But it has to pull itself up by its own bootstraps, so to speak, from square one every time. When designing a boot process the trick is to ...


18

/tmp is the location for creation of temporary files and directories. It's not usable for storing "well-known names" (i.e. names another process could be aware of without you having to convey the name to it somehow) because nobody has ownership over the namespace; anyone can create files there. As such you generally use it when you have a utility that needs ...


17

Some kind of "update" on this issue: Recently some Linux distributions are merging /bin into /usr/bin and relatedly /lib into /usr/lib. Sometimes also (/usr)/sbin to /usr/bin (Arch Linux). So /usr is expected to be available at the same time as /. The distinction between the two hierarchies is taken to be unnecessary complexity now. The idea was once ...


16

It is a builtin. See man bash for the details of cd and the Bash Manual for a description of builtins: Builtin commands are contained within the shell itself. When the name of a builtin command is used as the first word of a simple command (see Simple Commands), the shell executes the command directly, without invoking another program. Builtin commands are ...


16

No reason to have both /run and /tmp I think you're right. /tmp is essentially deprecated now we have /run. If your program is in a position to do so (which requires that it was installed as a privileged operation), then nowadays you would use a sub-directory of /run. This is for security reasons. E.g. the CUPS printing daemon does not run as root, but ...


16

You make your own mount point directories. If you want to ask why, I can only point to the great answer by Wouter Verhelst. Internal drives /mnt is a valid place to make your own if you like, and so is /. /mnt may have been used for this purpose by some historical installation systems, as well as for removable media (before /media). It's still valid for ...


15

They have the same purpose and functionality. Every version of UNIX/Linux will handle these directories differently. Historically, before the advent of RAM/swap based filesystems, you had disk-less systems where the / and /usr filesystems would be read-only and /var (variable) would be read-write. The /tmp name would be a symbolic link to /var/tmp. Later,...


15

It's a question of supportability - platform providers have learned from years of experience that if you put binaries in PATH by default, people will come to depend on them being there, and will come to depend on the specific arguments and options they support. By contrast, if something is put in /usr/libexec/ it's a clear indication that it's considered an ...


14

Because Unix and Linux have a decades old tradition of documenting with man pages (and, on GNU systems, info files ...). See man(1), man(7), man-pages(7). BTW, man command and pages are optional (and you won't install them on every Unix system). The file system hierarchy is described in hier(7). It is defined by the Filesystem Hierachy Standard available ...


Only top voted, non community-wiki answers of a minimum length are eligible