ISee Imaging Systems Client Support Website

 

Home | Contact Us | Search

What's New
Software Upgrades
How To / FAQ
Trouble Shooting
Service Request
ISee Networks
ISee Software Manuals
Support Forum
ISee Workshops

 

bulletUNIX File Permissions
bulletDirectory Structure
bulletShells
bulletMounting and Unmounting Filesystems
bulletThe fstab File
bulletThe mount Command
bulletThe unmount Command
bulletProcesses

 

 

 

Unix File Permissions

Because the system is capable of supporting multiple users, everything the systems manages has a set of permissions governing who can read, write, and execute the resources. These permissions are stored as two octets broken into three pieces, one for the owner of the file, one for the group that the file belongs to, and one for everyone else. This numerical representation works like this:

Value Permissions

Directory Listing

0 - No read, no write, no execute ---
1 - No read, no write, execute --x
2 - No read, write, no execute -w-
3 - No read, write, execute -wx
4 - Read, no write, no execute r--
5 - Read, no write, execute r-x
6 - Read, write, no execute rw-
7 - Read, write, execute rwx

You can use the -l command line argument to ls (list) to view a long directory listing that includes a column with information about a file's permissions for the owner, group, and everyone else. Here is how the first column of ls -l is broken up:

-rw-r--r--

The first character, from left to right, is a special character that tells if this is a regular file, directory, a special character or block device, a socket, or any special pseudo-file device. The next three characters, designated as, rw-, gives the permissions for the owner of the file. The next three characters, r--, gives the permissions for the group that the file belongs to. The final three characters, r--, gives the permissions for the rest of the world. a dash means that the permission is turned off. In the case of this file, the permissions are set so the owner can read and write to the file, the group can read the file, and the rest of the world can only read the file. According to the table above, the permissions for this file would be 644, where each digit represents the three parts of the file's permission.

This is all well and good, but how does the system control permissions on devices? UNIX actually treats most hardware devices as a file that programs can open, read, and write data to just like any other file. These special device files are stored on the /dev directory.

Directories are also treated as files. They have read, write, and execute permissions. The executable bit for a directory has a slightly different meaning that that of files. When a directory is marked executable, it means it can be searched into, for example, a directory listing can be done in that directory.

There are more to permissions, but they are primarily used in special circumstances such as setid binaries and sticky directories. If you want more information on file permissions and how to set them, be sure to look at the chmod man pages.

Back to Top

 

Directory Structure

The UNIX directory hierarchy is fundamental to obtaining an overall understanding of the system. The most important concept to grasp is that of the root directory, "/" . This directory is the first one mounted at boot time and it contains the base system necessary to prepare the operating system for multi-user operation. The root directory also contains mount points for every other file system that you may want to mount.

A mount point is a directory where additional file systems can be grafted onto the root file system. Standard mount points include /usr, /var, /mnt, and /cdrom . These directories are usually referenced to entries in the file /etc/fstab . The /etc/fstab is a table of various file systems and mount points for reference by the system. Most of the file systems in /etc/fstab are mounted automatically at boot time from the script unless they contain the noauto option.

A brief overview of the most common directories include:

Directory Description
/ Root directory of the file system
/bin/ User utilities fundamental to both single-user and multi-user
/boot/ Programs and configuration files used during operating system bootstrap
/boot/defaults/ Default bootstrapping configuration files
/dev/ Device nodes
/etc/ System configuration files and scripts
/etc/defaults/ Default system configuration files
/etc/mail/ Configuration files for mail transport agents such as sendmail
/etc/namedb/ named configuration files
/etc/periodic/ Scripts that are run daily, weekly, and monthly
/etc/ppp/ ppp configuration files
/mnt/ Empty directories commonly used by system administrators as a temp mount point
/proc/ Process file system
/root/ Home directory for the root account
/sbin/ System programs and administrative utilities fundamental to both single/multi users
/stand/ Programs used in stand alone environment.
/tmp/ Temporary files
/usr/ The majority of user utilities and applications
/usr/bin/ Common utilities, programming tools, and applications
/usr/include/ Standard C include files
/usr/lib/ Archive libraries
/usr/libdata/ Miscellaneous utility data files
/usr/libexec/ System daemons & system utilities
/usr/local/ Local executables, libraries, etc.
/usr/obj/ Architecture-specific target tree produced by building the /usr/src/ tree
/usr/ports/ The UNIX ports collection
/usr/sbin/ System daemons & system utilities (executed by users)
/usr/share/ Architecture-independent files
/usr/src/ BSD and /or local source files
/usr/X11R6/ X11R6 distribution executables, libraries, etc.
/var/ Multi-purpose log, temporary, transient, and spool files
/var/log/ Miscellaneous system log files
/var/mail/ User mailbox files
/var/spool/ Miscellaneous printer and mail system spooling directories
/var/tmp/ Temporary files that are kept between system reboots
/var/yp/ NIS maps
Back to Top

 

