Previous Page
Next Page

The Root (/) File System


Describe the purpose, features, and functions of root subdirectories, file components, file types, and hard links in the Solaris directory hierarchy.

Solaris comes with many file systems already created. These file systems were described earlier in this chapter. One of the most important file systems is the root file system. This file system is important because it is the first file system that is mounted when the system begins to boot. It is the file system that contains the kernel and all of the bootup scripts and programs. Without this file system, the system will not boot.

Furthermore, the root file system is at the top of the hierarchy of all file systems and contains all of the directory mount points for the other file systems. Taking a closer look at the contents of the root file system, we see that it contains many important directories, which are described in Table 1.7.

Table 1.7. Root Directories


Description of Contents


Root of the overall file system name space.


This is a symbolic link to the /usr/bin directory. See the section later in this chapter titled "Soft (Symbolic) Links."


Primary location for logical device names. Logical device names are described earlier in this chapter. Subdirectories within this directory are

/dev/cfgSymbolic links to physical ap_ids

/dev/cuaDial out devices for UUCP

/dev/dskBlock (buffered) disk devices

/dev/fbsFrame buffer device files

/dev/fdFile descriptors

/dev/mdSolaris Volume Manager metadisk devices

/dev/ptsPseudo terminal devices

/dev/rdskRaw (character) disk devices

/dev/rmtRaw magnetic tape devices

/dev/sadEntry points for the STREAMS Administrative driver

/dev/soundAudio device and audio device control files

/dev/swapDefault swap device

/dev/termSerial devices


This file system contains physical device names, which were described earlier in this chapter.


Platform-dependent administrative and configuration files and databases that are not shared among systems. Most configuration files in this directory define the machine's identity. A few subdirectories within the /etc directory that you need to be aware of are

/etc/acctAccounting system configuration information.

/etc/cron.dConfiguration information for cron(1M).

/etc/defaultDefault information for various programs.

/etc/dfsConfiguration information for shared file systems.

/etc/dhcpDynamic Host Configuration Protocol (DHCP) configuration files.

/etc/inetConfiguration files for Internet services.

/etc/init.dContains legacy RC scripts for transitioning between run levels. This directory has been significantly reduced from previous versions of Solaris with the introduction of SMF, which is described in Chapter 3, "Perform System Boot and Shutdown Procedures."

/etc/libShared libraries needed during booting.

/etc/lpConfiguration information for the printer subsystem.

/etc/mailMail subsystem configuration.

/etc/nfsNFS server logging configuration file.

/etc/optConfiguration information for optional packages.

/etc/openwinOpenWindows configuration files.

/etc/rc<#>.dContains legacy RC scripts for transitioning between run levels. These are mainly hard links to the /etc/init.d directory and are described in Chapter 3.

/etc/safService Access Facility files.

/etc/securityBasic Security Module (BSM) configuration files.

/etc/skelDefault profile scripts for new user accounts. This directory is discussed in Chapter 4, "User and Security Administration."

/etc/uucpUUCP configuration information.


This directory contains commonly shared file systems such as user home directories.


This is the system default directory (mount point) for user home directories. When you are running AutoFS (see Chapter 9, "Virtual File Systems, Swap Space, and Core Dumps"), you cannot create new entries in this directory.


This directory contains platform-independent loadable kernel modules required as part of the boot process. /kernel includes the generic part of the core kernel that is platform independent, named /kernel/genunix.


Shared executable files and Service Management Facility (SMF) executables.


Default temporary mount point for file systems. Use this empty directory to temporarily mount any file system.


This is a default directory for add-on and third party application packages.


This directory contains platform-specific objects that need to reside on the root file system. It contains a series of directories, one per supported platform.


The single-user bin directory contains essential commands used in the booting process. These commands are available when /usr/bin is not mounted. It contains many system administration commands and utilities.


The mount point for the /usr file system. The name "usr" is an acronym for Unix System Resources. Important subdirectories in /usr are

/usr/binMost standard system commands are located here.

/usr/ccsC-compilation programs and libraries.

/usr/demoDemonstration programs.

/usr/dtCDE programs and files.

/usr/includeHeader files for C programs and other executables.

