|
|
Table of ContentsIntroduction 1 - What is UNIX
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Next |
IntroductionA Hands on class, and group therapy session, intended to remove the fear you hold deep within regarding this evil uncle Unix of yours. We hope to discover that beneath his dull green terminal, the exciting colorful guy that's been hidden there, waiting to fufill your wildest computing dreams. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Your LecturerMy background is mechanical engineering, which I did for about 15 years. During that time I learned to use computers, and eventually began using Unix machines around 1990 to run CAD/CAM software on. I wrote software during that period that enabled designers to solve various visual and computational problems unique to our product line. Eventually I knew too much about Unix and was sentenced to keep our network of 500 machines running. Realizing my fate, I fled to Smith College, where I do pretty much the same thing, but with a lot less machines and PHB's (Pointy Haired Boss's). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Why this Class?I have found that for a scientist or engineer, Unix is hard to beat for a computing platform. It's sort of a Swiss-Army-Knife computer. It's a abrupt, get-to-the-point kind of operating system, that was born in a research lab and never got the polish applied that the Windows world did. That's the bad thing about unix, it's hard to learn. It's also the good thing about Unix, which I hope you will begin to see by the end of this class. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Which Books should I get?Easy answer. Unix in a Nutshell by O'Reilly. This is the only Unix book you need. Forget all the others. All you need is a basic understanding of how the thing works and a few conventions understood and your on your way. That is the purpose of this class, to give you the confidence to sit at a terminal (or Xterm) and open your book and create solutions for yourself. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
1 - What is UNIX |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
History of UnixThe Unix operating system found its beginnings in MULTICS, which stands for Multiplexed Operating and Computing System. The MULTICS project began in the mid 1960s as a joint effort by General Electric, Massachusetts Institute for Technology and Bell Laboratories. In 1969 Bell Laboratories pulled out of the project.One of Bell Laboratories people involved in the project was Ken Thompson. He liked the potential MULTICS had, but felt it was too complex and that the same thing could be done in simpler way. In 1969 he wrote the first version of Unix, called UNICS. UNICS stood for Uniplexed Operating and Computing System. Although the operating system has changed, the name stuck and was eventually shortened to Unix. Ken Thompson teamed up with Dennis Ritchie, who wrote the first C compiler. In 1973 they rewrote the Unix kernel in C. The following year a version of Unix known as the Fifth Edition was first licensed to universities. The Seventh Edition, released in 1978, served as a dividing point for two divergent lines of Unix development. These two branches are known as SVR4 (System V) and BSD. Ken Thompson spent a year's sabbatical with the University of California at Berkeley. While there he and two graduate students, Bill Joy and Chuck Haley, wrote the first Berkeley version of Unix, which was distributed to students. This resulted in the source code being worked on and developed by many different people. The Berkeley version of Unix is known as BSD, Berkeley Software Distribution. From BSD came the vi editor, C shell, virtual memory, Sendmail, and support for TCP/IP. For several years SVR4 was the more conservative, commercial, and well supported. Today SVR4 and BSD look very much alike. Probably the biggest cosmetic difference between them is the way the ps command functions. The Linux operating system was developed as a Unix look alike and has a user command interface that resembles SVR4. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
The Connection Between Unix and CAt the time the first Unix was written, most operating systems developers believed that an operating system must be written in an assembly language so that it could function effectively and gain access to the hardware. Not only was Unix innovative as an operating system, it was ground-breaking in that it was written in a language (C) that was not an assembly language.The C language itself operates at a level that is just high enough to be portable to variety of computer hardware. A great deal of publicly available Unix software is distributed as C programs that must be complied before use. Many Unix programs follow C's syntax. Unix system calls are regarded as C functions. What this means for Unix system administrators is that an understanding of C can make Unix easier to understand. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Why Use Unix?One of the biggest reasons for using Unix is networking capability. With other operating systems, additional software must be purchased for networking. With Unix, networking capability is simply part of the operating system. Unix is ideal for such things as world wide e-mail and connecting to the Internet.Unix was founded on what could be called a "small is good" philosophy. The idea is that each program is designed to do one job well. Because Unix was developed different people with different needs it has grown to an operating system that is both flexible and easy to adapt for specific needs. Unix was written in a machine independent language. So Unix and unix-like operating systems can run on a variety of hardware. These systems are available from many different sources, some of them at no cost. Because of this diversity and the ability to utilize the same "user-interface" on many different systems, Unix is said to be an open system. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Unix AnatomyAs is illustrated here, Unix is a multi layered system. In a strictly physical sense the kernel, shell, and utilities rest on the hardware. Logically the system is arranged as the diagram shows.Although the words "operating system" are frequently used to refer to the kernel, shells, and the utilities or commands. Technically utilities are not part of the operating system. Utilities that come with the operating system are basic tools that have evolved into standard Unix commands. They make the operating system more immediately useful to the user, but only the kernel and the shell are truly the operating system. Each layer in the system can be thought of as a country with its own indigenous language. Hardware includes the physical parts of the system: monitor, mouse, printer, cables, chips, etc. The hardware layer and the user layer are monolingual. They can only talk to one other layer of the system. The hardware can converse with the kernel. The kernel is bilingual. It can talk to the hardware or to the shell. The shell is multi lingual and can talk to any part of the system with the exception of the hardware. The shell can be thought of as the master interpreter. It retrieves the file that holds instructions for every command that's typed in and it allows users to utilize the services of the kernel. Unix utilities can converse with the shell and indirectly with the kernel. Utilities use functions called system calls to request services from the kernel. They cannot interact with the kernel directly.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using Man Pages"The Unix approach to on-line documentation works fine if you are interested in documenting a few hundred programs and commands that you, for the most part, can keep in your head anyway. It starts to break down as the number of entries in the system approaches a thousand; add more entries, written by hundreds of authors spread over the continent, and the swelling, itching brain shakes with spasms and strange convulsions."Unix manual pages are created by the man command which finds, prints, and displays entries from the online reference manuals. Man pages are vendor specific by necessity, as individual commands and options to them may vary from operating system to operating system. Man pages are organized into sections. The content of each section can vary slightly between vendors, however they are basically ordered as follows:
The manual pages can be accessed via the man command. For example, entering, man ls, means that all sections of the manual pages are searched for information on the ls command. Searches can also be limited to a particular section, keyword, filename or combinations of these. Typing man man at the command line will print a list of all the options for man as well as instructions on how to do searches by section, keyword, filename, etc. The X Window System uses xman, a graphical browsing tool for viewing man pages. With xman the user is presented with a listing of all available man pages and a "Sections" menu. Because man pages are tersely written they can be most helpful for looking up things such as the options to or syntax of a command. They can also be useful for finding out what command performs a particular function, by using the function as the keyword for a keyword search to locate the command. Due to the style in which they're written, man pages are generally not a a good place to go for learning the basics of how a command works. Tip: check out the whatis command, also the keyword (-k) option of the man command.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
SuperuserThe superuser is a privileged user who has unrestricted access to the whole system; all commands and all files regardless of their permissions. By convention the username for the superuser account is root.The root account is necessary as many system administration files and programs need to be kept separate from the executables available to non-privileged users. Unix allow users to set permissions on the files they own. A system administrator may need to override those permissions. Access to the root account is restricted by a password. Because the superuser has the potential to affect the security of the entire system, it is recommended that this password be given only to people who absolutely need it, such as the system administrator. It is also a good idea to change the password on this account often. On BSD derivative systems, users who have access to the root account are frequently listed as members of group 0, also known as wheel. There are several ways to log into the root account. If a system comes up in single user mode whoever is logged in automatically has root privileges. When a system is already up in multi user mode, a user can log in directly as root. This is not recommended as it is easy to take superuser privileges for granted and perform mundane tasks in this mode. When a user is already logged in, issuing the su command, without options, will cause the system to prompt for the root password. Once it is given the user becomes root. The root account has its own shell and frequently displays a prompt that is different from the normal user prompt. If this is not the case, changing the default shell for the root account will change the prompt. Commands and programs that a system administrator will need as root are kept in /etc to decrease the chances of a user trying them by accident. For example, /etc contains /etc/passwd, which holds a list of all users who have permission to use the system. Because the root account has extensive privileges it has an equal
potential for destruction. This is amplified by the fact that
safeguards built into some commands do not apply to this account. For
example, the superuser may change another user's password without
knowing the old password. The superuser can also mount and unmount file
systems, remove any file or directory, and shut down the entire system.
The root account should be used with caution and only when necessary to
perform a given task. A misplaced keystroke in this mode can have
disastrous results.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
2 - Files and commands |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Everything is a fileOne of the unique things about Unix as an operating system is that regards everything as a file. Files can be divided into three categories; ordinary or plain files, directories, and special or device files.Directories in Unix are properly known as directory files. They are a special type of file that holds a list of the other files they contain. Ordinary or plain files in Unix are not all text files. They may also contain ASCII text, binary data, and program input or output. Executable binaries (programs) are also files, as are commands. When a user enters a command, the associated file is retrieved and executed. This is an important feature and contributes to the flexibility of Unix. Links are a special file type that allows two files names/paths to actually point to the same file. They are a powerful feature. Special files are also known as device files. In Unix all physical devices are accessed via device files; they are what programs use to communicate with hardware. Files hold information on location, type, and access mode for a specific device. There are two types of device files; character and block, as well as two modes of access. Block device files are used to access block device I/O. Block devices do buffered I/O, meaning that the the data is collected in a buffer until a full block can be transfered. Character device files are associated with character or raw device access. They are used for unbuffered data transfers to and from a device. Rather than transferring data in blocks the data is transfered character by character. One transfer can consist of multiple characters. Some devices, such as disk partitions, may be accessed in block or character mode. Because each device file corresponds to a single access mode, physical devices that have more than one access mode will have more than one device file. Device files are found in the /dev directory. Each device is assigned a major and minor device
number. The major device number identifies the type of device, i.e. all
SCSI devices would have the same number as would all the keyboards. The
minor device number identifies a specific device, i.e. the keyboard
attached to this workstation.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Working with Files and DirectoriesThe following topics will be discussed in this section:
The UNIX filesystem structureAll the stored information on a UNIX computer is kept in a filesystem. Any time you interact with the UNIX shell, the shell considers you to be located somewhere within a filesystem. Although it may seem strange to be "located" somewhere in a computer's filesystem, the concept is not so different from real life. After all, you can't just be, you have to be somewhere. The place in the filesystem tree where you are located is called the current working directory.CONCEPT: The UNIX filesystem is heirarchical (resembling a tree structure). The tree is anchored at a place called the root, designated by a slash "/". Every item in the UNIX filesystem tree is either a file, or a directory. A directory is like a file folder. A directory can contain files, and other directories. A directory contained within another is called the child of the other. A directory in the filesystem tree may have many children, but it can only have one parent. A file can hold information, but cannot contain other files, or directories. ![]() CONCEPT: To describe a specific location in the filesystem heirarchy, you must specify a "path." The path to a location can be defined as an absolute path from the root anchor point, or as a relative path, starting from the current location. When specifying a path, you simply trace a route through the filesystem tree, listing the sequence of directories you pass through as you go from one point to another. Each directory listed in the sequence is separated by a slash. UNIX provides the shorthand notation of "." to refer to the current location, and ".." to refer to the parent directory. These two symbols actually are two hidden directories, the first being a link to the entries in the file structure for the current directory, and the second a link to the entries in the file structure in the directory just above it in the directory tree. These names make it easier to move through the directory tree and to describe paths relative to the current directory. EXERCISE: Specify the absolute path to the directory named jon at the bottom of the tree diagram. EXPLANATION: Since the absolute path must always begin at the root (/) directory, the path would be:
EXPLANATION: Starting from the student directory, we would first have to move up the filesystem tree (using the .. notation) to the directory called users before we could descend to the directory called jon. The path would be:
Changing DirectoriesIn UNIX, your location in the filesystem heirarchy is known as your "current working directory." When you log in, you are automatically placed in your "home directory." To see where you are, type the command
To change your location in the filesystem heirarchy, use the cd (change directory) command, followed by an argument defining where you want to go. The argument can be either an absolute path to the destination, or a relative path. EXAMPLE: Type the command
If you type the cd command without an argument, the shell will place you in your home directory. EXERCISE: Type the command
EXPLANATION: The cd .. command should have moved you up one level in the directory tree, since .. is UNIX shorthand for the parent directory. The result of the second pwd command should be the same as the first, with the last directory in the path omitted. File and directory permissionsCONCEPT: UNIX supports access control. Every file and directory has associated with it ownership, and access permissions. Furthermore, one is able to specify those to whom the permissions apply.Permissions are defined as read, write, and execute. The read, write, and execute permissions are referred to as r, w, and x, respectively. Those to whom the permissions apply are the user who owns the file, those who are in the same group as the owner, and all others. The user, group, and other permissions are referred to as u, g, and o, respectively. A short note on groups: UNIX allows users to be placed in groups, so that the control of access is made simpler for administrators. The meaning of file and directory permissions
Viewing permissionsTo see the permissions on a file, use the ls command, with the -l option.EXAMPLE: Execute the command
-rw-r--r-- 1 root sys 41002 Apr 17 12:05 /etc/passwd The first 10 characters describe the access permissions. The first dash indicates the type of file (d for directory, s for special file, - for a regular file). The next three characters ("rw-") describe the permissions of the owner of the file: read and write, but no execute. The next three characters ("r--") describe the permissions for those in the same group as the owner: read, no write, no execute. The next three characters describe the permissions for all others: read, no write, no execute. Setting permissionsUNIX allows you to set the permissions on files that you own. The command to change the file permission mode is chmod. The chmod command requires you to specify the new permissions you want, and specify the file or directory you want the changes applied to.To set file permissions, you may use the rwx (read, write, and execute) notation to specify the type of permissions, and the ugo (user, group, others) notation to specify who those permissions apply to. To define the kind of change you want to make to the permissions, use the plus sign (+) to add a permission, the minus sign (-) to remove a permission, and the equal sign (=) to set a permission directly. EXAMPLE: Type the command
EXERCISE: Change the permissions on the .cshrc file in your home directory so that group and others have read permission only. EXPLANATION: Typing the command
Listing the contents of a directoryThe ls command allows you to see the contents of a directory, and to view basic information (like size, ownership, and access permissions) about files and directories. The ls command has numerous options, so see the manual page on ls (type man ls) for a complete listing. The ls command also accepts one or more arguments. The arguments can be directories, or files.EXAMPLE: Type the command
In the example, the l and R options of the ls command are invoked together. Some commands permit you to group options in that way, and some commands require the options to be named separately, e.g., ls -l -r. The l option calls for a long output, and the R option causes ls to operate recursively, moving down directory trees. The last part of the example, /etc/i*, directs the ls command to list files and directories in the /etc directory, that begin with the letter "i". The wildcard character, "*", matches any character(s). EXERCISE: Type the command
EXPLANATION: The shell responded by printing all the entries in the /etc directory that start with the letter "i", and end with the letter "g". The -m option causes the output to be streamed into a single line. See the manual page for ls to get a complete description of the ls command's options. EXERCISE: Find the permissions on your home directory. EXPLANATION: There are many ways to accomplish this. You could type
Viewing the contents of a fileCONCEPT: Text files are intended for direct viewing, and other files are intended for computer interpretation.The UNIX file command allows you to determine whether an unknown file is in text format, suitable for direct viewing. EXERCISE: Type the command
EXPLANATION: The shell is a shared executable, indicating that the file contains binary instructions to be executed by the computer. The cat command
EXAMPLE: Send the contents of your .cshrc file to the screen by typing
The more command
EXAMPLE: Type
The head and tail commands
EXAMPLE: Type
The tail command works like head, except that it shows the last lines of of file. EXAMPLE: Type
Copying files and directoriesThe UNIX command to copy a file or directory is cp. The basic cp command syntax is cp source destination.EXAMPLE: The command
EXERCISE: Describe the permissions necessary to successfully execute the command in the previous example. EXPLANATION: To copy the .cshrc file, one must have read permission on the file. To create the new file called pcopy, one must have write permission in the directory where the file will be created. Moving and renaming filesThe UNIX mv command moves files and directories. You can move a file to a different location in the filesystem, or change the name by moving the file within the current location.EXAMPLE: The command
Removing filesThe rm command is used for removing files and directories. The syntax of the rm command is rm filename. You may include many filenames on the command line.CAUTION: Once the rm command has been executed on a file it is gone and cannot be retreived.EXAMPLE: Remove the qcopy file that you placed in your home directory in the section on moving files by typing
Creating a directoryThe UNIX mkdir command is used to make directories. The basic syntax is mkdir directoryname. If you do not specify the place where you want the directory created (by giving a path as part of the directory name), the shell assumes that you want the new directory placed within the current working directory.EXAMPLE: Create a directory called temp within your home directory by typing
EXPLANATION: Once the temp directory is created, you could just type
Removing a directoryThe UNIX rmdir command removes a directory from the filesystem tree. The rmdir command does not work unless the directory to be removed is completely empty.The rm command, used with the -r option can also be used to remove directories. The rm -r command will first remove the contents of the directory, and then remove the directory itself. CAUTION: When the rm -r command is executed on a directory the directory and all it's contents are removed and cannot be retreived.EXERCISE: Describe how to remove the temp directory you created, using both rmdir, and rm with the -r option.EXPLANATION: You could enter the commands
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Introducing Redirection and PipesThis is feature that comes from the shell. Our next session will focus on shells completely, but we will introduce it now to facilitate our working with our file manipulation commands.Redirection is a shell feature that allows us to direct command output to
files. By default report their results to a special file called
Standard Output (stdout) which during an interactive session (your at a terminal) is
mapped to the screen. Therefore if you type cat myfile the contents of myfile will be printed on the screen. If you type
cat myfile > newfile nothing will appear on the screen, instead stdout will be
redirected to newfile, either creating or replacing the contents of
newfile. You can replace the > with >> which appends the contents to
file (if it exists). The other special files we are concerned with are
Standard Error (stderr) and Standard Input (stdin). Stderr is the file error messages are directed to from commands.
This is also mapped to the screen by default. Stdin is assigned to the
terminal by default as well. Therefore using our cat example: cat >&
newfile will take input from stdin (the terminal)
Pipes (|) make use of commands adherence to stdin and stdout. If you connect two or more commands like cmd1 | cmd2 , the stdout of cmd1 is redirected to the stdin of cmd2. You can make your own commands using this operator. Remember this is a shell feature, it is not the same kind of pipe that C programmers use for interprocess communication. Example: ls | wc -w reports the number of files in a directory.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using Pipes and FiltersCONCEPT: UNIX allows you to connect processes, by letting the standard output of one process feed into the standard input of another process. That mechanism is called a pipe.Connecting simple processes with a pipe allows you to perform complex tasks without writing complex programs. EXAMPLE: Using the more command, and a pipe, send the contents of your .rhosts and .cshrc files to the screen by typing
EXERCISE: How could you use head and tail with a pipe to display lines 25 through 75 of a file? ANSWER: The command
It is easy for beginners to confuse the usage of the input/output redirection symbols < and >, with the usage of the pipe. Remember that input/output redirection connects processes with files, while the pipe connects processes with other processes. GrepThe grep (global regular expression and print) utility is one of the most useful filters in UNIX. The grep utility searches line-by-line for a specified pattern, and outputs any line that matches the pattern. The basic syntax for the grep command is grep [-options] pattern [file]. If the file argument is omitted, grep will read from standard input. It is always best to enclose the pattern within single quotes, to prevent the shell from misinterpreting the command.The grep utility recognizes a variety of patterns. Here are some of the characters you can use to build regular expressions:
EXAMPLE: Type the command
EXERCISE:List all the files in the /tmp directory owned by the user root. EXPLANATION: The command
EXERCISE:List all the processes owned by the user root. EXPLANATION: The command
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Commands - the Unix wayUnix is infamous for it's commands, zillions of commands, each one with zillions of options. For better or worse we need to understand some basic conventions regarding the commands we type.Convention
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Good Basic commandsThe following is a list of basic commands you will get to know. We will explore most of these in our labs, and build some applications using them. Note, all of these commands work at a terminal and a text based. X windows is not required.
File Manipulation commandsThis list is an essential group of commands that you should be familiar with. Of course ls and cd are an essential requirement to just get around the filesystem, but do you know what csplit does? There are quite a few other commands that could be listed here, but this list is enough to take you a long way.
File Searching and Comparison
Command text editing
Interactive text editing
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
3 - Text Handling |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Editing Text with EMACSOne of the most basic operations you will need to perform on a UNIX system is text editing. Whether you are preparing a document, writing a program, or sending email to a colleague, you will need a utility to allow you to enter and edit text.There are many editors available for UNIX systems, but this discussion will focus on the emacs text editing program because of its power, flexibility, extensibility, customizability, and prevalence. No matter where you get a UNIX account, you are likely to have emacs at your disposal. Here is an index to the topics in this section:
General features of the emacs editorEmacs is a visual editor. That means that you have a representation of your entire document on your screen, and you can move around freely, editing any part of the document you wish. Older editors, referred to as line editors, required all changes to the file to be made on a line-by-line basis. Each command to a line editor specified a line number, and the changes to be applied to that line. Line editors are truly horrible things, and you should feel lucky if you have never seen one.Emacs prefaces commands with either a control character or meta character in order to distinguish editor commands from text to be inserted in the buffer. In this tutorial the notation "Control-X" means to hold down the Ctrl key, and type the letter "x". You don't need to capitalize the "x" or any other control character, by holding down the shift key. Meta characters vary depending on the system, usually it they are the Escape, Alternate, or Extended character keys. With the Esc key the notation "Meta-X" means to press the escape key down, release it, and then type "x". With the Alt or Extended char keys the notation "Meta-X" means to press down either of Alt or Extended char and simultaneously press type the letter "x". Working with buffersWhen you edit a file in emacs, you're not really editing the file itself, as it sits out on a disk somewhere. Instead, emacs makes a copy of the file, and stores the copy in a part of RAM memory called a buffer. All the changes you make to the file are applied to the buffer. When you save the file, emacs writes the contents of the buffer to the disk.Because the buffer exists in RAM memory, it disappears if the power is turned off, or if the system crashes. Thus, you should use the save command often, flushing your current buffer to disk. Once the file is on disk, a power outage or system crash shouldn't harm it. Basic operations in emacsHere are some of the fundamental things you'll need to do when you edit a document in emacs.Starting emacsTo start emacs, just type the command
Quitting emacsTo exit emacs and return to the UNIX shell, type Control-X-Control-C. If you have made changes to the buffer since the last time you saved it to disk, emacs will ask you if you want to save. Type y for yes, or n for no.Getting helpEmacs has an on-line help system that can be invoked by typing Control-H. If you type the question mark (?), emacs will present a list of help topics you can choose.The emacs displayThe display in emacs is divided into three basic areas. The top area is called the text window. The text window takes up most of the screen, and is where the document being edited appears. At the bottom of the text window, there is a single mode line. The mode line gives information about the document, and about the emacs session. The bottom line of the emacs display is called the minibuffer. The minibuffer holds space for commands that you give to emacs, and displays status information.Aborting a commandYou can abort an emacs control or escape sequence by typing the command Control-G.Working with filesTo read a disk file into an emacs buffer, type the command Control-X-Control-F. Emacs will ask you for the name of the file. As you type the name of the file, it will be displayed in the minibuffer. When you have entered the file name, press the return key, and emacs will load the file into a buffer, and display it in the text window.The command to save the contents of the buffer to a disk file is Control-X-Control-S. The save command overwrites the old version of the file. You may also write the contents of the buffer to a different file with the command Control-X-Control-W. Emacs will prompt you for the name of the file you want to create. To create a new file, use Control-X-Control-F, just as if the file already existed. When emacs asks you for the file name, type in the name you want your new file to have, and emacs will create the file, and display an empty buffer for you to type in. Emacs will perform file name completion for you. Type part of the name of the file you want, and press the spacebar or tab key to get emacs to complete a file name. If the partial name you've given matches more than one file, emacs will display a list of all potential matches. You can continue typing in more of the file's name, and pressing either file completion key, until you zero in on the file you want. Cursor motionOn well-configured systems, you will find that the keyboard arrow keys will function correctly in emacs, moving you forward or backward one character at a time, and up or down one line at a time. If the arrow keys do not work, here's how to accomplish the same functions:
Inserting and deleting textTo insert text into a buffer, place the cursor where you want to start inserting text, and start typing away.If you want to insert the contents of another file into the current buffer, place the cursor at the desired insertion point, and type Control-X-I. Emacs will ask you for the name of the file you wish to insert. You may also insert text by cutting it from one place, and pasting it at the insertion point. See the next section for information on cutting and pasting. ild all the Khoro Deleting text is easy. As you'd expect, the delete key (or backspace key) deletes backward one character. Here are some other ways to delete text:
Cutting and pasting text regionsEmacs allows you to select a region of text, and perform cut and paste operations on the region. It uses a temporary storage area called the "kill buffer" to allow you to store and retrieve blocks of text. There is only one kill buffer in emacs, which means that you can cut text from one document, and paste it into another.To define a region of text, place the cursor at one end of the region and press Control-spacebar. That sets the mark. Then, move the cursor to the other end of the region. The text between the mark and the cursor defines the region. To cut a region of text, and place it in the kill buffer, use the command Control-W (think of Wipe). The paste command is Control-Y. It Yanks the block of text from the kill buffer, and places it where the cursor rests. The Control-Y command only retrieves the most recently-cut block of text. You can paste in earlier cuts by pressing ESCAPE-Y. The ESCAPE-Y command, used repeatedly, will take you back through several previous text blocks that were cut. The ESCAPE-Y command does not work unless you type Control-Y first. You may copy a region of text into the kill buffer without cutting it. Define the text block by setting the mark at one end, and moving the cursor to the other end. Then type ESCAPE-W. Undoing changesIt is possible to undo the changes you have made to a file by entering the command Control-_. (That's Control-underscore. On some keyboards, you'll have to hold down both the control and shift keys to enter the underscore character.)Many word processing programs can only undo the most recent command, but emacs remembers a long history of commands, allowing you to undo many changes by repeatedly entering the Control-_ code.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Editing with viAbout vivi (pronounced vee-EYE, short for "visual") provides basic text editing capabilities. Three aspects of vi make it appealing. First, vi is supplied with all UNIX systems. You can use vi at other universities or any businesses with UNIX systems. Second, vi uses a small amount of memory, which allows efficient operation when the network is busy. Third, because vi uses standard alphanumeric keys for commands, you can use it on virtually any terminal or workstation in existence without having to worry about unusual keyboard mappings. As a point of interest, vi is actually a special mode of another UNIX text editor called ex. Normally you do not need to use ex except in vi mode.Starting viTo start vi, enter:
Command Mode and Input Modevi has two modes, command mode and input mode. In command mode, characters you type perform actions like moving the cursor, cutting or copying text, or searching for some particular text. In input mode, you type to insert or overwrite text. When you start vi, it is in command mode.To switch from command to input mode, press the "i" key (you do not need to press RETURN). vi lets you insert text beginning at the current cursor location. To switch back to command mode, press ESC. You can also use ESC to cancel an unfinished command in command mode. Unfortunately, vi does not normally indicate which mode you are in. The next exercise turns on a mode indicator. If you are uncertain about the current mode, you can press ESC a few times. When vi beeps, you have returned to command mode. TABLE 1.Cursor Movement Commands
TABLE 2.Common Command Mode Functions
TABLE 3.Common ex Mode Functions
Changing file contextTyping these commands puts you into insert or edit mode. You see the text change. To go back to command mode remember to hit esc when done editing the text.TABLE 3.Common ex Mode Functions
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Batch Editors - sed, awkSed is a batch file editor. Sed stands for Stream oriented editor. It reads a file and a script of editing commands and produces it's output on stdout. Sed is very cryptic and hard to use. However it's worth knowing the basics of it's use, as it is an invaluable tool for editing files without user interaction, such as in a shell script. Your Nutshell book details the programs, so I will only give them topical treatment here.Awk is a pattern matching program. I think awk stands for the initials of it's creators, not the awkward program as I used to call it. Awk is also a cryptic batch program like sed, but it excells at pattern matching and processing based on the patterns. Like sed it reads a file and a script of commands and produces it's output on stdout. Awk is an incredably powerful program and it supports a full programming environment with loops, arithmetic and string operations. Awk is often used to populate databases. Both these programs use has been eclipsed by the Perl language. It's no coincidence that all of the capabilities of these two programs are fully embedded into Perl. I still use both sed and awk in shell programs.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Text processing commandsThese are the essential text editing commands.Command text editing
Interactive text editing
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
4 - The shell |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Shell overviewThe shell is an intermediary. It sits between your program and the kernel, and provides a environment for your program. In this section we will learn how to work with the interactive shell (at your terminal prompt), and program in the shell.There are several shell available on most unix systems. Here is a quick rundown on them.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Interactive Use of the ShellThis section discusses tips and tricks to make your use of the shell more efficient.File name completionBoth csh and tcsh will perform file name completion for you. You can type in a partial file name, and press the ESCAPE key for csh, or the TAB key for tcsh. The shell will then complete the name of the file for you. If no file exists that begins with the characters you typed, the shell will beep at you, and will not complete the name. If more than one file begins with the characters you typed, the shell will complete the name up to the point where the names differ. Then you can type additional letters to specify the file name you want, reusing the ESCAPE key if desired.To enable file completion the following variable is set: set filec Command name aliasingBoth csh and tcsh provide command name aliasing, to allow you to rename commands. Aliasing can save a lot of keystrokes if you must frequently issue the same lengthy command. The alias command requires two pieces of information: The command you wish to alias, and the alias you wish to use to refer to it.EXAMPLE: To alias the "history" command to "hi" you could use the following command in the csh or tcsh shell
EXPLANATION: The command
Command aliasing can be tricky. Surround the alias string with single quotes (') to prevent the shell from interpreting special characters. If you use command history substitution in an alias, use the backslash character (\) to escape characters that you don't want the shell to interpret. EXAMPLE: This example, written for the C shell, creates an alias for the cd command, so that it stores the current location in a shell variable called old before it changes to the new location. It also creates a new command alias called back that allows us to go back to the previous location:
alias back 'set dirvar=$old; cd $dirvar; unset dirvar' The alias for back also has three parts: The first part reads the previous location from the shell variable old, and stores it in a shell variable called dirvar. That is necessary because the new cd alias will change the value of old when we call it in the second part of the back alias. The third part cleans up our mess by unsetting the variable dirvar, removing it from the environment. You can remove an alias using the unalias command. To remove the "clean" alias you created in a previous exercise, enter the command:
Command history substitutionThe C shell and TC shell will keep an ordered list of the commands you have issued, and allow you to retrieve commands from the list. That facility, called command history substitution, makes it possible to reuse all or part of your previously issued commands. Each command on the list is given a command number, according to the order it was issued. You can view the command history list by issuing the command:
csh, and tcsh
To recall previous commands from the history list, the C shell uses the exclamation point (!) character, sometimes referred to in computer jargon as "bang." The bang character can be used in combination with history line numbers, and text patterns. Here are some examples of how to use history substitution in the C shell:
more !10:$ |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Customizing the UNIX ShellTable comparing shell features
Choosing your shellIt is possible to invoke any available shell from within another shell. To start a new shell, you can simply type the name of the shell you want to run, tcsh, csh, or sh.It is also possible to set the default startup shell for all your future sessions. The default shell for your account is stored in the system database /etc/passwd, along with the other information about your account. To change your default shell, use the chsh command The chsh command requires one argument, the name of the shell you want as your default. To change your default shell to the C shell, you could enter the command
Default file access permissionsWhenever you create a file or directory in a UNIX filesystem, the newly created file or directory is stamped with a default set of permissions. That default set of permissions is stored in a variable called the umask. You can change the value of umask to suit your preferences. To see the current value of the umask variable, enter the shell command:
To set your umask to deny write permission to group and others, use the command
Customizing with user login scriptsBelow is an example login script, .login from an IRIX system.# user login file for IRIX
if (! $?ENVONLY) then
# Set the TERM environment variable
# Set the default X server.
Customizing with Csh Resource fileThe resource file is the .cshrc file. Below is a example one from an IRIX system.# .cshrc file for IRIX (SGI)
# list directories in columns
# Remember last 100 commands
# For interactive shells, set the prompt to show the host name and
event number.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Shell ProgrammingWhats a shell program?So far we've mostly been refering to interactive shells that are attached to a terminal. All the shell features, job control, environment variables are available along with programming control statements in a batch environment. So what is a shell program? It's simply a text file containing commands that are either unix programs (like grep) and shell directives (like SETENV). The special thing that makes the file recognized by the kernel is the first line, which looks like: #!/bin/csh . Lets talk about this special character set #!.The magic #!This is a really powerfull function of the Unix operating system and is worth explaining at this point. If the execute bits are set on a file (--x--x--x) then if you type the file name in a shell the shell will pass the filename to the kernel to execute. The kernel will then interpet the file to see what it is. It can be one of two things, a compiled binary file (a C program for example), or a plain text file. If it's a plain text file, the kernel opens a child process for it and hands it to either a Bourne shell, if no #! record is found, or it replaces the child process with the program listed on the #! statement.So in the case of the C shell script, the kernel starts a csh because of the #!/bin/csh directive. It also passes the contents of the line after the #! as arguments. The C shell reads them, (cause it's written that way) and excutes the subsequent lines in the file as if you were typing them at a terminal. Don't fall asleep now! Think about this for a minute. There's nothing magic about the C shell. It's just a C program someone wrote. You could write your own program that reads some special form of input and run it the same way. Cool! Example: I create my own plotting program (plot_vector).
#! /home2/ejensen/bin/plot_vector
Would run the program and plot a nice square for me.
C shell ConstructsRather than repeat the Nutshell book here, I will simply show a couple examples of C shell scripts for discussion.Example 1: Recursively update .cshrc files in peoples directories
Example 2: Archive a bunch of users home accounts, based on a list input #!/bin/csh
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
5 - Unix Processes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
How they work - fork and execfork and exec are system calls (program calls that request services from the kernel) that create new processes.A quick overview is needed at this point. When you are typing at the
prompt, you are in a shell. When you enter a command, the shell forks itself (creates, "spawns" a duplicate), and the new shell execs (replaces itself) with whatever program you asked it to run. When
that command terminates that shell dies. This is how every program on a Unix system runs.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Interaction and Job ControlWhen you log in to a UNIX system, the kernel starts a shell for you, and connects the shell to your terminal. When you execute a command from the shell, the shell creates a child process to execute the command, and connects the child process to your terminal. By connecting the child process to your terminal, the shell allows you to send input to the child process, and receive output from it. When the child process finishes, the shell regains access to the terminal, redisplays the shell prompt, and waits for your next command.Any task that requires you to actively participate (like word processing) must be in the foreground to run. Such jobs, termed "interactive," must periodically update the display, and accept input from you, and so require access to the terminal interface. Other jobs do not require you to participate once they are started. For example, a job that sorts the contents of one file and places the results in another file, would not have to accept user commands, or write information to the screen while it runs. Some UNIX shells allow such noninteractive jobs to be disconnected from the terminal, freeing the terminal for interactive use. Note that it is even possible to log out, and leave a background process running. Unfortunately, there is no way to reconnect a background job to the terminal after you've logged out. Jobs that are disconnected from the terminal for input and output are called "background" jobs. You can have a large number of background jobs running at the same time, but you can only have one foreground job. That is because you only have one screen, and one keyboard at your terminal. Background and foreground jobsThe process that is connected to the terminal is called the foreground job. A job is said to be in the foreground because it can communicate with the user via the screen, and the keyboard.A UNIX process can be disconnected from the terminal, and allowed to run in the background. Because background jobs are not connected to a terminal, they cannot communicate with the user. If the background job requires interaction with the user, it will stop, and wait to be reconnected to the terminal. Jobs that do not require interaction from the user as they run(like sorting a large file) can be placed in the background, allowing the user to access the terminal, and continue to work, instead of waiting for a long job to finish. Starting a job in the backgroundTo place a job in the background, simply add the ampersand character (&) to the end of your shell command.EXAMPLE: To sort a file called "tempfile", and place the results in a file called "bar", you could issue the command
Examining your jobsThe UNIX command jobs allows you to see a list of all the jobs you have invoked from the current shell. The shell will list the job ID of each job, along with the status (running, stopped, or otherwise), and the command that started the job. The shell considers the most recently-created (or most recently-manipulated) job to be the current job, marked with a plus sign. Other jobs are referred to as previous jobs, and are marked with a minus sign. The commands related to job control will apply to the current job, unless directed to do otherwise. You may refer to jobs by job ID by using the percent sign. Thus, job 1 is referred to as %1, job 2 is %2, and so forth.Suspending the foreground jobYou can (usually) tell UNIX to suspend the job that is currently connected to your terminal by typing Control-Z (hold the control key down, and type the letter z). The shell will inform you that the process has been suspended, and it will assign the suspended job a job ID.There is a big difference between a suspended job, and a job running in the background. A suspended job is stopped, and no processing will take place for that job until you run it, either in the foreground, or in the background. Placing a foreground job into the backgroundIf you started a job in the foreground, and would like to place it in the background, the first thing you must do is suspend the job with a Control-Z, freeing your terminal. Then, you can issue the UNIX command
Bringing a background job to the foregroundYou can reconnect a background job to your terminal with the UNIX command
Starting a suspended jobIf you have a suspended job that you'd like to resume running, first you must decide whether you want it running in the foreground, or the background. Find the job ID of the suspended job with the jobs command, and then use bg (to run the job in the background), or fg (to run the job in the foreground).EXAMPLE:Start several jobs running in the background by entering the following:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Tracking and managing processesEvery process on the system is identifiable, and can be managed with the ps and kill commands.psThe ps or Process Status command queries the system for a list of proccess that exist on it at a givven moment. It has many flags which tailor it's output. This is one of the few Unix commands that varies in implementation form the BSD and SysV Unix derivatives. Check the Man page to be sure of the options available. Below is a fragment of a process list made on an SGI system using the ps -ef command. UID PID PPID C STIME TTY TIME CMD
-+- 00001 root /etc/init
Do you see the parent/child relationship here? What do think the
"defunct" process is?
killNow that we can identify processes on the system, we can send them a signal if need be with the kill command.So in the previous example:
If I issue the command kill -9 3022 my telnet session is abruptly canceled. Now if you've used Unix at all you've probably seen this command , and used it yourself to get out of a tight spot. But what's really happening here? I you review the man page for kill you will discover that it sends a signal to the process. Signals are a communications mechanisim that allow two seperate processes that exist in their own private address space to send messages to each other. The kernel is the broker for these signals and programs use system calls to send and catch these signals. So in the telnet example: I used the kill command, which is a general purpose signal sender, to send the -9 or SIGKILL, to the telnet process 3022. The telnet program was written to listen for signals and respond to certain ones in certain ways. It recieved the SIGKILL signal from me and honored it by aborting ungracefully right away. This is a "brute force" last resort type of use of the kill command. But there are many other signals available to send to a process, and many Unix programs are written to respond to these signals. Table of signal values (from signal(5) man page)
Lots of programs use these signals behind the scenes to work
efficiently. Example - printing. A program runs all the time in the
background named lpd. Lpd listens for print requests and manages a queue and spools the
jobs to the printer. Now it would be very inefficient to have lpd
activly scanning the print queue for a print job, so lpd is written to
sleep and do nothing until it gets woken up by, in older Unix systems,
a signal sent from the lpr command. Actually in newer Unixes, programs like this use
sockets, another form of interprocess communication to do the job.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
5 - X windows |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Why Use a Graphical User Interface (GUI)?Before we study X Windows in detail it is worth considering why we need GUIs.GUIs provide an easy means of data entry and modification. They should provides an attractive and easy to use interface between human and machine. So easy in fact that a non-computer literate person could use the system. GUIs provide a better means of communication than cumbersome text-based interfaces. How do GUIs provide such facilities? By means of:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X Window System - BackgroundDeveloped at the Massachusetts Institute of Technology in 1984, X provides a graphics- window system for computer networks. Every computer network requires a system that will allow users to communicate with it. X provides such a system and employs graphics windows as its foundation. Each graphics window represents a particular application, such as a text editor, a debugger, an electronic mail manager, or a terminal emulator. X lets you open multiple windows and run several applications simultaneously.The activity within one window executes independently of the activity in the other windows. For example, you can compile a FORTRAN program in one window, read electronic mail in another, run a clock in a third, and run a text editing program in a fourth window. This feature makes X very powerful because you can access many different applications--- even different computers---from a single terminal; you simply open new windows as needed. First, and foremost, however, X is a windowing system, not a complete operating system. Unix is an operating system. X mediates the communication between individuals and a computer network. X creates windows that represent applications, but does not execute the applications itself. In the current Information Systems configuration, applications most often run on computers separate from an individual's computer terminal. You can tailor X to suit your needs. For example, you can tell X to run certain applications automatically each time you start an X session. That saves you the trouble of starting them manually every time you log in. The first popular and widely circulated release of X was X11R4. Many X window systems shipped by Unix vendors are based on X11R5. The current Open Group X11 Release is X11R6.3. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X Window System - The BasicsAs you can guess, the X Window System is a graphical user interface (GUI). The impressive thing about X is that it's network-extensible. This means that you don't have to sit in front of a computer's physically connected console to enjoy the GUI features (as is usually the case). X can be (and often is) run over the network to a remote computer's console (provided that the remote computer is also running X). The remote computer can be situated down the hall from you or across the world; to X it makes no difference.Although X window system is used most frequently on Unix workstations, it can be used on almost any computer. X servers are now commonly available for Windows and the Mac environment. Just as there are different "flavors" of Unix there are different X-like systems. These are vendor specific window systems that are based on MIT's X11, which is the original X. These systems have been configured by the vendor to work with a particular Unix "flavor". Each of these has a unique look and feel. The two major X variants are Motif and OPEN LOOK. OpenWindows, a graphical user environment based on the OPEN LOOK specification, is part of Sun's Solaris system. Almost everyone else uses a system based on Motif. However, since even Solaris now comes with the Common Desktop Environment (which is based on Motif), it appears that Motif may ultimately emerge as the victor. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
The X ProtocolX is a client-server protocol and it is the protocol which sets the standard for X. This protocol pertains to the way the client and the server communicate with each other at a low level. It has no effect on the way X will look on a terminal screen. This means that a number of user interfaces that all look different can still be called X. The look is determined by which utilities (called widgets and toolkits) a programmer used to develop the interface. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X is Client-ServerHowever, the manner in which the terms client and server are used is a bit skewed in X. We will explore this more fully in the next section. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Window ManagerEvery X system uses a window manager. The window manager gives each window a title bar, border and makes it possible to resize, move and iconify windows. There are several window managers. The most common are the Tab Window Manager ( twm) from MIT, OPEN LOOK Window Manager (olwm) from UNIX International, Motif Window Manager (mwm) from the Open Software Foundation, and fvwm from FSF(?).A window manager is an application program and not part of the window system. This means that the Motif Window Manager can be used with OPEN LOOK, etc. A single X server can provide access to several different window mangers. Generally a window manager is initiated as part of a user's startup script as is the X system. However, both can be be started from the command line. The startup script is what pulls together all the elements that comprise a user's X environment. The startup script for X includes initialization files, resource files and startup files for the window manager. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Startup ScriptsThe startup script is known either as $HOME/.xsession when xdm, the X Display Manager, is used to begin an X session or as $HOME/.xinitrc if xinit, the X Window System initializer, is used. Although there are some differences between the scripts, the conventions for configuring them are the same. For the rest of this module xinit and .xinitrc will be used as examples.The first thing xinit does is to find the initialization file .xinitrc and execute the commands found in it. It is the commands in this file that determine what programs will be started every time X starts. xinit terminates when the last command in .xinitrc has been executed. So the command to start the window manager is generally the last command in the file. Resources are the variables used by a specific X client. They are read from the .xresources, by the xrdb program, as part of the startup script. The .xresources file contains information on the configuration of various X applications such as the size of windows, text fonts and color selection. The startup files for the window manager are where the manager can be modified to suit the specific needs of a user. These preferences are stored in the initialization files for the window manager. In these files a user can create personalized menus to specify such things as what pressing each of the mouse buttons will do. All window managers have a file that holds the standard menus. If no special menus exist the window manager will use the standard menus. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Common X Clients (Programs)Common X programs include; xcalc, xclock, xwininfo and xterm. The first two are self explanatory, being a calculator and a clock. xwininfo brings up a "Window Information" window that displays information such as height, width and depth for any window the user selects with the mouse.The xterm program is a terminal emulator. It presents the user with a window that functions as a pseudo-terminal. This means that each xterm window can have a different program or programs running in it. When a window is created it is controlled by the shell specified in the SHELL environmental variable. Unix commands can be entered in this shell as can commands to call up other X clients. On SGI and HP workstations, the window environment is the first screen the user sees once the system is up. On Sun workstations xinit or openwin must be used to call up the OPEN LOOK environment, unless the system is running Solaris and CDE has been installed.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X Window System - Setting the DisplayThe X window system has a special environment variable called DISPLAY (or its command line equivalent -display) which is used to tell a host (or a specific X client) the name of the host whose display to use.Let us consider the following example: Hosts foo.indiana.edu and bar.indiana.edu are connected via a TCP/IP network and have the X environment installed. You are sitting in front of bar's console. You can telnet to foo and set the DISPLAY environment variable like this:
foo% export DISPLAY or foo% setenv DISPLAY bar.indiana.edu:0 (for csh style shells)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X Window System FilesWhere the X window system files reside on disk depends on the vendor and the user environment. However, in a generic X environment, the X filesystem structure looks something like this (exceptions for various OSes are noted in parentheses):~/.twmrc
The configuration file for the twm window manager.
Example.
~/.xinitrc
Initialization file for xinit. Used to start each
application in the user's startup environment.
Example.
~/.Xresources or ~/.Xdefaults
A file containing resource definition (preferences) for X clients.
Example. These resouces can be used
either instead of or in concert with the default resources.
~/.xsession
A shell script which is used to start each application in the
user's startup environment if the the X session is started
using xdm. Example.
/usr/bin/X11 (/usr/X11R6/bin in Linux, /usr/openwin/bin in SunOS/Solaris)
Directory containing X binaries which include the X server(s),
window managers, clients, and utilities.
/usr/include/X11 (/usr/X11R6/include in Linux, /usr/openwin/include in SunOS/Solaris)
Directory containing the X header files necessary for compiling
X programs.
/usr/lib/X11 (/usr/X11R6/lib/X11 in Linux, /usr/openwin/lib in SunOS/Solaris)
Directory containing system startup files, fonts, locale
information, application defaults, etc. Details follow.
/usr/lib/X11/app-defaults
Directory containing application defaults for X clients such as
xterm, etc. Example.
/usr/lib/X11/config
Directory containing site and OS specific configuration files.
This info is needed to compile X programs.
/usr/lib/X11/fonts
Directory containing fonts used by X.
/usr/lib/X11/twm
Directory containing the systemwide startup file for twm.
/usr/lib/X11/xdm
Directory containing systemwide startup files for xdm.
/usr/lib/X11/xinit
Directory containing systemwide startup files for xinit.
In addition, various X11 libraries go in /usr/lib (/usr/X11R6/lib/X11 in Linux).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Environment Specifics:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X Window System - Is it a Client or a Server?Noone really knows why (perhaps the X11 project started before the preponderance of what we now call the client-server environment?) but X uses a client-server paradigm which is diametrically opposite to what one would expect. Since this may be a bit confusing, we will elaborate.In modern client-server world, a client is usually a small program which runs on your desktop. It connects over the network to a remote server (which is a program running on a more substantial box somewhere) and sends commands which the server understands. These commands make the server do something and return results back to the client. The X server, on the other hand, runs on your desktop. An X client may be running locally (such as an xterm running from your hard disk) or running on a remote machine. If it is running on a remote machine and displaying on your desktop, the remote machine is connected using the X protocol to the X server running on your desktop. The X server understands the X requests coming from the remote machine to display the remote xterm. Read the previous two paragraphs repeatedly until this issue is completely clear.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X-Windows System - Window ManagersTo enable window operations, X runs a client called a window manager. The window manager handles operations like moving, resizing, and iconifying windows. The window manager handles the appearance and manipulation of windows while X supervises communication between windows, applications, and input/output devices (like the monitor/keyboard).Without a window manager, windows still display but you cannot move or resize them. Also, if one window happens to lay on top of another, you cannot access the second window. The window manager is a special client of the X server. It is the only client with the ability to move, resize, map, unmap, iconify, and deiconify windows. The window manager normally has no windows itself, with the exception of the menu windows the user can summon. It is possible to run an X session without using a window manager, but parts of windows hidden under other windows would be inaccessible. Several different window managers exist, and each user can choose his or her own window manager. However, you can only use one window manager at a time. For example, suppose there are two window managers available: the Tab and Motif Window Managers. When you log on, you may use either the Tab or the Motif Window Manager, but not both. Here are the default window managers under various Unixes:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Window Managers - twmtwm, which stands for Tab Window Manager or Tom's Window Manager (because it was written by Tom LaStrange), is probably the oldest window manager still in use. It provides the basic, no-frills window management functionality and, like most window managers, is highly customizable. Here is a screenshot.twm comes bundled with most Unixes we will be considering in this class. A newer, enchanced version of twm called tvtwm has also been released. It adds virtual windowing capabilities to the base twm. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Starting twmThough it is usually started by the systemwide xinitrc or xsession (or a user's .xinitrc or .xsession), twm can also be started on the command line by simply typing twm while the X server is up and running and no other window manager is currently managing the desktop.When twm fires up, it reads any user customizations in $HOME/.twmrc and, if the file cannot be found, twm uses the systemwide twm startup file (which usually resides in /usr/lib/X11/twm/system.twmrc). If neither of these files is found, twm uses builtin defaults. Here is an example twmrc. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using twmPopup Windows: When you open a new window, it will pop up on the screen. It will appear as an outline and will follow the pointer. This means that the window is waiting for the user to position it. By pressing any mouse button the window will be placed at it's current location. The left mouse button will keep the window at it's default size. The right button may allow the window to fill from it's current position to the bottom of the screen.Scroll Bars: Most scroll bars perform according to the following:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Window Managers - olwmolwm is the OPEN LOOK window manager from Sun and has Sun's OPEN LOOK look and feel. It is part of Sun's OpenWindows graphical user environment. Here is a screenshot.Note that though olwm is part of Sun's OpenWindows environment, it can be used on other platforms as well (the only requirement is that the OPEN LOOK glyph and cursor fonts are available to the X server). In particular, the Linux distributions often come with olwm (if they have the xview package installed). You might also want to read the olwm man page. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Starting olwmOn Suns, olwm is usually started by /usr/openwin/lib/Xinitrc. However, it can also be started by just typing olwm at the Unix prompt. It reads $HOME/.openwin-menu upon startup or, if this file cannot be found, /usr/openwin/lib/openwin-menu to set up olwm defaults. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using olwmPointer Shapes: The mouse cursor, called the Pointer, indicates the kind of operation you are currently using. In OPEN LOOK, the pointer is an arrow. There are other pointer shapes to give you current information, like a watch cursor when a process is busy, or a question mark when a selection isn't appropriate for that situation.Mouse Buttons: You can use either the standard three-button mouse or an optional two-button mouse or optional trackball. The three mouse buttons behave differently; but their operation is usually just a simple click (a single press and release), a double click (two clicks in rapid succession), or click and drag (pressing a button and holding it down while you move the mouse pointer). Different operations are selected by the left, middle, and right mouse buttons. If you have a two-button mouse, the middle button operations are selected by pressing both buttons at the same time. (The actual configuration of the mouse buttons, such as swapping left and right buttons, can be modified by the xmodmap utility.) OPEN LOOK has made some default assignments for the mouse buttons. The three button mouse has these assignments for its buttons:
Middle - ADJUST - this extends or reduces the number of selected objects Right - MENU - this displays and chooses menus Selecting Focus: The OPEN LOOK Window Manager can give focus to a window in two ways - either by placing the pointer in the window and clicking on it (this is the default choice), or by simply moving the pointer into the window. There is a configuration selection (called a resource) that selects this mode of operation. If you point and click to give a window focus, that window retains focus regardless of where the mouse pointer is located. Many people prefer this type of operation because they can work in one window and ignore the mouse position. Others prefer to be able to get window focus by moving the mouse only, without the need to click when they are in the window. This is a significant difference in the way a user controls the screen. The operation of the window manager controls this function and many other significant operations depending on its configuration. These questions of configuration are important and are discussed at the end of this chapter. Window Decoration: The border around the window, called its decoration, has areas marked that permit easy manipulation of the window. These are labeled below, along with brief descriptions of their operations.
Resize corner - These are the handles to resize the window. Iconify button - This button reduces the window to an icon. Resizing a Window: You can change a window's size to make your work easier. Imagine that the window has elastic sides. By grabbing a corner (point the mouse on a corner and press the left button and hold it down), you can stretch the window to a larger size or let it contract to a smaller size. Dragging the lower left corner stretches the left and bottom sides (with the upper right corner remaining fixed). Try resizing a window - it's easier to learn by doing than by reading. Iconifying and Deiconifying a Window: You can gain space on your screen by changing a window into an icon. The window will continue to function if it has a process running, but it is temporarily hidden from view. To iconify a window, simply move the pointer to the Iconify button and click on it. The window changes to an icon and moves to a row of icons, usually at the bottom of the root window. You can move the icons (they are windows), or define a different place for the icon row. The icon itself has an image and a label so you can distinguish them from each other. To deiconify an icon, move the mouse pointer to it and double click. The window will be restored to its original size and location on the screen. Exiting olwm: You can exit the OPEN LOOK Window Manager by selecting the "Exit WM" line in the menu. Clicking on the last line "Exit" closes all of your windows and connections.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Window Managers - mwmmwm is the Motif window manager. It is based on the second proprietary interface (the first being Sun's OPEN LOOK) and defines a generic look and feel which is slowly becoming an industry standard. It was developed by Ellis Cohen of the Open Software Foundation. Here is a screenshot.mwm attempts to create a three-dimensional appearance which is somewhat most aesthetic than that provided by many other window managers. Because it is licensed software, mwm tends not to be bundled unless the Unix vendor has licensed it from Open Group (OSF's new name). You will find mwm by default under IRIX and HP-UX but not under SunOS/Solaris and Linux (where they need to be purchased separately). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Starting mwmAs with other window managers, mwm can either be started from the standard startup files (.xinitrc or .xsession) or by typing
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using mwmSelecting Focus: Again, you select the window to receive input by moving the pointer anywhere in that window. When you focus input on a window, it changes color. Also, when you are working with a stack of windows that overlap, selecting a window as the active window automatically raises that window.Moving a Window: a) Place the pointer in the titlebar (the titlebar is the area of the window at the top which says "xterm" in the screenshot). The pointer changes to an arror cursor. b) Press and hold the left mouse button. c) Move the window by dragging the mouse. While dragging the pointer changes to a cross arrow and a window outline which tracks the movement of the window appears. In the center of the screen, a small box also appears with the x and the y coordinates of the window as you move it. d) Drag the cross arrow pointer with the window outline to the desired location. e) Release the left mouse button. Minimizing and Maximizing a Window: There are two buttons at the top right corner of the titlebar. On the left is the minimize button (a little square with a dot in the middle); on the right is the maximize button (a square with a smaller square in it). To minimize a window, click on the minimize button at the top right. This will iconify the window on the desktop. To maximize it, click on the maximize button. This will make the window as big as it can be (which can be the size of the entire screen for many windows). Resizing a Window: The entire frame of a window under mwm control is available for resizing. (This is a feature not available in many other window managers.) You can click on any part of the frame with the left mouse button where the pointer changes to an arrow pointing toward the window border and drag the mouse to resize the window. The Windows Menu: Clicking the left mouse button the top left corner of the titlebar (in the area which looks like a small square with a - sign in it) brings up the window menu. Using this menu, you can restore, move, size, minimize, maximize, lower, or close the window. Note that all of these actions can also be performed using ALT + function key keystrokes. Moving a Window: The easiest way to move a window is to place the pointer on the title bar, then click the left mouse button and to drag the mouse to the desired location. Working with mwm Menus: Clicking the left mouse button on an empty part of the screen will bring up the root menu. This menu can be customized by editing the ~/.mwmrc file.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Window Managers - fvwmfvwm, written by Robert Nation, is a relative newcomer in the X world. However, due to its speed, efficient use of memory, and customizability, it is currently probably the most ubiquitous of the virtual window managers. fvwm was derived from twm.fvwm was designed to be infinitely customizable (to the extent that there exists fvwm95, a Windows 95 lookalike), even as far as the look and feel is concerned. For example, you can customize it to look like twm or like mwm! Here is a screenshot of a fvwm managed desktop created using this .fvwmrc. Another very attractive feature of fvwm is its use of add-on modules. Modules can be loaded dynamically and can be used to extend fvwm's capabilities beyond most other window managers. You can get more information about fvwm at the official fvwm home page. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Starting fvwmfvwm can be started in the usual manner from a user's startup file ( .xinitrc or .xsession) or by typing its name at the command prompt:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Configuring fvwmHere is an excellent resource on configuring fvwm version 1 (version 2 is the most recent one).
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
xdm, the X Display Managerxdm is a special X client which is designed to to start the X server automatically (from the Unix /etc/rc* system startup file) and to keep it running. (X can also be started manually via xinit as we have seen before.) If xdm is running, you will most likely see a graphical login screen (for example, in HP-UX and IRIX).In its most basic implementation, xdm emulates the function of getty and login programs. It puts up a graphical login prompt and manages the login session. Once a user logs in, xdm reads the user's ~/.xsession and fires up the X applications defined in it. When the user logs out, xdm makes sure that all user processes have ended and puts up the login screen again for the next user to log in. However, xdm can be used in a more powerful way. Users can design their own sessions, running several clients and setting personal resources (such as keyboard, pointer, and display characteristics). Special xdm files can also be customized to manage several connected display (both local and remote) and to set system-wide X resouces (for example, client default features). |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
XDMCPXDMCP stands for "X Display Manager Control Protocol". It is a mechanism supported by xdm which allows an Xterminal to request a session from a remote host. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
xdm filesreside in /usr/lib/X11/xdm and include:Xsession the systemwide file which tells xdm which X apps to start
if ~/.xsession doesn't exist
xdm-config Configuration parameters for xdm.
xdm-errors Contains xdm errors.
Xaccess Defines access control for XDMCP connections.
Xlogin Contains commands which initialize the login screen and
provides hooks for alternative login programs.
Xreset Run after the server is reset, but before the Login
window is offered.
Xresources A list of resources to be loaded onto the display
using xrdb. As the authentication widget reads this database
before starting up, it usually contains parameters for
xlogin.
Xservers Contains a list of displays to manage.
Xstartup Prevents logins while /etc/nologin exists.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
X User EnvironmentsNow that we have seen a number of popular X window managers, we can discuss a number of complete user environments. All of these except the Sun OpenWindows are based on the Motif user interface. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Common X ClientsWhile there are a large number of X clients in use today, a few still top the list as basic ones used most of the time by users. This list includes:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Common X Clients - xtermxterm is perhaps the most important and the most often used X client of all. It provides VT100 and Tektronix terminal emulation in the X environment.For detailed info on xterm, please read the man page. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Starting xtermThe simplest way to start xterm is to just type its name at the command prompt:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Copying and Pasting TextYou can copy text from one xterm window and paste it into another xterm or X client. To copy text, you place the cursor where you want the selection to start and hold down the left mouse button. Now drag the cursor to highlight and select text. When you release the left mouse button, the text stays highlighted and is copied into a buffer (hitting any key will unhighlight the text but it will still remain in the buffer). You can now move the cursor to another xterm window and click on the middle mouse button to paste the selection.Double clicking the left mouse button on a word selects the whole word. Triple clicking selects the entire line you are on. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using xterm MenusMenu 1 - Main OptionsIf you are in an xterm and hit CTRL + left mouse button, you get this menu. It allows you to set certain modes and to send signal that affect the xterm process.Here are the choices with explanations:
Menu 2 - VT OptionsIf you are in an xterm and hit CTRL + middle mouse button, you get this menu. It provides VT102 setup functions. Most are analagous to a real VT102 (the exception is scrollbar).
Menu 3 - VT Fonts (Changing Fonts Dynamically)xterm allows you to select a few fonts dynamically. The font in the current xterm window may be changed by pressing the CTRL key and the right mouse button simultaneously. This will bring up a menu. Still holding the right button select the font desired. Release the button and the font in the xterm will change.The VT Fonts menu items are:
/usr/lib/X11/fonts/misc (IRIX, HP-UX) /usr/X11R6/lib/X11/fonts/misc (Linux)
/usr/lib/X11/app-defaults/XTerm (IRIX, HP-UX) /usr/X11R6/lib/X11/app-defaults/XTerm (Linux) You can change the default font setting by defining resources font1-font6 in your ~/.Xresources file like this:
XTerm*VT100*font2: 5x8 XTerm*VT100*font3: 5x9 XTerm*VT100*font4: 8x13 XTerm*VT100*font5: 9x15 XTerm*VT100*font6: 10x20 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Using the Tektronix WindowIf you have an application which makes use of a Tektronix terminal and which switches to Tektronix mode correctly, xterm will fire up the Tektronix window.Under the Tektronix window, a CTRL + middle mouse button gets you the Tek Options menu.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Fixing xterm after a ResizeHow xterm is resized depends on the window manager running. If xterm seems to act strangely after resizing, issue the command
or eval `/usr/bin/X11/resize` (c shell) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
xterm and Terminal EmulationShell startup script such as .login and .profile often deal with setting terminal type for that shell. This usually involves setting the TERM environment variable and/or running tset. Setting the terminal type is not required for xterm windows since it has its own way of dealing with terminal types. Several entries in termcap or terminfo such as "xterm", "vt100", "vt102", and "ansi" work with standard size (80x24) xterm windows. The xterm client automatically searches the terminal database for these entries (in order) and sets the TERM environment variable according to which entry it finds first.In light of this, you may want to remove any lines in the startup files which set the terminal type (or set it to "xterm"). Also, your vendor may supply its own version of terminal emulator which may or may not be based on xterm. Examples are hpterm, dxterm, aixterm, etc. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
xterm and the Login ShellIf csh is your default shell, you may know that .cshrc is read for every csh command run, and that the .login file is read only once, at the beginning of each "login" shell.X effectively redefines the meaning of the "login" shell. Since X enables the ability to run multiple windows, the usage of .login becomes confused. (You probably don't want to be told that you have new mail and see the message of the day every time you open a new xterm.) So by default, xterm shells are not login shells so .login is not read when you open an xterm (however, it still reads .cshrc). (You can still call a login shell in an xterm by giving it the -ls option or by setting the resource XTerm*login-Shell to true.) The .cshrc file therefore has to assume more responsibility in the X environment. For example, you have to make sure that you are doing the following in your .cshrc:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Exercise 1Log into your workstation.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Exercise 2This assumes that you are still logged in on your workstation and that the X server is running.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
5 - Other Unix topics, Mail, utilities, ..... |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
Mail IssuesMail is a important and relatively complex issue which I will only deal with nominally here. I've compiled a list of issues related to Pine, the email client of choice at Smith, mostly explaining how to deal with attachments and other types of computers.One important detail to get about mail. E-mail, no matter whose
computer you use, has to abide by certain conventions and standards
that allow it to pass along through the various relays along the
internet and make it to the intented client intact. The two standards
most of interest to us are SMTP and MIME.
What is the Simple Mail Transfer Protocol (SMTP)?The Simple Mail Transfer Protocol, or SMTP, is the de facto standard for electronic mail transport across the Internet. When you send an e-mail message, SMTP packages your message in a kind of envelope and relays it to its destination. Multiple servers are often involved in the transport of the message, and as it passes through them, each one timestamps and tags it. Thus, when the message arrives, the recipient can get an idea of where it's been, and when it was sent. SMTP also handles error messages, sending notifications to senders when there is difficulty delivering their mail.When you set up a POP or IMAP client, such as Eudora, Netscape, or Outlook Express, you must specify an SMTP server. This is for your outgoing mail and may be different from the server you use to check incoming mail. The Simple Mail Transport Protocol was introduced in a series of RFCs, notably 772, 780, and 788, with the current base specification appearing in 1982's RFC 821: http://info.internet.isi.edu:80/in-notes/rfc/files/rfc821.txtWork continues on SMTP, however, and over the years its capabilities have been significantly enhanced. Modern programs that implement SMTP, such as sendmail, are based on these Extended SMTP (ESMTP) standards. Important RFCs that cover extensions or otherwise discuss SMTP include:
http://info.internet.isi.edu:80/in-notes/rfc/files/rfc974.txt http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1123.txt http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1869.txt http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1870.txt What is MIME?MIME, the Multi-purpose Internet Mail Extensions, is a freely available specification that offers a way to interchange text in languages with different character sets, and multimedia e-mail among many different computer systems that use Internet mail standards.If you were bored with plain text e-mail messages, thanks to MIME you now can create and read e-mail messages containing these things:
Before MIME became widespread, you might have been able to create a message containing, say, a Postscript document and audio annotations, but more often then not, the message was encoded in a proprietary, non-transportable format. That meant that you couldn't easily handle the same message on another vendor's workstation, or even get it intact through a mail gateway in the first place. Now, depending on the completeness of your MIME-capable mail system, there's a good chance that it'll "just work." (See section 1.2 of the original source FAQ for some warnings on this subject). One of the best things about MIME is that it's a "four-wheel drive
protocol", (to borrow a description applied originally to PhoneNet by
Einar Stefferud). MIME was carefully designed to survive many of the
most bizarre variations of SMTP, UUCP, and other Procrustean mail
transport protocols, such as BITNET and MMDF, that like to slice, dice,
and stretch the headers and bodies of e-mail messages.
In Pine, how do I attach a file to an e-mail message?Encoding the fileThis step isn't necessary if you are sending the file to someone you know is using a MIME compliant mail program (e.g. Pine). You can also skip this section if the file is encoded before you FTP it to your e-mail computer. (For example, Fetch permits you to Binhex a file before transferring it.) Finally, if the file is a text file encoding is not necessary. (Note, word- processed documents are not text files.)
uuencode filename destname > localnameReplace "filename" by the name you gave the attached file when you transferred it; replace "destname" with the name you want the file will have when you have sent it and it's been decoded by the recipient; replace "localname" with the name you want for the new encoded version of file which will be created by this command on your e-mail computer directory. Attaching the file to a mail message in PineIf the recipient is using a MIME compliant mailer (such as Pine), then follow these steps:
If the file is uuencoded, it is a good idea to inform the recipient of this either in the subject line or in the body of the text. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
In Pine, how do I save a file attached to an e-mail message to my hard drive?There are three general steps to transferring an attachment from an e-mail message in Pine to the hard drive on your local computer:
Export the attachment to a file
Copy attachment to file in home directory:Type in the name you want to give the file, press Enter or Return, and Pine will save it to your home directory. Decode the fileAttachments often contain binary data, but the current methods used to transfer e-mail messages only allow the basic ASCII text characters to be transmitted. Several methods have been developed to encode binary data using only ASCII text characters. Also, other encoding methods have been developed that allow you to store information with a smaller number of characters. Attachments that contain binary data will be encoded using one or more of these methods. Once the attachment is extracted to a file, you will probably need to decode this file. Pine, however, knows how to decode two encoding formats, base64 and quoted printable. If the headers on the attachment are properly formatted, then Pine will do the encoding as it is extracting, and the resulting file will already be decoded. You will not need to decode the file if the attachment was unencoded text or was automatically decoded by Pine. Otherwise, you will need to decode the file yourself. Below is a list of common encoding methods (with filename extensions that commonly identify them) and references for instructions for decoding them.Note: Some of these texts give directions for doing the decoding on your local computer. If you choose to use these methods, then you will (obviously) need to transfer the file before decoding. Also, methods other than the ones in the references below are available. Programs are available for decoding all of these encoding formats for the Macintosh and there are programs for IBM-compatible computers that will handle most of these. uuencode (uu, uue)
In Pine, how do I decode a uuencoded mail message I received?A uuencoded file typically contains non-text data (e.g., graphics, programs and word processing files) converted into ASCII text. To uudecode a message with Pine, while you are looking at the message, press the pipe key ("|"). Pine will prompt you for a command. Enter uudecode and then press return or enter. This will decode the message and save it in a file on your home directory. The name of this file will be the last word in the "begin" line of the uuencoded message. So, in the following example, the file will be called myfile.zip:begin 644 myfile.zipYou can then use the file or transfer it to your own computer. In Unix, how do I uuencode a binary file?The uuencode command uses the syntax:uuencode original_filename final_filename > encoded_filenameReplace original_filename with the name of your binary file. Replace final_filename with the name that you want the file to have when it is eventually decoded (usually the same as original_filename). Replace encoded_filename with the name you want to give the uuencoded version of the binary as it will appear in your directory. For example, to convert a binary file named myfile.zip into a uuencoded (text) file named myfile.uue, you would enter at the shell prompt: uuencode myfile.zip myfile.zip > myfile.uueThe original binary file myfile.zip is unchanged, and the uuencoded file myfile.uue is now located in your current directory. The greater-than character (>) is used to redirect output; it takes the output of the uuencode command and directs it into the file myfile.uue (rather than onto your screen). The purpose of the uuencode program is to translate a binary file
that contains unprintable (non-text) characters into a format that is
entirely readable. This prevents mail, news, and terminal programs from
misinterpreting non-text characters as special instructions. A text
file produced by uuencode may thus be mailed as an ordinary mail
message and later uudecoded into its original binary form by the
recipient. The uuencoded file is usually larger than the original
binary file, because the unprintable characters in the binary file are
expanded into multiple readable characters
How do I send a WordPerfect or MS Word file as an e-mail message?Standard e-mail can only handle text (ASCII) files. Most word processors save their files in a non-ASCII format, intended for use only by that word processor. Most word processors also allow files to be saved in ASCII format, but doing so strips out or ignores special formatting and fonts (such as boldfacing, underlining and foreign characters). If you don't mind converting your file into a "plain text" format, then you can use the following method to send a word processed file as an e-mail message:
Many e-mail programs, including Pine and most workstation-based e-mail programs, will automatically MIME encode any non-ASCII file that is included as an attachment. The advantage of encoding is that the file format of your word
processor (including all special fonts, formats and characters) is
preserved. The disadvantage of encoding is that the recipients of your
message might not have the utilities on their computers to decode your
message. Furthermore, they might not use the same word processor as
you, and theirs might not be capable of converting your word
processor's file format. Therefore it is usually safer to cut and paste
the text of your file into the body of your e-mail message.
What is POPmail?"POPmail" refers to e-mail software that is installed on your personal computer which sends and receives mail very quickly from a shared computer's electronic post office. The "POP" in POPmail stands for "post office protocol." Personal computers seldom have the network resources required to serve as an independent post office, which is why most people use shared systems or POPmail for e-mail.POPmail software on your personal computer (the "POP client") quickly logs into a shared computer which is an e-mail post office (a "POP server"), and transfers received mail from your account on that system to your workstation. When you send a message from your workstation, the POP client transfers it to a dedicated mail system for transmission on the Internet. POPmail programs include Eudora for Macintosh, PC-Eudora for Windows, Pegasus for Windows, Explorer, and Netscape. POPmail requires that you have an account on a shared computer system . It is to this account that incoming mail goes first, and this is your "preferred e-mail address." However, instead of making you log in from your workstation to the shared computer (using your workstation as a "dumb" terminal), POPmail programs automatically connect to the POP server only long enough to transfer messages. You use the power of your workstation in your favorite user-friendly environment (Macintosh or Windows) to compose, read, and manage mail. This keeps POPmail fast, even during rush hours on "shared" computers. POPmail programs are also usually rich in features: document attachment, automatic document encoding/decoding, user lookup, internal address books, font selection, signature files, and multiple mail management options. Of course, POPmail has disadvantages too: if you use POPmail on
campus, and dial in to your shared system account to use e-mail from
home, you could end up managing your e-mail in two different places.
Furthermore, if you "pop" your mail to your personal computer without
keeping a copy of it on your shared computer account, you'll need to
back up your e-mail files regularly.
What is IMAP (Internet Message Access Protocol)?IMAP (Internet Message Access Protocol -- formerly known as the Interactive Mail Access Protocol) is a protocol for e-mail clients to retrieve e-mail messages from, and work with the mailboxes on, a mail server. The latest version, IMAP4, is similar to POP3 but offers additional and more complex features. With IMAP4, for example, you can work with your e-mail on the server -- such as searching your e-mail messages for keywords -- while your e-mail remains on the server. You can download messages to your computer and leave them on the server to be accessible from a different computer. IMAP uses SMTP for communication between the client and server.IMAP was developed at Stanford University in 1986. For more
information about IMAP, see Stanford's Web page at:
Printmail utilityPrintmail is a free utility (courtesy of elm) that allows you to format a mail message for printing.printmail | lpr will print all the mail in your default mailbox. Run the man page on
it to learn more.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous Next |
What is FTP, and how do I use it to transfer files?What is FTP?FTP is an acronym for "file transfer protocol." As the name implies, FTP is used to transfer files between computers on a network, generally the Internet. You can use FTP to exchange files between your computer accounts, transfer files to or from an account to a desktop computer, or access software archives on the Internet. Most important, FTP follows a open internet standard on all computing platforms, so once you learn it you know it no matter where you go.What is anonymous FTP?Many universities, government agencies, companies, and private individuals have set up publicly accessible archives on the Internet. There are thousands of these sites that contain a myriad of programs, data files, and informational text. Maintainers of such sites set aside a set of public directories and files that may be read by the rest of the world via FTP, usually in a directory named /pub. Specific directions or information about a site is generally contained in greeting messages or files with names like README.Remember that anonymous FTP is a privilege granted by the organization that owns the computer to which you are connecting, and you should show good manners in your usage. Don't transfer files you don't need or an excessive amount of material, and try to restrict your transfers to off-peak hours. Many FTP sites are used very heavily, and you may need patience to connect. How do I use FTP?There are several ways to use FTP. The most convenient way is generally with a World Wide Web browser, which can connect to an FTP address just as it can to a Web (HTTP) address. Using a Web browser for FTP transfers makes it easy for you to browse large directories and read and retrieve files. Your Web browser will also take care of some of the details of connecting to a site and transferring files. To use your Web browser to connect to the site ftp.math.smith.edu, you would use ftp:// in front of the host name, with a / after the name:ftp://ftp.math.smith.edu/While this method is convenient, Web browsers are often slower, less reliable, and have fewer features than other ways of using FTP. You can also use FTP in a command line format from your Unix account, or your Unix or DOS workstation. To start FTP, enter at the command line prompt: ftp hostnameReplace hostname with the name of the FTP site (e.g. ftp.math.smith.edu or ftp.netscape.com). When you connect to another computer with FTP in this way, you must enter a name and password. To connect to an account of your own, enter your own username and password. To connect to most "anonymous" FTP sites, enter the username "anonymous" and your e-mail address as the password. As a shortcut, you can usually abbreviate your e-mail address as username@Replace username with your own username. The FTP program will automatically add your site name after the @ sign. Here are some common FTP commands, with examples of how you would enter them at the FTP prompt. Note that in this list, "remote" refers to the computer to which you are connecting with the FTP program. help Display the available commands.
Examples: help (list commands)
help put (help with put command)
help dir (help with dir command)
open address Open an FTP session with a remote computer.
Example: open ftp.indiana.edu
dir Display the directory contents on the remote computer,
along with file sizes and permissions.
Examples: dir (list current directory)
dir pub (list files in "pub")
dir .. (list files in parent directory)
cd dirname Change directory to "dirname" on remote computer.
Example: cd pub (change to directory "pub")
lcd dirname Change local directory on the computer on which
you started the FTP session.
Examples: cd /tmp (switch to /tmp directory)
cd ~/ (switch to your home directory)
binary Set file transfer type to binary, necessary when
transferring files (like programs or images) that
aren't stored as text files.
Example: binary
get filename Get a file from the remote computer and store it in
the current directory on the computer on which you
started the FTP session.
Example: get theirfile (grab a copy of "theirfile")
mget filenames Get more than one file from the remote computer and
store them in the current directory on the computer
on which you started the FTP session.
Example: mget hisfile herfile
(grab copies of "hisfile" and "herfile")
put filename Put a file from your local directory into the current
directory of the remote computer.
Example: put myfile (send a copy of "myfile")
mput filenames Put more than one file from your local directory into
the current directory of the remote computer.
Example: mput myfile ourfile
(send copies of "myfile" and "ourfile")
close Close the current connection, but stay in FTP.
quit Close the current connection, and quit the FTP program.
You can also use the FTP program non-interactively in a shell script,
and using the expect command.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contents Previous |
File Packaging/Compression toolsUnix has a good set of archival and compression tools. The following table lists the main ones:
In Unix, what is "tar", and how do I use it?"tar" stands for "tape archiving", which is one use for the command. However, tar's more common use is to combine two or more files for storage or distribution.To combine multiple files and/or directories into a single file, use the following command: tar -cvf file.tar inputfile1 inputfile2Replace "inputfile1" and "inputfile2" with the files and/or directories you want to combine. You can use any name in the place of "file.tar", though you should keep the ".tar" extension. If you don't use the "f" directive, tar assumes you really do want to create a "tape archive" instead of joining up a number of files. The "v" directive tells tar to be "verbose" and report all files as they are added. To separate an archive created by tar into separate files, enter at the shell prompt: tar -xvf file.tarYou can use gzip in conjunction with tar to create compressed archives. You can create a compressed archive with the following command: tar -cvf - inputfile1 inputfile2 | gzip > file.tar.gzNote: If gzip isn't available on your system, use the Unix compress command instead. In the example above, replace gzip with compress and change the ".gz" extension to ".Z" (compress looks specifically for an uppercase 'Z'). To separate a gzipped tar archive, enter gunzip -c file.tar.gz | tar -xvf -Similarly, to separate a tar archive compressed with the Unix compress command, replace gunzip with uncompress In Unix, how do I create or decompress zip files?To create a zip file, enter at the Unix prompt:zip filename inputfile1 inputfile2Replace filename with the name you want to give the zip file. The .zip extension will automatically be appended to the end of the filename and will include the period. Replace inputfile1 and inputfile2 with the names of the files you wish to put into the zip archive. You can include any number of files here or an asterisk (*) to include all files in the current directory. To include the contents of a directory or directories into a zip archive, use the -r flag: zip -r filename directoryThis will create the archive filename.zip that contains the files and sub-directories of directory. Files created by zip can normally be decoded by programs like PKZIP, but especially if the zip archive is to be transferred to DOS, you should use the -k flag. This will simulate a zip file created by PKZIP and will shorten long Unix filenames. To de-archive a zip file in Unix, use the unzip command. Enter at the Unix prompt: unzip filenameReplace filename with the name of the zip archive. For more information about zip and unzip, see their manual pages:
In Unix, how can I read a file that ends in .Z, .z, or .gz?A file whose name ends in .Z, .z, or .gz has been compressed, so that it takes up less disk space. Unfortunately, compressed files can't be read like normal files, so they must first be expanded, or "uncompressed". How you do that depends on the program used to compress the file in the first place.Files whose names end in .Z were compressed with the "compress" program. To expand such a file, enter at the Unix prompt: uncompress filenameReplace "filename" with the name of the file. It doesn't matter if you include the ".Z" at the end. Files ending in .z or .gz were compressed with "gzip", a newer and much better program than compress. To uncompress a gzipped file, enter at the Unix prompt: gunzip filenameAgain, replace "filename" with the name of your file. It doesn't matter whether you include the ".gz". |