- User environment
- File system
- Processes
Note: For improved legibility, this file uses Cascading Style Sheets--supported in version 4 and later of the Netscape and Microsoft browsers.
- User environment
- Unix is a multi-user operating system.
- Multi-user means that multiple people use the same computer, possibly at the same time. As a consequence, Unix computers implement access controls, and accept connections from other devices besides the main computer unit itself.
- Access Control
- Each user needs to identify him/herself to the operating system before beginning to use the computer. This process is called login, and requires that the user enter a userid (assigned name, also called username), and a password.
- In most cases, userids and passwords are case sensitive, meaning that upper- and lower-case letters are considered different (e.g., if your password is 'mySecret', typing 'mYsecret' won't work). Typically, additional restrictions are placed on the type and length of userids and passwords.
- It is very important that the password be unique and hard-to-guess. Weak passwords may allow intruders in, which may lead to damage not only to your own work, but also to that of other users.
- At the end of a work session, users need to logout, telling the system that they are done using the computer and that access under their userid should be discontinued.
- Just like secure passwords, prompt logouts are essential to system security. Never leave a logged-in terminal unattended.
- Terminals
- Each user connects to the Unix computer through a device called a terminal. While in the past these devices were actual hardware items, they are now often emulated in software, either as an application running on a separate personal computer, or as a window within the graphical user interface of the Unix machine itself.
- The terminal provides a command-line interface, allowing the user to:
- input commands into the system
- read the results of the commands
- To indicate that the user is sitting at the Unix computer itself, the word console may be used for their terminal. Even in an emulated environment, a console window has a special status, since it displays system messages.
- Shells
- Users interact with the Unix operating system through a special program called the shell. The shell receives the user's commands and relays them to the appropriate part of the operating system.
- Most Unix commands use a standard format for command-line invocation through the shell:
- first the name of the command (which is the same as the pathname to a program executing the requested action, or the name of a shell built-in command)
- Commonly-used commands can be invoked by their name alone, since the path to their location in the filesystem is already known to the shell (through its configuration files).
- after the name, separated by space(s), come single letters preceded by a dash. These are the options to the command (modifying the way it operates).
- last, separated again by space(s), are the parameters (generally corresponding to items on which the command will operate.
- The following is an example of a command-line entry to show the contents of a directory:
ls -al /usr/local
The name of the command is 'ls' (the rest of the pathname is known to the shell). The options are 'a' (showing all files including invisible ones), and 'l' (long-format listing, including ownership, permissions, filesizes, modification date); notice that multiple options (not separated by spaces) can follow a single dash. The parameter is the pathname to the directory we want to see the contents of.
- While all shell programs share basic functions and features, some of their differences may be important enough to change the way you use the Unix computer. The default shell for Irix 5.3 Unix is csh (the C-shell).
- An important feature of csh that may affect the way commands operate are aliases. Aliases are shortcuts for typing a some long or intricate entry on the command line. For example, ls in the default Irix 5.3 configuration of csh is aliased to ls -a: when you enter ls on the command line, you automatically get the 'a' option as well, adding 'invisible' files to the directory listing.
- Use the command alias to see a complete list of all the aliases currently defined.
- Configuration files
- Unix stores a number of settings affecting the user environment in plain-text configuration files.
- The names of these files generally start with a period, making them 'invisible'--they are normally not displayed in directory listings.
- Most configuration files are seldom edited by the user. Hiding them reduces clutter in listings.
- Many of these filenames also end with 'rc' (for 'read commands'), while the rest of the name lets you guess which part of the system is affected by the settings they contain. For instance, the file .cshrc contains settings for the C-shell, csh.
- There are exceptions to this rule. For instance, the file .profile contains settings for another shell, sh.
- File system
- Storage organization
- The files on a Unix system are arranged in a directory tree, starting at the root--indicated by a single '/' (forward slash)--and branching out in directories and nested subdirectories.
- At any one time, the user is said to be 'located' at a particular directory within the file system--this is the directory to which commands apply in the absence of further specifications, and is called the current working directory (cwd).
- Filenames
- The name of a file on most Unix systems can be up to 255 characters long. Several characters will cause problems when used in filenames--it is safer to stick with digits and letters only (no spaces, punctuation, or special characters). Like userids and passwords, filenames are case sensitive, meaning that upper- and lower-case letters are considered different (e.g., you can have both a 'Sample' file and a 'SAMPLE' file in the same directory).
- Pathnames
- A file's pathname lists the directories to look in to get at the file. Between the names of the directories is the directory separator character--again, the '/' (forward slash).
- Pathnames that start with the root of the filesystem are called absolute pathnames. For example, the absolute pathname to a file called 'sample', located in a 'tmp' directory which in turn is inside the 'usr' directory, is:
/usr/tmp/sample
- Pathnames that start from the current working directory are called relative pathnames. For example, if the cwd is '/usr', then the following is a relative pathname to the same 'sample' file mentioned before:
tmp/sample
Notice in this last example the absence of a leading forward slash.
- In a pathname, use a '.' (period) to indicate the current directory, and '..' (two periods) to indicate the parent (enclosing) directory. For example, if the cwd is '/etc', then the following is a relative pathname to the same 'sample' file mentioned before:
../usr/tmp/sample
- Home directories
- Each user of a Unix computer is given a directory within the filesystem called his/her home directory. This is the initial working directory whenever the user logs into the system.
- In the standard arrangement of directories on a Unix filesystem, users' home directories are located under the '/usr' directory. On Irix 5.3 workstations, home directories are in '/usr/people'.
- Volumes
- Storage devices connected to the Unix computer (such as additional hard drives, floppy drives, CD-ROM drives, etc), appear as directories at specific locations in the file system called volume mount points. For example, a CD-ROM connected to an Irix 5.3 workstation appears as the contents of the directory '/CD-ROM' (if there is no disc in the drive, the directory is empty).
- Ownership and permissions
- Due to its multi-user nature, Unix provides protection against file tampering. Each file or directory has an owner (typically, the individual who created the file, though the file can be reassigned later), and a set of access permissions, specifying the kind of access allowed for different categories of users.
- The owner is indicated by the users' userid, plus a group that the user belongs to.
- Each user may belong to multiple groups, allowing secure access to information for shared tasks. Only one of the user's groups can be listed for each file's ownership.
- In commands, userid and group are listed as two words separated by a '.' (period).
- Access categories are: 'user', 'group', and 'other' (every other person with access to the system). These are abbreviated in commands as 'u', 'g', 'o'. The abbreviation for all categories at once is 'a'.
- Access permissions are 'read', 'write', and 'execute', abbreviated as 'r', 'w', 'x'. No access is indicated by a '-' (hyphen).
- Users with read access to a file or directory can see its contents.
- Users with write access to a file can modify its contents. Write access to a directory allows creating, renaming, or deleting files within the directory.
- Users with execute access to a file can run the file (assuming that it contains a valid program or script). Execute access to a directory is also called search permission, and allows full access (read, write, execute) to the files it contains.
- Access permissions are indicated in long-format directory listings as nine consecutive characters for each file. The first three characters indicate 'user' access permissions, the second set of three indicates 'group' permissions, the last three indicate 'other' permissions.
- The nine permission characters are preceded by a character indicating the type of the file.
- Processes
- Unix is a multi-tasking operating system.
- Multi-tasking means that multiple programs can share the same computer. A multi-processor system may actually run programs concurrently, but on most systems running programs are scheduled in such a way as to appear to execute all at the same time. Each running program is called a process. The same program can be run multiple times, resulting in multiple simultaneous processes.
- Running
- Invoking most commands will cause a separate process to execute. Besides user processes, many additional processes may be running on the same machine to service system functions (a process that is started automatically and runs continuosly is called a daemon).
- A user process normally runs in the foreground and ties up the terminal it was started from, awaiting input and/or displaying output. To avoid this, a process can be run in the background by appending '&' (ampersand) to the command line. The following example starts up a web browser and immediately returns terminal control to the user:
communicator &
- Listing
- Each process is assigned a pid (process ID) number. You can find out the pid of processes you started with the ps command (the pid is the number at the beginning of each line in the list).
- Stopping
- Most processes automatically terminate when their job is done. To stop unintended or erratic processes, you can use the following commands:
- For a foreground process, use 'Control-C' (hold down the 'Control' key and press the 'C' key).
- For a background process, find its pid, then use it as the parameter to the kill command. For example, to stop a process whose pid is '1234' you would use:
kill 1234
- Use the latter approach to recover from a misbehaving process that locks up the terminal (you will need to do this from another terminal).