64 Comments
- inactive, on 10/12/2007, -4/+36does anyone else think latching onto the first comment for attention, even though your reply is totally irrelevant to it is a /major/ annoyance
- scratched, on 10/12/2007, -1/+29An easier way to find out this stuff is just by opening the terminal and typing "man hier" (without the quotes) and you'll get a great explanation of the stuff on that page without having to check a bookmark every time you forget.
Just keep "man hier" written on a post-it note near your PC :p
Like someone mentioned below, wikipedia also has a good explanation of the hierarchy.
& for i440:
The standard is fine, it's easiest the way it is. Short and simple, less typing is always a good thin when using the command line. - trogdoor, on 10/12/2007, -6/+22"Does anyone else think this standard needs a /major/ revision?"
No. - EBorg, on 10/12/2007, -0/+11This from Wikipedia seems more complete.
http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard - brundlefly76, on 10/12/2007, -6/+15Don't feel bad, nothing about the unix directory structure is intuitive, it's an ugly legacy.
Anyone who tells you otherwise is just so damn proud they know how to navigate it that they will be more then glad to tell you how simple it is.
That said, those of us who do know how to navigate it don't really have any idea how it would look otherwise. - inactive, on 10/12/2007, -0/+9This is pretty nice. especially for someone who isn't too familiar with Linux. Thanks for sharing this.
:) - noisrevd, on 10/12/2007, -4/+13Pardon my mistake: "... and which I install ..." > " ... and DATA which I install ...". I left out the word data in my description.
- kwojniak, on 10/12/2007, -2/+11I agree this is nice, but something this basic shouldn't require reading up on. I'm not trying to start an OS war here, but OS X clearly identifies in the Finder your Applications, Documents, Pictures, Movies, Music, etc, folders (and so does Windows). The least Linux could do (again, I'm not a Linux user so maybe this has already been started) is put symbolic links labeled "Applications" and "Documents", etc, so the user can easily find where to put their files.
This is definitely one area that Linux needs to improve upon if it wants the average Joe working on it. - flum, on 10/12/2007, -0/+9i440: http://www.gobolinux.org/
- mistshadow2k4, on 10/12/2007, -0/+7"so does Windows"
Not always true. You can uninstall an app and find it's not completely gone, because it partially installs to documents & settings and/or windows, not just it's own program files directory. I've seen apps that put files in all three -- and more than one that *also* put files in subdirectories of Windows. Considering that few software devs for Windows feel obligated to tell anyone where all the files an app installs go, it's really just as messy as *nix. Windows is actually more aggravating when trying to get rid of an annoying app, as there is no APT with a purge command (this applies with some *nix distros too though). - merreborn, on 10/12/2007, -1/+7Honestly, this is one of the things that I found most difficult to understand about linux. Glad to see a good article about it getting dugg up.
- prockcore, on 10/12/2007, -1/+7Except even OSX isn't always consistent. XCode, for example, does *not* install into Applications.
- kwojniak, on 10/12/2007, -0/+6@scratched
Nice, even works on Mac OS X. - Nebbie, on 10/12/2007, -0/+6@kwojniak
Not only has that stuff started, its already done. This information here is more akin to what folders are in c:windows. It's not really something you need to know or understand completely to use it.
In Linux its up to the desktop (usually Gnome or KDE) to sort the useful applications into categories such as "Internet", "Office" or "Multimedia". Linux actually does this much better then windows: when you install a program in windows you get another folder with the company name with a bunch of useless links. In Linux when you install a program you get a link to the program in the correct category in your "start menu" with no clutter.
Folders such as "Pictures", "Documents", and "Music" all belong in the /home/username folder, just the same way windows makes the "My Pictures" and "My Music" in "My Documents", the only difference (and this could be a really good or really bad thing for different people) is that these folders are not automatically created (although some distributions do create them).
Hope that helps! - trogdoor, on 10/12/2007, -0/+5If you ever need to "locate the binary, source, and manual page files for a command"
try:
whereis < command > - michuk, on 10/12/2007, -1/+6This is a nice introduction. Here is another similar resource: http://polishlinux.org/first-steps/filesystem-and-disks/ -- less information on file structure, but compared to the Windows hierarchy + some more information about coping with disks under Linux.
- noisrevd, on 10/12/2007, -1/+5Yeah, I know its frustrating learning where you are supposed to install stuff when there's so many directories like /usr/local/ , /usr/share/local , /var/lib, etc. etc. Although, many distros of linux have their own spin on what should go where. But, they are generally fairly similar
- gcauthon, on 10/12/2007, -1/+5@burke
I'm not sure why everyone is saying /sbin is for root users, but that's wrong. The /sbin directory is for static linked binaries. The reason for this, is if you lose your /usr/lib folder then you can still run everything under /sbin. Try to mount only /bin and then try to run stuff. Missing a few libraries?
I'm not saying these folders did not have their purpose at some point in time, I'm just saying they're not useful anymore and nobody knows what they're for anyway. Another point I was trying to make is that it doesn't matter if you the user knows where stuff should go. If the distro packagers don't know then everything ends up all scrambled and your system is screwed anyway.
For example, the /usr/bin used to be for OS specific programs and /usr/local/bin was for third-party programs. For example, if you had System V installed and then installed some 3rd party applications, then those would go in /usr/local. If you upgraded System V to a new release then your /usr/local would still be intact after the upgrade. The /opt directory was for installing optional software made by the OS vendor but not packaged with the OS. Stuff like IBM's MQSeries and Sun's C compiler went here.
However, this is linux and the separation makes no sense anymore. There's no distinction between the software that ships with a distro and the software you download afterwards. There is no "third-party" software in linux. So people make up their own stupid rules. - Stemp, on 10/12/2007, -0/+4Revision 0.5 9/02/2003 ?
I understand why there is no /media - burke, on 10/12/2007, -0/+3It's simple. If files in /bin go missing, you're screwed. If it's separated from the crap you mess with on a daily basis (/usr/bin, /usr/local/bin), you have a minimized chance of screwing it up.
/sbin is stuff that's only accessible to the root user and other privileged users. This way, you keep important core executables safe from users, and also only executable by admins.
/usr/bin and /usr/local/bin, IMO is not a necessary distinction, but I'm sure there's a good reason for that too. - buzzedlightyear, on 10/12/2007, -0/+3this article becomes less useful as more & more distro's and users are using package managers and less users placing files by themselves.
still good to know though. - McGrude, on 10/12/2007, -0/+3For most self installed software I install it in /space/program-name/program-name-version/
So, for example If I want to install gcc 4.0.1 I install it in /space/gcc/gcc-4.0.1/
Then in /space/gcc/ I create a symbolic link named "current_version" which points to the current version (it may not be the highest rev number in some cases).
I have a script in /space/path_setup.sh which iterates over each /space/program-name/ adding the /space/program-name/current_version/bin/ to the path if it exists, else /space/program-name/current_version/ as a fallback. Works in most cases and recent versions of 'man' find the man pages with having to manually alter the manpath.
This allows me to keep previous versions installed, thus permitting users to override the default path for each program set by the /space/path_setup.sh script. If they want gcc-3.0.0 then they just prepend that to their path in their own bash{rc,_profile} as needed. - McGrude, on 10/12/2007, -0/+3God I hate fixing a typo...
"Works in most cases and recent versions of 'man' find the man pages with having to manually alter the manpath."
should be
Works in most cases and recent versions of 'man' find the man pages withOUT having to manually alter the manpath. - nofxjunkee, on 10/12/2007, -0/+3it all makes sense though, in some way. except for /opt. I hate /opt because no data is random.
for example having /var separate is so if you really want to lock down a machine (fex. using secure levels on bsd) you can have some file systems (such as one that holds /bin, /sbin, /usr, /etc) mounted read only on a server. keeping just /var, /tmp and say /home writable gives you a much more secure server since no executables can be modified (especially if you mont /var and /home and /tmp with the noexec option).
yes it's arcane and non-intuitive, but it adds to unix's reputation for being pretty secure. - greyfade, on 10/12/2007, -0/+3the description for /opt/ sucks. on Gentoo Linux, /opt/ is used for binary packages, such as Skype, Firefox-bin, Java, etc., which all come precompiled.
@flum: i looked at it once before, but now... EW. Gobo has gone to version numbering directories? YUCK. - Crucifix, on 10/12/2007, -0/+3Also note that all binaries in /sbin should be statically linked, so that the system may still function if something happens to libc.so or other shared objects.
It would be nice if the article were more in-depth than the manpages... `man hier' tells you what you need to know just as well as the article (if not better) - but I'd really like to know why etc is called etc and why sbin is called sbin. sbin = system binaries? etc = etcetera (if so, why)? - ostracize, on 10/12/2007, -0/+2/opt is the safe fall back for any program because it's guaranteed to not screw up somebody's install convention.
If you specify an install directory as in:
./configure --prefix=/usr/local
it will install to where ever you want it.
KDE installations should have kde-config which helps determine proper installation directories (eg. kde-config --prefix). I don't know if Gnome does anything similar. - ModernTenshi, on 10/12/2007, -0/+2I agree, this is fantastic. I've only started dabbling in Linux recently, and I hated having to ask a friend, "Okay, so which directory is the best/logical place to save/install this?"
Thanks for posting this. - drag, on 10/12/2007, -0/+2The correct answer to the question 'were do I install my programs' is "WERE EVER YOU WANT".
Seriously. It's not a big deal.
I don't use /opt/
Never have. Never will.
I don't install in /usr/ or in / because I like the distribution package management mess with that. There is no point trying to do that you may run into a problem accidently overwriting the wrong files.
Personally I like to install my programs in ~/apps. Yes I install programs to my home directory.
That way, since my home directory is networked, when I install doom3 or Realplayer or whatever on my home directory then I install it on all my machines at home at the same time. Pretty simple, eh?
The reason the directory structure is like how it is in Linux is because it's designed to be flexible. If you ever seen a Unix directory structure on a large scale you'd realise that people do stuff like having /usr/local/ directories on a remote server so that they don't have to install stuff on everybody's machine. Much more efficient use of time and disk space just to have it automaticly aviable on everybody's machine instantly.
This is one of the reasons Linux environments are so much easier to manage then Windows. Windows makes all sorts of assumptions on how you have your computer setup and how things on your network are going to be arragned.
Try doing something as simple as having a diskless workstation is a HUGE headache for Windows admins, but is simple for experianced Linux guys. (oh why would want to have a _diskless_ workstation? I suppose people would say: (the correct answer is that it makes managing stuff much simplier))
Why waste time on dealing with 'roaming profiles' type stuff when you can have every application, every user home directory with all their applications and all their preferences instantly aviable on every workstation in their workgroup by simply using NFS?
Then there is even much weirder stuff you can do. Like having layered file systems or usermode file systems (like FUSE sshfs). Ever wonder how Knoppix allows you to install applications and save files even though your booted up on a cdrom? I bet most people never tried to install stuff using apt-get on Knoppix.. (it works)
This is why Microsoft had to copy the Unix directory tree structure for it's 'DFS' stuff. Having C: drives and E: shares is a throw back to DOS days and is completely obsolete and very difficult to work with. - senorBojangles, on 10/12/2007, -0/+2Props for mentioning the 'whereis' command. It's important to understand that these directories are conventions, not hard and fast rules. The conventions are usually followed, but not always, which can make it even more confusing to someone green to *nix.
Another command which (no pun intended) does the same thing is the 'which' command followed by the program name as an argument will give you the installation path. i.e:
# which adept
# /usr/bin/adept - BlackAdderIII, on 10/12/2007, -0/+2Always good to have this sort of thing explained to people, and ALWAYS good that people understand exactly where things are on their computer and what it's all about, so they enjoy using it. Dugg for that.
Familiarity is the only thing that stands in the way of a newbie "getting" it, so the more transparent it can all be, the better. - saftaplan, on 10/12/2007, -0/+2Why should the Linux file system structure be bad? Sure, it could be more descriptive, but at least it's not like in Windows: you have a folder called "Program Files" where all the 3rd party programs, but also some drivers, OS apps and logs are. Then you have the "Windows"-folder where all OS apps, but also some 3rd party programs, drivers and logs are. Then there is the "system"-folder, which is used for nothing but is still there. Then there is the "system32"-folder used for libraries, drivers, OS apps but also some logs are.
And where would you think most of the user settings go? Somewhere in the "Documents and Settings"-folder? No, they are kept in another headache called the "Register", with another crazy structure.
The only tree that's really messed up is the Windows one, but most people see it as 'user friendly' because they are used to it. You can find the Linux directory structure confusing, but at least it has one. - antdude, on 10/12/2007, -0/+2Revision 0.5 9/02/2003 Dang, that's old.
- nickiank, on 10/12/2007, -0/+2Definitely worth knowing. I just hope people just learning Linux learn about their distro's package manager (if applicable) first! I found out about all this stuff when I got started w/ Debian two years ago and spent a lot of time and effort compiling + installing apps one-at-a-time by hand and tearing my hair out over dependency issues...didn't find out what apt was all about until a month after.
Still: doesn't hurt to learn this stuff. Even if you're not putting stuff into place yourself, it's good for cutting down time in terms of figuring out where a given file probably lives. - gcauthon, on 10/12/2007, -4/+6Ok, so let me get this straight:
/bin - executable programs
/sbin - executable programs needed to boot the system
/usr/bin - applications
/usr/local/bin - applications that you install
Am I the only person left in the world that finds this incredibly retarded?
/opt - Used for storing random data that has no other logical destination
And all credibility for this article goes right out the window. But I guess it's better than the more generally accepted definition at http://www.pathname.com/fhs
/opt - add-on applications that you install
And that's apparently not enough options for some distributors. I've seen mysql packages that install under /var. I've seen a distro of apache that installed in /etc. And I've seen a distro of openldap that installed everything under /usr/shared/lib.
I've got a more accurate guide on where to find stuff under linux:
man find - inactive, on 10/12/2007, -1/+2@ Michuk
PolishLinux is a great resource, good post. - cptnapalm, on 10/12/2007, -0/+1One interesting thing about Unix filesystems is that once you get accustomed to it, finding most stuff is pretty easy. You will know where to go for system configuration, where to go for games, where to go for libraries and so on. Going back to Windows sometime there after becomes interesting. The c:windows directory structure is an absolute mess. After awhile, Program Files becomes a horrid site; why do i need to know the name of the publisher of something to find the damn program?
I have been wondering what ever happened to 3rd party stuff installing in /usr/local though. The way I always understood it was that if it comes from your distro, then it goes in / and /usr but if it is installed locally, its /usr/local. I'm much more likely to remember if I installed software by on my own than I am to remember who the hell the publisher of a game I bought a year ago was. - SniperSlap, on 10/12/2007, -0/+1FHS. Everyone has said it.
It's just a standard location for your executable binaries, libraries, configuration files and shared resources. Bla bla bla.
BUT, it is important. FHS is probably the first thing anyone should be told about before getting into Linux. It saves a lot of problems later on. - kwojniak, on 10/12/2007, -1/+2@prockcore - true, but at least it's "Developer", with subfolders that don't require guessing.
- noisrevd, on 10/12/2007, -1/+2Thanks! I'm putting together an information center for some of the linux neophytes at work, that will be a nice addition!
- inactive, on 10/12/2007, -1/+2i think this is great, it was the first major hurtle in learning linux for me, moving from C: and C: Program Files, to the /var /usr /bin etc , not really understanding what goes where, and where the actual files are located for the programs i have installed
- 256byteram, on 10/12/2007, -0/+1/opt
Used for storing random data that has no other logical destination.
I've found a lot of proprietary applications (such as printer drivers) and other binaries install here. - thepxc, on 10/12/2007, -0/+1When I install things in Gentoo, I just use emerge and let it take care of the rest. But for programs that aren't in in the repositories yet (or at all), I have a partition I mount in / as "/lin-shared," which is a partition I share (duh) between whatever distributions I have installed. I put a directory with the name of the program in there, and then untar the source tarballs, which usually includes a version string. Then I just re-compile for whichever distro and use the /usr/local prefix.
- jiminoc, on 10/12/2007, -1/+2I know it's not common place but I like to put ***** in different places, like having all my php, apache, mysql stuff in /web and all my apps in my home/apps directory. That's what makes linux great though, I can do whatever the F I want :) But it's nice to know where things should go.
- ostracize, on 10/12/2007, -0/+1the locate command can help here.
If you were desperate, I guess you could do two file listings on the whole system and do a diff on them. - BlackAdderIII, on 10/12/2007, -0/+1"One interesting thing about Unix filesystems is that once you get accustomed to it, finding most stuff is pretty easy. You will know where to go for system configuration, where to go for games, where to go for libraries and so on."
Couldn't agree more. This is largely an issue of getting used to something different for a lot of people - having a clearly organised hierarchy becomes a boon once you're used to it, because you've got an idea of where something is happening even if you've never seen the piece of software in your life before - and being able to add/delete/move branches of the "tree" to/from different devices etc. without any problems is just a win for anyone who's ever used a non-unix system.
"Going back to Windows sometime there after becomes interesting. The c:windows directory structure is an absolute mess. After awhile, Program Files becomes a horrid site; why do i need to know the name of the publisher of something to find the damn program?""
Uhuh, shared apps that keep 1(one) user's app data in the global install directory on a supposed multi-user OS, programs installed under random publishers' names with stuff placed at random in "Common Files" or in the root directory or in some other random place, settings placed in the "Registry" and not cleaned up - it's a lot easier to find and rid yourself of cruft in a system with a clear focus on things being in their right place.
Of course, there are some nixen that ain't got that focus at *all* nowadays, haha.
"I have been wondering what ever happened to 3rd party stuff installing in /usr/local though."
Ah, plenty of developers are still plenty good like that. - BartSwordfish, on 10/12/2007, -0/+1Great quick run down on what's what in the various directories. I don't do enough on a regular basis with Linux to have committed the directory structure to memory so it's great to see something like this article. I'll probably print it out and keep it around as a good cheat sheet for when I'm working on a Linux system. Thanks
- chaos386, on 10/12/2007, -0/+1Or you could just use checkinstall and have your package manager handle it.
- Jugalator, on 10/12/2007, -0/+1http://photos1.blogger.com/blogger/220/1983/1600/linux_file_structure.jpg
-
Show 51 - 65 of 65 discussions



What is Digg?