/usr/javaJava programs and libraries.

/usr/libProgram libraries and databases.

/usr/openwinOpenWindows programs and files.

/usr/optConfiguration information for optional packages.

/usr/pubFiles for online manual pages and character processing.

/usr/sadmSystem administration files and directories.

/usr/spoolA symbolic link to /var/spool.

/usr/shareA location for sharable files. Bundled Solaris software gets loaded here.

/usr/snadmFiles related to system and network administration.

/usr/tmpSymbolic link to /var/tmp.

/usr/ucbBerkeley compatibility package binaries.


Directory for varying files such as logs, status files, mail, print files, and so on.

In addition, Solaris 10 introduces additional in-memory system directories and subdirectories that are described in Table 1.8. These in-memory directories are maintained by the kernel and system services. With the exception of /tmp, do not attempt to manually create, alter, or remove files from these directories.

Table 1.8. In-Memory System Directories




A directory containing special files relating to current file descriptors in use by the system.


The primary directory for physical device names.


A memory-based file, in its own file system, which contains details of currently mounted file systems.


A directory that contains log files and reference files relating to the current state of system services.


This directory stores current process-related information. Every process has its own subdirectory in /proc.


A file system used for creating, controlling, and observing contracts, which are relationships between processes and system resources. These process contracts are used by the Service Management Facility (SMF) to track the processes that compose a service. See Chapter 3 for a description of the SMF.


This directory, used primarily for DTrace activity, describes the state of all modules currently loaded by the kernel.


A memory-resident directory for temporary files. Be careful storing files in /tmp; this directory is cleared during the boot sequence.


This directory contains lock files, special files, and reference files for a variety of system processes and services.

As you browse the directories in the root file system, you'll notice many file types. The file type can usually be identified by looking at the first character of the first column of information displayed when issuing the ls -l command.

A typical listing may look like this when listing the contents of the /etc directory:

ls -l /etc
total 583
lrwxrwxrwx   1 root     root          14 Aug  9 19:18 TIMEZONE -> ./default/init
drwxr-xr-x   6 root     other        512 Aug  9 20:51 X11
drwxr-xr-x   2 adm      adm          512 Aug 10 09:24 acct
lrwxrwxrwx   1 root     root          14 Aug  9 19:31 aliases -> ./mail/aliases
drwxr-xr-x   7 root     bin          512 Aug 10 09:34 apache
drwxr-xr-x   2 root     bin          512 Aug 10 09:26 apache2
drwxr-xr-x   2 root     other        512 Aug  9 20:29 apoc
-rw-r--r--   1 root     bin          226 Sep 13 14:17 auto_home
-rw-r--r--   1 root     bin          248 Aug  9 19:29 auto_master
lrwxrwxrwx   1 root     root          16 Aug  9 19:18 autopush -> ../sbin/autopush
drwxr-xr-x   2 root     other        512 Aug  9 20:19 bonobo-activation
drwxr-xr-x   2 root     sys          512 Aug  9 19:18 certs
lrwxrwxrwx   1 root     root          18 Aug  9 19:18 cfgadm -> ../usr/sbin/cfgadm
lrwxrwxrwx   1 root     root          18 Aug  9 20:18 chroot -> ../usr/sbin/chroot
    <output has been truncated>

