Important Standard Directories and Files


Files on a Mac OS X system are kept in standard locations in the filesystem hierarchy. These locations reflect a combination of POSIX standards, BSD traditions, and Apple's additions. For example, the /Applications directory is an Apple addition. Some directories are documented in the man page for hier, which describes part of the Mac OS X filesystem hierarchy.

~/.bash_profile

Startup file Holds a user's login shell initialization script. The Bourne Again Shell executes the commands in this file in the same environment as the shell each time a user logs in. The file must be located in a user's home directory.

You can use .bash_profile to specify a terminal type (for vim, terminal emulators, and other programs), run stty to establish the terminal characteristics that a user desires, and perform other housekeeping functions when a user logs in. For more information refer to "Startup Files" on page 259.

~/.bashrc

Startup file Holds a user's interactive, nonlogin shell initialization script. The Bourne Again Shell executes the commands in this file in the same environment as the (new) shell each time a user creates a new interactive shell. The .bashrc script differs from .bash_profile in that it is executed each time a new shell is spawned, not just when a user logs in. For more information refer to "Startup Files" on page 259.

~/Desktop

Personal Desktop The subdirectories in this directory hold files that appear on a user's Desktop in the Finder.

~/Library

Personal libraries and support Holds application support files for a user, similar to those stored in /Library and /System/Library. It also holds some of a user's startup (preference) files.

/

Root The ancestor of all files in the OS X filesystem. The startup disk (page 87) is mounted as the root directory.

/Applications

Application software Holds graphical application programs, including both standard system applications and applications that you install. The /Applications directory contains subdirectories that hold groups of related applications, such as the system tools in the Utilities subdirectory and the server maintenance tools in the Server subdirectory on Mac OS X Server.

/bin

Essential command binaries Holds the files needed to boot the system and run it when it first comes up in single-user mode (page 437).

/dev

Device files Holds the files that represent peripheral devices, such as disk drives, terminals, and printers (page 100). Some peripheral devices, such as mice and USB printers, are not represented by files.

/dev/null

Null file Output sent to this file disappears; also called a bit bucket. The /dev/null file is a device file that must be created with mknod. Input that you redirect to come from this file appears as nulls, creating an empty file. You can create an empty file named nothing by giving the command

$ cat /dev/null > nothing 


or

$ cp /dev/null nothing 


or without explicitly using /dev/null

$ > nothing 


The last command redirects the output of a null command to the file with the same result as the previous commands. You can use this technique to truncate an existing file to zero length without changing its permissions. You can also use /dev/null to get rid of output that you do not want:

$ grep portable * 2> /dev/null 


The preceding command looks for the word portable in all files in the working directory. Any output to standard error (page 262), such as permission or directory errors, is discarded; output to standard output appears on the screen.

Optional

/dev/zero

Zero file Input you take from this file contains an infinite string of zeros (numerical zeros, not ASCII zeros). The dd (page 703) utility converts and copies a file; you can fill a file or overwrite a file with zeros with a command such as the following. The od utility (page 799) displays the contents of the new file:

$ dd if=/dev/zero of=zeros bs=1024 count=10 10+0 records in 10+0 records out 10240 bytes transferred in 0.000301 secs (34006075 bytes/sec) $ ls -l zeros -rw-rw-r--  1 sam  sam  10240 Dec  3 20:26 zeros $ od -c zeros 0000000 \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0 \0 * 0024000 


When you try to do with /dev/zero what you can do with /dev/null, you quickly fill the partition you are working in:

$ cp /dev/zero bigzero cp: bigzero: No space left on device $ rm bigzero 



/etc

Machine-local system configuration Holds administrative, configuration, and other system files. This file is a symbolic link to /private/etc.

Caution: Files in /etc are not always used

On traditional UNIX systems, the user account database and other similar databases are stored in files in /etc. Under Mac OS X, these databases are stored in NetInfo (page 441) and access to them is handled through the lookupd daemon (page 455). See Table VI-18 on page 796 for a list of NetInfo databases. The files holding the traditional UNIX databases may exist and contain some valid information under OS X. However, making modifications to these files has no effect. For example, user accounts are not listed in /etc/passwd, even though it contains a list of system accounts such as root. To list user accounts give the command nidump passwd /. Refer to page 796 for more information on nidump.


/etc/motd

Message of the day Displayed each time someone performs a textual login. This file typically contains site policy and legal information. Keep this file short because users tend to see the message many times.

/etc/pam.d

PAM files Holds files that specify authentication methods used by programs that use PAM (page 466).

Caution: Be cautious when changing PAM files

Unless you understand how to configure PAM, avoid changing the files in /etc/pam.d. Mistakes in the configuration of PAM can make the system unusable. For more information refer to "PAM" on page 466.


