13.1 UNIX Concepts
By logging in, you identify yourself to the system, distinguish yourself from other users, and insure that only you may gain access to your files. By having a personal login "account," separate from the system administrator account (even if you wear both hats at different times), you can insure that activities you perform as an ordinary user will not destroy, remove or otherwise harm important system files. Each user chooses a password for use when logging in. Your login name, or user name, and password are both case-sensitive. Thus, Pigeon is different from pigeon.
A Shell is simply the UNIX program that accepts, interprets and executes commands entered by the user. The shell provides a prompt, usually just a dollar sign. In various implementations and flavors of UNIX, there have been many different shells developed. The original UNIX shell was called the Bourne shell, or just sh. This is now considered hopelessly primitive, with bash, the Bourne Again shell, having supplanted it. There are also csh (the c-shell), ksh (the korn shell), tcsh, zsh and others as well. To find out what shell you are using, type, at the dollar sign prompt:
RWI, Inc, highly recommends the use of bash for use with BeeSoft.
In a UNIX system, there is a directory called /home where each users files are placed. Each user has a subdirectory under /home, named after that users login name. If your login name is pigeon, your home directory is /home/pigeon. User pigeon can create any number of directories and subdirectories under /home/pigeon. When pigeon logs in, he or she will be placed directly in /home/pigeon. Anytime you want to verify that you are indeed in your home, or "working directory," type the command pwd at the dollar sign prompt The system confirms the directory you are in.
A cd command with no arguments always returns you to your home directory.
Your home directory is often represented by the tilde (~) character. So, for user pigeon, the string ~/pie means that pie is located right in pigeons home directory.
File Ownership and Permissions
UNIX systems are designed for cooperative working, and for the open sharing of data and files. However, even in such a trusting environment, some degree of security and protection for individual users files and data is essential. UNIX systems thus include the concepts of file ownership and permissions. This area is quite critical to a full understanding of UNIX philosophy and operations.
Although the area of ownership and permissions is complex and often subtle, there are a few essential basics. One category of permissions applies to files. When a file is created, it is endowed with certain default permissions, based on who created it. There are three types of file permissions. Read permission lets a user look at a files contents. Write permission allows a user to change or delete a file. Execute permission lets the user run the file as an executable program.
There are also three types of permissions that apply to directories. Read permission lets a user list the contents of the directory. Write permission lets a user add or remove files from the directory. Execute permission means the user can list information about the files in the directory.
Who "owns" these permissions? Again, there are three levels. Each file has an owner and a group. The owner is the user who created the file. The group is that group of users who have access to the file."Others are all users who have access to the system, but are not a member of the files group.
With all these variables -- three levels of permission, three types of user for each file -- the understanding and management of ownership and permissions can get tricky. Be sure to study further in a good general UNIX reference, and be sure you are fully informed about thesetup at your site.
A user is an entity that owns an account on a UNIX system. Users are distinguished for reasons of identity, security and for keeping straight the various levels of system permissions to look at and/or modify particular files. A users account information authenticates that uses access to system resources. User accounts are vital where multiple users are going to be accessing the same system.
Users are not necessary individual human beings; there are also special user accounts such as root, used for system administration; news, used by a program called a news daemon to obtain and store in a spool directory newsfeeds (for example, from USENET newsgroups) so that ordinary users can access them; and other specializes user accounts.
Root and Superuser
The root account is a special case of a user account, used by the system administrator to perform system maintenance functions. When you are logged on as root, you are called a superuser and have all kinds of privileges and can access all the files on the system, no matter who created or "owns" them.
The most important thing to realize about the root account is that it can be quite dangerous, especially in the hands of a UNIX novice, or even an experienced user working on an unfamiliar UNIX system. As root, you have tremendous power to destroy. Unlike many more commercial operating systems, UNIX is designed for extraordinarily knowledgeable uses, and lacks much of the built in "idiot-proofing" which many users have come to take for granted. Thus, as root, a slip of the finger, a mistyped command, or other silly error can delete essential files, damage the filesystem or do other serious mischief.
No matter how careful and knowledgeable you are, you should log on and work as root only when absolutely necessary, for example, to perform system administration tasks such as fixing configuration files or installing new software.
Superuser can be thought of as just another term for a user logged into the root user account. The usual way to log in as root is with the su, or superuser, command. To log on as the superuser, you need to know the systems root password.
For security reasons, RWI, Inc., does not supply you with the root password. When you first log into the system, you should select and set your own root password. See Section 12.2.1 (above) for instructions for setting your sites root password. Always exercise extreme caution when using the root account. In inexpert or inattentive hands, it can be quite dangerous!
Man pages / apropos
"Man" (manual) pages are the UNIX form of online documentation. They can be extraordinary useful, as well as frustrating to navigate. Since they are optional in most installations, your site may have chosen not to install them, or to have installed only a subset. The command man <command> will display the man page, if there is one. The command apropos also accesses the man pages. For example, for information on the passwd command, you could type either man passwd or apropos passwd. Man pages often have "See also" notations at the very bottom that will direct you to other useful related man pages.
Redirection of stdin, stdout and stderr
There are three standard data streams associated with most UNIX operations: stdin is the standard input stream, for example, the command like you type at your workstation; stdout, the standard output stream from a commands or programs execution; and stderr, the standard destination for error messages from command or program executions. Most of the time, these defaults are all your own computer screen.
Sometimes, though, you might want to print the error messages or the output on paper, or just throw them away entirely. To do this, you redirect one or more of these standard streams. For example, to throw away error messages, you redirect the stderr stream to /dev/null.
There are two ways to redirect a stream. One is through the shell with a greater-than sign. For example, to list the contents of a directory and capture that list in another file, you might issue the command ls /usr/bin > ~/Binaries. The listing of /usr/bin will be saved in your home directory, in a file called Binaries. Beware that if Binaries already existed, this command would wipe it out and replace it with the new contents. However, if youre using the bash shell, you can issue the command noclobber=1 to prevent inadvertent wiping out of Binaries. Or, you could append the output, simply by using a doublegreater-than sign.
The other way to redirect a stream is through a pipe. Piping is a very powerful UNIX technique. With a pipe, represented by a vertical bar, you can send the output stream from one command directly into another.