Coming from the Windows world, I have found the majority of the folder directory names to be quite intuitive:
-
Program Filescontains files used by programs (surprise!) -
Program Files (x86)contains files used by 32-bit programs on 64-bit OSes -
Users(formerlyDocuments and Settings) contains users’ files, i.e. documents and settings-
UsersUSERApplication Datacontains application-specific data -
UsersUSERDocumentscontains documents belonging to the user
-
-
Windowscontains files that belong to the operation of Windows itself-
WindowsFontsstores font files (surprise!) -
WindowsTempis a global temporary directory
-
et cetera. Even if I had no idea what these folders did, I could guess with good accuracy from their names.
Now I’m taking a good look at Linux, and getting quite confused about how to find my way around the file system.
For example:
-
/bincontains binaries. But so do/sbin,/usr/bin,/usr/sbin, and probably more that I don’t know about. Which is which?? What is the difference between them? If I want to make a binary and put it somewhere system-wide, where do I put it? -
/mediacontains external media file systems. But so does/mnt. And neither of them contain anything on my system at the moment; everything seems to be in/dev. What’s the difference? Where are the other partitions on my hard disk, like theC:andD:that were in Windows? -
/homecontains the user files and settings. That much is intuitive, but then, what is supposed to go into/usr? And how come/rootis still separate, even though it’s a user with files and settings? -
/libcontains shared libraries, like DLLs. But so does/usr/lib. What’s the difference? -
What is
/etc? Does it really stand for “et cetera”, or something else? What kinds of files should go in there — global or local? Is it a catch-all for things no one knew where to put, or is there a particular use case for it? -
What are
/opt,/proc, and/var? What do they stand for and what are they used for? I haven’t seen anything like them in Windows*, and I just can’t figure out what they might be for.
If anyone can think of other standard places that might be good to know about, feel free to add it to the question; hopefully this can be a good reference for people like me, who are starting to get familiar with *nix systems.
*OK, that’s a lie. I’ve seen similar things in WinObj, but obviously not on a regular basis. I still don’t know what these do on Linux, though.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Linux distributions use the FHS: http://www.pathname.com/fhs/pub/fhs-2.3.html
You can also try man hier.
I’ll try to sum up answers your questions off the top of my head, but I strongly suggest that you read through the FHS:
- /bin is for non-superuser system binaries
- /sbin is for superuser (root) system binaries
- /usr/bin & /usr/sbin are for non-critical shared non-superuser or superuser binaries, respectively
- /mnt is for temporarily mounting a partition
- /media is for mounting many removable media at once
- /dev contains your system device files; it’s a long story 🙂
- The /usr folder, and its subfolders, can be shared with other systems, so that they will have access to the same programs/files installed in one place. Since /usr is typically on a separate filesystem, it doesn’t contain binaries that are necessary to bring the system online.
- /root is separate because it may be necessary to bring the system online without mounting other directories which may be on separate partitions/hard drives/servers
- Yes, /etc stands for “et cetera”. Configuration files for the local system are stored there.
- /opt is a place where you can install programs that you download/compile. That way you can keep them separate from the rest of the system, with all of the files in one place.
- /proc contains information about the kernel and running processes
- /var contains variable size files like logs, mail, webpages, etc.
To access a system, you generally don’t need /var, /opt, /usr, /home; some of potentially largest directories on a system.
One of my favorites, which some people don’t use, is /srv. It’s for data that is being hosted via services like http/ftp/samba. I’ve see /var used for this a lot, which isn’t really its purpose.
Method 2
I won’t answer about what they all mean (others have), but give a little historical context.
First, remember that UNIX is getting close to 40 years old, back in the days of paper tape and 300 baud hard-coded terminals to mainframes (Windows XP system is close to 10 year old). Typing was slow and the need for efficiency in typing outweighed a lot of other considerations. That is the reason for the very short basic commands (i.e. ‘ls’, ‘cat’, ‘cc’, ‘dd’, etc.). The same was with the directory structures. The thought was that if the command is more than three or four characters then the name was too long.
The /usr directory originally contained user’s home directories since most of the commands were in /bin and all the device files were in /dev. Later it was thought to make the primary drive (the root filesystem, ‘/’) small for faster boot times. So other structures like /usr/bin, /usr/include and /usr/lib came about, where /usr was a separate “drive”. Much later, it was thought to have user’s home directories in /home, yet another drive. And much later than that, to have a /var (short for variable/changable). The /etc directory did mean ‘et cetera’ since that was the catch-all location of all the system configuration files. The /mnt was used as a temporary place to access a drive (often a backup drive). Directories like /opt, /proc and /media came much much later.
There is a lot that is left out (like /usr/local and /net), but this gives a brief description of why the names are ‘less intuitive’.
Method 3
As already mentioned here, Linux distributions mostly use the FHS, see here for a tutorial-like overview, specially good suited for someone coming from windows.
As a note, Windows directories seem intuitive, superficially. But let me ask you, where do settings for a program belong, as a *.ini file in the programs folder, in Documents and SettingsUser (Application Data or Local SettingsApplication Data), or in the infamous registry? no one knows, not even Microsoft. And so we can go on and on.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0