/etc/printcap

Printer capability database Derived from 4.3BSD UNIX, describes system printers and gives utilities such as lpr access to the Mac OS X printing environment. The system's printer configuration application automatically maintains this file.

/etc/profile

Startup file Contains a systemwide interactive shell initialization script. When you log in using bash, the shell does immediately execute the commands in this file in the same environment as the shell. (For more information on executing a shell script in this manner, refer to the discussion of the . [dot] command on page 261.) This file allows the system administrator to establish systemwide environment parameters that individual users can override. Using this file, the system administrator can set shell variables, execute utilities, and take care of other housekeeping tasks. See also ~/.bash_profile on page 444.

See the /etc/profile file on the local system for a more complex example.

/etc/protocols

Protocols Provides protocol numbers, aliases, and brief definitions for DARPA Internet TCP/IP protocols. Do not modify this file.

/etc/rpc

RPC services Maps RPC services to RPC numbers. The three columns in this file show the name of the server for the RPC program, the RPC program number, and aliases.

/etc/services

System services Lists system services. The three columns in this file show the informal name of the service, the port number/protocol the service frequently uses, and aliases for the service. This file does not specify which services are running on the local system, nor is it used to map services to port numbers. The services file is used internally to map port numbers to services for display purposes.

/etc/X11

Machine-local configuration for the X Window System

/Library

Third-party libraries and support Holds libraries and support files that are not part of the base system. Contrast with /System/Library.

/private

System-local files Holds files that cannot be shared between machines. The /etc, /tmp, and /var files are symbolic links to the /private/etc, /private/tmp, and /private/var directories, respectively. This setup allows systems to share the root filesystem (startup volume) over a network while retaining individual copies of core system files.

/private/etc

The target of the /etc symbolic link.

/private/tmp

The target of the /tmp symbolic link.

/private/var

The target of the /var symbolic link.

/sbin

Essential system binaries Utilities used for system administration are stored in /sbin and /usr/sbin. The /sbin directory includes utilities needed during the booting process, and /usr/sbin holds utilities used after the system is up and running. Programs that were in /etc on older UNIX systems will generally be in one of these directories.

/System

System files Holds system software and support code, including standard system fonts, kernel extensions, and the preference files that control launchd.

/System/Library

System libraries and support files Holds libraries and support files that are part of the base system and that are used with the Carbon and Cocoa APIs (page 478). This directory serves a function similar to that of /usr/lib.

/tmp

Temporary files Holds temporary files for many programs. This directory is a symbolic link to /private/tmp.

/Users

User home directories Holds users' home directories. It is possiblealbeit not commonto change the location of home directories.

/usr

Second major hierarchy Traditionally includes subdirectories that contain information used by the system. Files in /usr subdirectories do not change often and may be shared by several systems.

/usr/bin

Most user commands Contains the standard Mac OS X utility programsthat is, binaries that are not needed in single-user mode (page 437).

/usr/include

Header files included by C programs

/usr/lib

Libraries Holds static and shared libraries that are used with the UNIX API (page 478). Contrast with /System/Library.

/usr/sbin

Nonvital system administration binaries See /sbin.

/usr/share

Architecture-independent data Subdirectories of /usr/share include dict, doc, info, locale, man, misc, terminfo, and zoneinfo.

/usr/share/doc

Miscellaneous documentation

/usr/share/file/magic

Magic number database Most files begin with a unique identifier called a magic number. This file is a text database listing all known magic numbers on the system. When you use the file utility, it consults /usr/share/file/magic to determine the type of a file. Occasionally you will acquire a new tool that creates a new type of file that is unrecognized by the file utility. In this case you need to update the /usr/share/file/magic file; refer to the magic man page for details. See also "magic number" on page 941.

/usr/share/info

GNU info system's primary directory

/usr/X11R6

X Window System, version 11, release 6 Holds subdirectories that contain X11 binaries, libraries, and support files.

/var

Variable data Files with contents that vary as the system runs are found in subdirectories under /var. The most common examples are temporary files, system log files, spooled files, and user mailbox files. Subdirectories can include backups, log, run, spool, tmp, and yp. Older versions of UNIX scattered such files through several subdirectories of /usr (/usr/adm, /usr/mail, /usr/spool, /usr/tmp). This directory is a symbolic link to /private/var.

/var/log

Log files Holds lastlog (a record of the last login by each user), system.log (system messages from syslogd), and wtmp (a record of all logins/logouts).

/var/root

Home directory for root

/var/spool

Spooled application data Holds cups, mqueue, postfix, and samba.

/Volumes

Automounted volumes Holds automatically mounted volumes (filesystems). For more information refer to "/Volumes" on page 86.




A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net