File System
File System
Introduction
Using the terminal you should now be able to wander around your hard drive with relative ease. However, you might have began to notice that the world is a much more complex place than Finder previously let you think it was. There are hidden files, there are long file names, there are aliases and shortcuts. Lets try and make some sense of where things are.
First off, in Mac OS X your hard drive is structured like a big tree. There is a single root and from that all other things sprout. In our case, the root is symbolized by the forward slash, /.
If you typed cd / you would now be in the same place as if you opened up Macintosh HD on your desktop. We’ll use this as the starting point for our description of the filesystem.

Here is a run down of some of the important directories listed above, and what they store.


•Network - This directory is primarily used when your computer is part of a computer network such as a corporate network or school network. Nothing in here usually.


•Volumes - This is a special directory, which you could probably tell by being highlighted in green. This directory is where all of the drives plugged into the system get mounted. We’ll talk more about this directory later.
All of the above directories will show up in Finder when you point it towards your hard drive. The following will not show up by default. These directories hold the files that form the basis for the core of Mac OS X. These files will include your primary tools when working with the terminal. This is where you really start to get to see the Unix portion of Mac OS X.

•sbin - Where bin contains programs that you might run normally, sbin contains applications that are geared more towards fixing and maintaining the system. It also includes programs that would require administrative access to run such as configuring network settings, modifying filesystem settings, and restarting the computer. (Yes, from a system perspective restarting a computer requires administrative privileges)
•etc - This is the Unix equivalent to the Library and System directories. Messing around in here will likely result in broken services and a non-booting system. A lot of the settings traditionally stored here on other Unix-based systems has been moved into the System directory to better fit into the way Apple likes to do things.
•home - For some reason this directory appeared in 10.5. It isn’t used by default, and is likely related to the Network directory for backward compatibility. On other Unix systems it would provide the functionality of the Users directory.
•usr - Do not confuse this with Users. The usr directory contains files that would be run or needed by a user on a daily basis if we only used the terminal. In someways it is much like the Applications directory, but it also combines some of the functionality of the Library directory as well. In here you will also find a bin and sbin directory. The programs stored there are geared more toward higher level functionality: editing files, compressing, reading mail, accessing the web. Some really fun stuff exists in here, and it would be to your benefit to play with them. On my system alone there are 904 programs sitting in /usr/bin. Hows that for a weekend of fun?
The Volumes Directory
So above I described your hard drive as a tree, all starting from a single root. Allow me to extend (and strain) this metaphor a bit. When you connect another hard drive to your computer there are not two roots. When you type cd / you still only go to the root directory of your system’s primary hard drive. So what happens?
The additional hard drives appear in the /Volumes directory. They show up as directories with the name of the hard drive you plugged in. So in this way your computer is not like a single tree, but rather a forest of trees connected together like a canopy in a rain forest (see, strained metaphor). The Volumes directory is your merging point for all of the different media connected to your computer.

As you can see I have Macintosh HD, WINDOWS HD, and mattandersen all connected to my computer right now. Here is the key to one of the subtle beauties of the Unix filesystem and why Apple chose it. There is no distinction between those three drives. They could be almost anything. In fact, mattandersen is not a hard drive or flash drive at all. It is my iDisk. And yet I don’t have to do anything special to access it from the terminal. It appears as just another directory.
I can navigate mattandersen in the same way we described before. And almost every single tool you’ll learn in terminal can be run on any file in that directory in the same way. Except that the changes are occurring live, over the internet and available on every single computer with my MobileMe account. Just like in Finder.
So if you need to access an external drive from terminal, cd /Volumes and go from there.