195

find ./photos/john_doe -type f -name '*.jpg' -exec du -ch {} + | grep total$ If more than one invocation of du is required because the file list is very long, multiple totals will be reported and need to be summed.


193

Since the Unix file system predates Windows by many years, one may re-phrase the question to "why does Windows use a separate designator for each device?". A hierarchical filesystem has the advantage that any file or directory can be found as a child of the root directory. If you need to move data to a new device or a network device, the location in the ...


167

Originally, there was /bin for programs (essentially, executable binaries), and very soon /dev for device files and /lib for extra executable code loaded by programs (libraries). /usr also came in very early, first for user data, then as an extra OS area with its own bin and lib and then man containing the manual in electronic form. The source code was also ...


115

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


109

The forward slash / is the delimiting character which separates directories in paths in Unix-like operating systems. This character seems to have been chosen sometime in the 1970's, and according to anecdotal sources, the reasons might be related to that the predecessor to Unix, the Multics operating system, used the > character as path separator, but the ...


101

/run/user/$uid is created by pam_systemd and used for storing files used by running processes for that user. These might be things such as your keyring daemon, pulseaudio, etc. Prior to systemd, these applications typically stored their files in /tmp. They couldn't use a location in /home/$user as home directories are often mounted over network filesystems, ...


87

This is partly for historical reasons, and partly because it makes more sense this way. Multics Multics was the first operating system to introduce the hierarchical file system as we know it today, with directories that can contain directories. Citing “A General-Purpose File System For Secondary Storage” by R.C. Daley and P.G. Neumann: Section 2 of the ...


66

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


60

The best place to put system unit files: /etc/systemd/system Just be sure to add a target under the [Install] section, read "How does it know?" for details. UPDATE: /usr/local/lib/systemd/system is another option, read "Gray Area" for details." The best place to put user unit files: /etc/systemd/user or $HOME/.config/systemd/user but it depends on ...


56

The first hierarchical file system as we know it today was designed for Multics. The design is described in “A General-Purpose File System For Secondary Storage” by R.C. Daley and P.G. Neumann. A salient characteristic of this filesystem is that a directory is a file which can be contained in a directory like any other file. The file structure forms a tree, ...


52

du -ch public_html/images/*.jpg | grep total 20M total gives me the total usage of my .jpg files in this directory. To deal with multiple directories you'd probably have to combine this with find somehow. You might find du command examples useful (it also includes find)


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


41

Few reasons I can think of: In corporate environments, you can have thousands of users. If so, cron would have to scan through every single user's directory every single minute to check for the crontab file (whether it has been created, deleted, or modified). By keeping them in a single location, it doesn't have to do this intensive scan. Home directories ...


39

Ah yes this is a very confusing part if you've dealt with Unixes for any length of time. There is a standard that most Unixes "try" to follow called FHS - Filesystem Hierarchy Standard. Given I primarily use Red Hat based distros I'm most familiar with their take on FHS for Fedora, CentOS, and RHEL Linux distros. But I've used Debian & BSD based distros ...


37

From "Linux Filesystem Hierarchy", section /lost+found": As was explained earlier during the overview of the FSSTND, Linux should always go through a proper shutdown. Sometimes your system might crash or a power failure might take the machine down. Either way, at the next boot, a lengthy filesystem check using fsck will be done. Fsck will go ...


36

It's actually not the "traditional" location at all. Traditionally, anything you installed after the OS went into /usr/local, and indeed that's the "Classical Apache path layout" (their words) to this day. For a long time, it was /home/httpd. What you're seeing is that an Apache that has been configured for a particular OS -- whether that's Red Hat Linux, ...


36

There are no security concerns behind having a single directory tree. The guys who designed Unix had a bunch of experience with operating systems that required users to know what physical device contained a given resource. Since part of the purpose of an operating system is to create an abstract machine on top of real hardware, they thought it much simpler ...


34

Usage of /var/www is confusing only at first sight. According to the FHS, web server data should go to /srv. That is the main rule. However, it also says that deciding about the structure of /srv is the sole responsibility of the local administrator! Therefore packages must not put anything into /srv, and the default document root must not be /srv, ...


32

The .. entry in the root directory is a special case. From the POSIX standard (4.13 Pathname Resolution, where the . and .. entries are referred to as "dot" and "dot-dot" repsectively): The special filename dot shall refer to the directory specified by its predecessor. The special filename dot-dot shall refer to the parent directory of its predecessor ...


31

On linking You generally do not link /usr/local/* with /bin, but this is more of a historical practice. In general, there are a few "technical" reason why you cannot do what you're suggesting. Making links to executables in /bin can cause problems: Probably the biggest caveat would be if you're system is having packages managed by some sort of package ...


30

You can't, given the user creating the directory has sufficient permission to write on the parent directory. You can instead leverage the inotify family of system calls provided by the Linux kernel, to watch for the creation (and optionally mv-ing) of directory shop in the given directory, if created (or optionally mv-ed), rm the directory. The userspace ...


30

To answer literally based on the question of preventing a folder of a certain name to be created. touch shop You can't create a directory if a file with a identical name existing mkdir: cannot create directory ‘shop’: File exists


28

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


28

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


28

Note that the drive letter names from MS-DOS which persist into modern Windows are a red herring here. Drive letter names are not the best representation of a file system structure which has multiple roots. They are a strawman implementation of such a system. A properly implemented filesystem that supports multiple roots would allow arbitrary naming for the ...


28

The "more correct" depends on your distribution. You should check your distribution's guidelines on where to put software that isn't managed by the package manager (often /usr/local) OR on how to create your own package for it. As you said TeamSpeak just put everything in one folder (and may not be easy to reorganise), yes /opt/ is probably best. (But, ...


27

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


27

From man wget: -x, --force-directories: [...] create a hierarchy of directories, even if one would not have been created otherwise. E.g. wget -x http://fly.srk.fer.hr/robots.txt will save the downloaded file to fly.srk.fer.hr/robots.txt.


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


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