Shells

In UNIX, a lot of everyday work is done in a command line interface called a shell. A shell's main job is to take commands from the input channel and execute them. A lot of shells also have built in functions to help everyday tasks such as file management, file globing, command line editing, command macros, and environment variables. UNIX comes with a set of shells, such as sh, the Bourne Shell, and tcsh, the improved C-shell. Many other shells are available from the UNIX Ports Collections, such as zsh and bash .

Which shell do you use? It is really a matter of taste. If you are a C programmer, you might feel more comfortable with a C-like shell such as tcsh. If you have come from Linux or are new to a UNIX  command line, you might try bash. The point is that each shell has unique properties that may or may not work with you preferred working environment, and that you have a choice of what shell to use.

One common feature in a shell is file name completion. Given the typing of the first few letters of a command or filename, you can usually have the shell automatically complete the rest of the command or filename by hitting the Tab key on the keyboard. Here is an example: suppose you have two files called foobar and foo.bar . You want to delete foo.bar. So what you would type on the keyboard is:

    rm fo [Tab]

The shell would print out rm foo[BEEP]. bar . The [BEEP] is the console bell, which is the shell telling me it was unable to totally complete the filename because there is more than one match. Both foobar and foo.bar start with foo, but it was able to complete to foo. . If you type in . , then hit Tab again, the shell would be able to fill the rest of the filename for you.

Another function of the shell is environment variables. Environment variables are a variable key pair stored in the shell's environment space. This space can be read by any program invoked by the shell, and thus contains a lot of program configuration. Here is a list of common environment variables and what they mean:

Variable Description
USER Current logged in user's name
PATH Colon separated list of directories to search for binaries
DISPLAY Network name of the X11 display to connect to, if available
SHELL The current shell
TERM The name of the user's terminal. Used to determine the capabilities of the terminal
TERMCAP Database entry of the terminal escape codes to perform various terminal functions
OSTYPE Type of operating system
MACHTYPE The CPU architecture that is system is running
EDITOR The user's preferred text editor
PAGER The user's preferred text pager
MANPATH Colon separated list of directories to search for manual pages

To view or set an environment variable differs somewhat from shell to shell. For example, in the C-Style shells such as tcsh and csh, you would use setenv to set and view environment variables. Under Bourne shells such as sh and bash, you would use set and export to view and set you current environment variables. For example, to set or modify the EDITOR environment variable, under csh or tcsh a command like this would set EDITOR to /usr/local/bin/emacs:

        # setenv EDITOR /usr/local/bin/emacs

Under Bourne shell:

        # export EDITOR="/usr/local/bin/emacs"

You can also make most shells expand the environment variable by placing a $ character in front of it on the command line. For example, echo $TERM would print out whatever $TERM is set to, because the shell expands $TERM and passes it to echo.

Shells treat a lot of special characters, called meta-characters as special representations of data. The most common on is the * character, which represents any number of characters in a filename. These special meta-characters can be used to do file name globing. For example, typing in echo * is almost the same as typing in ls because the shell takes all the files that match * and puts them on the command line for echo to see.

To prevent the shell from interpreting these special characters, they can be escaped from the shell by putting a backslash (\) character in front of them. The echo $TERM prints whatever your terminal is set to. The echo \$TERM prints $TERM as is.

Back to Top

 