The information displayed in the long listing is in the form of columns and is as follows (reading from left to right):

  • Column 1 Ten characters that describe the mode of the file. The first character displays the file type where


    The entry is a directory.


    The entry is a door.


    The entry is a symbolic link.


    The entry is a block special file.


    The entry is a character special file.


    The entry is a FIFO (or "named pipe") special file.


    The entry is an AF_UNIX address family socket.


    The entry is an ordinary file.

    The next nine characters in column one describe the file's permission mode, which is described in detail in Chapter 4.

  • Column 2 Displays the number of links to the file

  • Column 3 Displays the file's owner

  • Column 4 Displays the file's group

  • Column 5 Displays the file size in bytes

  • Column 6 Date/Time of the file's last modification

  • Column 7 File name

    The -> after a file name denotes a symbolic link, as follows:

    lrwxrwxrwx   1 root   root   14 Feb 26  2005 TIMEZONE -> ./default/init
    drwxr-xr-x   2 adm    adm   512 Feb 27  2005 acct
    lrwxrwxrwx   1 root   root   14 Feb 26  2005 aliases -> ./mail/aliases
    lrwxrwxrwx   1 root   root   16 Feb 26  2005 autopush -> ../sbin/autopush
    lrwxrwxrwx   1 root   root   18 Feb 26  2005 cfgadm -> ../usr/sbin/cfgadm
    lrwxrwxrwx   1 root   root   18 Feb 26  2005 chroot -> ../usr/sbin/chroot
    lrwxrwxrwx   1 root   root   16 Feb 26  2005 clri -> ../usr/sbin/clri

    A link is a pointer to another file or directory. Links provide a mechanism for multiple file names to reference the same data on disk. In Solaris, there are two types of links:

    Both of these are discussed in the following sections.

Soft (Symbolic) Links

Sometimes symbolic links are used for shortcuts; other times we use them to link to a filename from each user's home directory to a centralized location or file. For example, perhaps we want to have a common directory named documents where every user stores their documents. This directory exists as /export/data/documents. In each user's directory, we create a link named documents that points to /export/data/documents. As a user, whenever I store something in the directory named $HOME/documents, the file actually gets directed to /export/data/documents. We can identify links when we perform a long listing on a directory as follows:


Notice the use of the -i option used with the ls command and the results displayed. This option is used to display the inode number (in the left column of the output) that has been assigned to each file and directory. I'll describe why this inode number is relevant to links later in this section when I describe hard links.

ls -li $HOME

The system displays the following:

75264 drwxr--r--   2 bcalkins staff  512 Jun  6 20:36 dir1
78848 drwxrwxr-x   2 bcalkins staff  512 Jun  6 20:38 dir2
82432 drw-r--r--   2 bcalkins staff  512 Jun  6 20:39 dir3
3593 lrwxrwxrwx    1 bcalkins staff  22 Jun 17 17:09 documents\
 -> /export/data/documents

Output has been truncated.

Notice the file that has an l as the first character of column 2. This is a soft or symbolic link. The sixth field shows a file size of 22 bytes and the last field shows which file or directory this link is pointing to. Each file has a unique inode number identified in column 1; the importance of this column is discussed later in this chapter.

When storing a file in $HOME/documents, the system is redirecting it to be stored in /export/data/documents. Now when changing to the /export/data/documents directory and issuing the ls -li command:

cd /export/data/documents
ls -li

The system displays the following:

125461   drwxr-xr-x   2 root     other    512 Jun 17 17:09 documents

Notice that the file that has a d as the first character of column 2. This is the directory that the $HOME/documents link points to. The first column shows the inode number, and the sixth column shows the file size as 512 bytes.

Symbolic links can point to files anywhere on the network. The file or directory could exist in another file system, on another disk, or on another system on the network.

The syntax for creating a symbolic link is as follows:

ln -s source-file link-name

For example, you might have a file named file1 that has the following contents:

This is the contents of file1

To create a symbolic link named link1, which will be linked to the existing file named file1, you issue the following command:

ln -s file1 link1

Now when you list the contents of the directory you see two files:

3588 -rw-r--r--   1 bcalkins staff         30 Jun 17 17:51 file1
3594 lrwxrwxrwx   1 bcalkins staff          5 Jun 17 18:09 link1 -> file1

See the link named link1 pointing to file1? If you display the contents of link1, it shows the following:

This is the contents of file1

If you remove file1, the source file, link1 will still exist, but it points to a file that does not exist. Type the following:

cat link1

The cat command can't print out the contents of the file, so you get this message:

cat: Cannot open link1

When you re-create file1, link1 will contain data again.

Hard Links


Explain how to create and remove hard links in a Solaris directory.

A hard link is more difficult to determine, because they are not so obvious when viewed with the ls -li command. For example, when you go to the /etc/rc2.d directory and type

ls -li

the system displays the following:

