Home > Articles

This chapter is from the book

What a Hierarchical File System Is All About

In a nutshell, a hierarchy is a system organized by graded categorization. A familiar example is the organizational structure of a company, where workers report to supervisors and supervisors report to middle managers. Middle managers, in turn, report to senior managers, and senior managers report to vice-presidents, who report to the president of the company. Graphically, this hierarchy looks as shown in Figure 3.1.

Figure 3.1

Figure 3.1 A typical organizational hierarchy.

You’ve doubtless seen this type of illustration before, and you know that a higher position indicates more control. Each position is controlled by the next highest position or row. The president is top dog of the organization, but each subsequent manager is also in control of his or her own small fiefdom.

To understand how a file system has a similar organization, imagine each of the managers in the illustration as a file folder and each of the employees as a piece of paper, filed in a particular folder. Open any file cabinet, and you probably see things organized this way: Filed papers are placed in labeled folders, and often these folders are filed in groups under specific topics. The drawer might then have a specific label to distinguish it from other drawers in the cabinet, and so on.

That’s exactly what a hierarchical file system is all about. You want to have your files located in the most appropriate place in the file system, whether at the very top, in a folder, or in a nested series of folders. With careful usage, a hierarchical file system can contain thousands of files and still allow users to find any individual file quickly.

On my computer, the chapters of this book are organized in a hierarchical fashion, as shown in Figure 3.2.

Figure 3.2

Figure 3.2 File organization for the chapters of Sams Teach Yourself Unix in 24 Hours, Fourth Edition.

Task 3.1: The Unix File System Organization

A key concept enabling the Unix hierarchical file system to be so effective is that anything that is not a folder is a file. Programs are files in Unix, device drivers are files, documents and spreadsheets are files, your keyboard is represented as a file, your display is a file, and even your tty line and mouse are files.

What this means is that as Unix has developed, it has avoided becoming an ungainly mess. Unix does not have hundreds of cryptic files stuck at the top (this is still a problem in DOS) or tucked away in confusing folders within the System Folder (as with the Macintosh).

The top level of the Unix file structure (/) is known as the root directory or slash directory, and it always has a certain set of subdirectories, including bin, dev, etc, lib, mnt, tmp, and usr. There can be a lot more, however.

You can obtain a listing of the files and directories in your own top-level directory by using the ls -F / command. (You’ll learn all about the ls command in the next hour. For now, just be sure that you enter exactly what’s shown in the example.)

On a different computer system, here’s what I see when I enter that command:

% ls -F /
Mail/        export/        public/
News/        home/          reviews/
add_swap/    kadb*          sbin/
apps/        layout         sys@
archives/    lib@           tftpboot/
bin@         lost+found/    tmp/
boot         mnt/           usr/
cdrom/       net/           utilities/
chess/       news/          var/
dev/         nntpserver     vmunix*
etc/         pcfs/

In this example, any filename that ends with a slash (/) is a folder (Unix calls these directories). Any filename that ends with an asterisk (*) is a program. Anything ending with the at sign (@) is a symbolic link (a pointer to another file or directory elsewhere in the file system), and everything else is a normal, plain file.

As you can see from this example, and as you’ll immediately find when you try the command yourself, there is much variation in how different Unix systems organize the top-level directory. There are some directories and files in common, and once you start examining the contents of specific directories, you’ll find that hundreds of programs and files always show up in the same place from Unix to Unix.

It’s as if you were working as a file clerk at a new law firm. Although this firm might have a specific approach to filing information, the approach can be similar to the filing system of other firms where you have worked in the past. If you know the underlying organization, you can quickly pick up the specifics of a particular organization.

  1. Try the command ls -F / on your computer system, and identify, as previously explained, each of the directories in your resultant listing.

The output of the previous ls command shows the files and directories in the top level of your system. Next, you learn what the commonly found directories are.

The bin Directory

In Unix parlance, programs are considered executables because users can execute them. (In this case, execute is a synonym for run, not an indication that you get to wander about murdering innocent applications!) When the program has been compiled, it is translated from source code into what’s called a binary format. Add the two together, and you have a common Unix description for an application—an executable binary.

It’s no surprise that the original Unix developers decided to have a directory labeled binaries to store all the executable programs on the system. Remember the primitive teletypewriter discussed earlier? Having a slow system to talk with the computer had many ramifications you might not expect. The single most obvious one was that everything became quite concise. There were no lengthy words like binaries or listfiles, but rather succinct abbreviations: bin and ls are, respectively, the Unix equivalents.

The bin directory (pronounce it to rhyme with "tin") is where all the executable binaries were kept in early Unix. Over time, as more and more executables were added to Unix, having all the executables in one place proved unmanageable, and the bin directory split into multiple parts (/bin, /sbin, /usr/bin).

The dev Directory