Mounting and Unmounting Filesystems

The filesystem is best visualized as a tree, rooted, as it were, at /. /dev, /usr, and the other directories in the root directory are branches, which may have their own branches, such as /usr/local, and so on

There are various reasons to house some of these directories on separate filesystems. The /var contains the directories log/, spool/, and various types of temporary files, and as such, may get filled up. Filling up the root filesystem is not a good idea, so splitting /var from / is often favorable.

Another common reason to contain certain directory trees on other filesystems is if they are to be housed on separate physical disks, or are separate virtual disks, such as Network File System (NSF) mounts or CDROM drives.

Back to Top

 

The fstab File

During the boot process, filesystems listed in the /etc/fstab are automatically mounted (unless they are listed with the noauto option)

The /etc/fstab file contains a list of lines of the following format:

    device    /mount-point     fstype        options        dumpfreq        passno

device

 A device name (which should exist), as explained in the Disk naming conventions above.

mount-point

A directory (which should exist) on which to mount the filesystem.

fstype

 The filesystem type to pass to mount. The default filesystem varies form different flavors of UNIX.

options

Either rw for read-write filesystem, or ro for read-only filesystems, followed by any other options that may be needed. A common      option is noauto for filesystems not normally mounted during the boot sequence.

dumpfreq

This is used by dump to determine which filesystems require dumping. If the field is missing, a value of zero is assumed

passno

This determines the order in which filesystems should be checked. Filesystems that should be skipped should have their passno set to zero. The root filesystem (which needs to be checked before everything else) should have its passno set to 1 and the other filesystems' passno should be set to values greater than 1. If more than one filesystems have the same passno, then fsck will attempt to check filesystems in parallel if possible.

Back to Top

  

The mount Command

The mount command is what is ultimately used to mount filesystems. In its most basic form, you have

        # mount device mountpoint

There are plenty of options, but the most common are:   

Mount Options Descriptions
-a Mounts all the filesystems listed in /etc/fstab. Exceptions are those marked with noauto, excluded by the -t flag, or those that are already mounted
-d Do everything except for the actual system call. This option is useful in conjunction with the -v flag to determine what the mount is actually trying to do.
-f Force the mount of an unclean filesystem (dangerous), or force the revocation of write access when downgrading a filesystem's mount status from read-write to read-only
-r Mount the filesystem read-only. This is identical to using the rdonly argument to the -o option
-t fstype Mount the given filesystem as the given filesystem type, or mount only the filesystems of the given type, if given the -a option
-u Update mount options on the filesystem
-v Be verbose
-w Mount the filesystem read-write

 

Back to Top

 

The unmount Command

The unmount command takes, as a parameter, one of a mountpoint, a device name, or the -a or -A option.

All forms take -f to force unmounting, and -v for verbosity. Be warned that -f is not generally a good idea. Forcibly unmounting filesystems might crash the computer or damage data on the filesystem.

The -a and -A are used to unmount all mounted filesystems, possibly modified by the filesystem types listed after -t. The -A, however, does not attempt to unmount the root filesystem.

Back to Top

 

Processes

UNIX is a multi-tasking operating system. This means that it seems as though more than one program is running at once. Each program at any one time is called a process. Every command you run will start at least one new process, and there are a number of system processes that run all the time, keeping the system functional.

Each process is uniquely identified by a number call a process ID, and like files, each process also has one owner and group. The owner and the group information is used to determine what files and devices the process can open, using the file permissions discussed earlier. Most processes also have parent process which is the process that started them. For example, if you are typing commands to the shell, then the shell is a process, and any commands you run are also processes. Each process that you run in this way will have your shell as its parent process. The exception to this is a special process called init. The init is always the first process, so it process ID is 1. The init is started automatically by the kernel when UNIX starts.

 

 

Home | What's New | Software Upgrades | How To / FAQ | Trouble Shooting | Service Request | ISee Networks | ISee Software Manuals | Support Forum | ISee Workshops

Questions or problems regarding this web site should be directed to webmaster@isee-client-support.com.
Copyright 2002 ISee Imaging Systems. All rights reserved.
Last modified: 04/28/02.