total 102
<output has been truncated>
      2123 -rwxr--r--   5 root     sys         1718 Jan 21  2005 S47pppd
      2102 -rwxr--r--   2 root     sys          327 Jan 21  2005 S70uucp
      1368 -rwxr-xr-x   2 root     other       1558 Jan  9  2005 S72autoinstall
       241 -rwxr--r--   2 root     sys         1262 Jan 21  2005 S73cachefs.daemon
      1315 -rwxr--r--   2 root     sys         1028 Jan 21  2005 S81dodatadm.udaplt
       237 -rwxr--r--   2 root     sys          256 Jan 21  2005 S89PRESERVE
      2103 lrwxrwxrwx   1 root     root          31 Aug 10 09:49 S89bdconfig ->\
      1898 -rwxr--r--   5 root     sys         3506 Jan 10  2005 S90wbem
      2100 -rwxr--r--   5 root     sys         1250 Jan 10  2005 S90webconsole
<output has been truncated>

The first character in the second column of information displays the file type as a regular file (-). The third column, link count, shows a number greater than 1. It displays the number of links used by this inode number. These are hard links, but they are not identified as links and the display does not show which file they are linked to.

Think of a hard link as a file that has many names. In other words, they all share the same inode number. As described in the section titled "The inode" later in this chapter, a file system identifies a file not by its name, but by its inode number. Looking at the file named S90wbem in the previous listing, we see an inode number of 1898. List all file names in this file system that share this inode number as follows:

find / -mount -inum 1898 -ls

The system displays the following list of files:

1898  4 -rwxr--r--   5 root   sys    3506 Jan 10  2005 /etc/init.d/init.wbem
1898  4 -rwxr--r--   5 root   sys    3506 Jan 10  2005 /etc/rc0.d/K36wbem
1898  4 -rwxr--r--   5 root   sys    3506 Jan 10  2005 /etc/rc1.d/K36wbem
1898  4 -rwxr--r--   5 root   sys    3506 Jan 10  2005 /etc/rc2.d/S90wbem
1898  4 -rwxr--r--   5 root   sys    3506 Jan 10  2005 /etc/rcS.d/K36wbem

All six of these files have the same inode number; therefore, they are the same file. You can delete any one of the filenames, and the data will still exist.

In this example, the file is named file1 in $HOME:

3588 -rw-r--r--   3 bcalkins staff         30 Jun 17 17:51 file1

The contents of this file are displayed with the cat command:

This is the contents of file1

The syntax for creating a hard link is as follows:

ln source-file link-name

To create a hard link named link1, which will be linked to the existing file named file1, issue the following command:

ln file1 link1

Now when I list the contents of the directory, I see two files:

3588 -rw-r--r--   2 bcalkins staff         30 Jun 17 17:51 file1
3588 -rw-r--r--   2 bcalkins staff         30 Jun 17 17:51 link1

Both files share the same inode number, the number of links is two, and the file size is 30 bytes. If I display the contents of link1, it shows the following:

This is the content of file1

If I remove file1, the source file, link1 still exists and still contains the data. The data will not be deleted until I destroy the last file that shares this inode number.

A hard link cannot span file systems; it can only point to another file located within its file system. The reason is that hard links all share an inode number. Each file system has its own set of inode numbers; therefore, a file with inode number 3588 in the /export/home file system may not even exist in the /var file system.

An advantage of a symbolic link over a hard link is that you can create a symbolic link to a file that does not yet exist. You cannot create a hard link unless the source file already exists. Here's what happens when you create a symbolic link to a file that does not exist:

ln -s  nonexistentfile link5

When you list the file:

ls -l link5

The system responds with

lrwxrwxrwx  1 bcalkins staff  14 Jun 17 18:24 link5 -> nonexistentfile

Now, here's what happens when you create a hard link to a file that does not exist:

ln noexistentfile link6

The system responds with

ln: cannot access noexistentfile

Removing a Link

Remove a link using the rm command as follows:

rm <linkname>

For example, to remove the link named link1, type

rm link1


Removing Files and Links When you remove a file, it's always a good idea to remove the symbolic links that pointed to that file, unless you plan to use them again if the file gets re-created.

Another advantage of symbolic links over hard links is that a symbolic link can link directories or files, whereas a hard link can link only files.

Previous Page
Next Page