Among the most important portions of any computer are its device drivers. Without them, you wouldn’t have any information on your screen (the information arrives courtesy of the display device driver). You wouldn’t be able to enter information (the information is read and given to the system by the keyboard device driver), and you wouldn’t be able to use your floppy disk drive (managed by the floppy device driver).

Remember, everything in Unix is a file. Every component of the system, from the keyboard driver to the hard disk, is a file.

Earlier, you learned how almost anything in Unix is considered a file in the file system, and the dev directory is an example. All device drivers—often numbering into the hundreds—are stored as separate files in the standard Unix dev (devices) directory. Pronounce this directory name "dev," not "dee-ee-vee."

The etc Directory

Unix administration can be quite complex, involving management of user accounts, the file system, security, device drivers, hardware configurations, and more. To help, Unix designates the etc directory as the storage place for all administrative files and information.

Pronounce the directory name "ee-tea-sea," "et-sea," or "etcetera." All three pronunciations are common.

The lib Directory

Like your own community, Unix has a central storage place for function and procedural libraries. These specific executables are included with specific programs, allowing programs to offer features and capabilities otherwise unavailable. The idea is that if programs want to include certain features, they can reference only the shared copy in the Unix library rather than having a new, unique copy.

Pronounce the directory name "libe" or "lib" (to rhyme with the word bib).

The lost+found Directory

With multiple users running many different programs simultaneously, it’s been a challenge over the years to develop a file system that can remain synchronized with the activity of the computer. Various parts of the Unix kernel—the brains of the system—help with this problem. When files are recovered after any sort of problem or failure, they are placed here, in the lost+found directory, if the kernel cannot ascertain the proper location in the file system. This directory should be empty almost all the time.

This directory is commonly pronounced "lost and found" rather than "lost plus found."

The mnt and sys Directories

The mnt (pronounced "em-en-tea") and sys (pronounced "sis") directories are safely ignored by Unix users. The mnt directory is intended to be a common place to mount external media—hard disks, removable cartridge drives, and so on—in Unix. On many systems, though not all, sys contains files indicating the system configuration.

The tmp Directory

A directory that you can’t ignore, the tmp directory—say "temp"—is used by many of the programs in Unix as a temporary file-storage space. If you’re editing a file, for example, the editor makes a copy of the file, saves it in tmp, and you work directly with that, saving the new file back to your original only when you’ve completed your work.

On most systems, tmp ends up littered with various files and executables left by programs that don’t remove their own temporary files. On one system I use, it’s not uncommon to find 10–30 megabytes of files wasting space.

Even so, if you’re manipulating files or working with copies of files, tmp is the best place to keep the temporary copies. Indeed, on some Unix workstations, tmp actually can be the fastest device on the computer, allowing for dramatic performance improvements over working with files directly in your home directory.

The usr Directory

The last of the standard directories at the top level of the Unix file system hierarchy is the usr—pronounced "user"—directory. Originally, this directory was intended to be the central storage place for all user-related commands. Today, however, many companies have their own interpretation, and there’s no telling what you’ll find in this directory.

Other Miscellaneous Stuff at the Top Level

In addition to all the directories previously listed, various other directories and files commonly occur in Unix systems. Some files might have slight variations in name on your computer, so when you compare your listing to the following files and directories, be alert for possible alternative spellings.

A file you must have in order to bring up Unix at all is one usually called unix or vmunix, or named after the specific version of Unix on the computer. The file contains the actual Unix operating system. The file must have a specific name and must be found at the top level of the file system. Hand-in-hand with the operating system is another file called boot, which helps during initial startup of the hardware.

Notice on one of the previous listings that the files boot and dynix appear. (DYNIX is the name of the particular variant of Unix used on Sequent computers.) By comparison, the listing from the Sun Microsystems workstation shows boot and vmunix as the two files.

Another directory you might find in your own top-level listing is diag—pronounced "dye-ag"—which acts as a storehouse for diagnostic and maintenance programs. If you have any programs within this directory, it’s best not to try them out without proper training!

The home directory, /home, also sometimes called users, is a central place for organizing all files owned by specific users. Listing this directory is usually an easy way to find out what accounts are on the system, too, because by convention each individual account directory is named after the user’s account name. On one system I use, my account is taylor, and my individual account directory is also called taylor. Home directories are always created by the system administrator.

The net directory, if set up correctly, is a handy shortcut for accessing other computers on your network.

The tftpboot directory is a relatively new feature of Unix. The letters stand for "trivial file transfer protocol boot." Don’t let the name confuse you, though; this directory contains versions of the kernel suitable for X Window System–based terminals and diskless workstations to run Unix.

Some Unix systems have directories named for specific types of peripherals that can be attached. On the Sun workstation, you can see examples with the directories cdrom and pcfs. The former is for a CD-ROM drive and the latter for DOS-format floppy disks.

Many more directories are in Unix, but this will give you an idea of how things are organized.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020