This documentation, a modification of UNIX: The Basics is intended as an introduction to UNIX and emacs for CS 5 students at Harvey Mudd College, so that they may better understand the environment in which they are programming.
Academic Computing Documentation Library
This manual is an outline version of some of the basic UNIX commands that will be useful as you begin using Unix (on Orion). We will talk about the commands, and the editor (Emacs) that you will be using as you work on your CS 5 programs and labs.
Unix is a layered operating system, the OS, called the kernel in Unix, interacts with hardware and provides the services to the user. In most modern operating systems, like Unix, the users do not need to know anything about the hardware, all that is necessary is that they know how to interact with the kernel. The way you interact with the kernel is through system calls, which this document will teach you about. Some examples of system calls are commands to open, close, read or write to a file, or make or change directories and their ownerships. Commands have the form
: command [options] [arguments]
Options are usually preceded by a hyphen (-) and you can put more than one option concatenated after the hyphen.
Unix is a multi-user, multi-tasking system which means that many users can log in and work on the system at one time. The kernel manages all the users and their processes or programs.
All of you probably already have logged onto Orion, during Freshman orientation or on your own. Therefore, you already have your password and your user name. There are multiple ways to connect to orion. If you are not in the PC or Mac lab, then most likely you will be using a telnet session from your dorm room. Using telnet requires that you have an Ethernet connection, which entails having an Ethernet card and the appropriate software installed on your computer. When you choose to telnet to orion.ac.hmc.edu and you will get a username prompt. Other remote login programs, such as NCSA Telnet, will ask you for the name of the machine with which to connect. Once you have established a connection, the computer will prompt you for your username. Then, after you have entered your username, the computer will prompt you for your password. Here's what a typical login looks like:
: login: juser
: password: Your password will not be displayed as you type it.
(Note that you must hit Enter at the end of each command line, although we won't remind you from now on.) If you are successful, you will see system notices and then your prompt will appear. The default prompt on orion is:
: [time] juser@orion (~):
In the paranthesis you will see the directory that you are currently in. If it is blank (displaying just the tilde ~) that means that you are in your home directory. This prompt indicates that the system is waiting for you to enter a command. On the other hand, if your login was unsuccessful, the computer will respond with
login incorrectand you will have to try again. Remember that your username is in all lowercase letters and that in general Unix is case sensitive.
1.2.2. Changing Your Password
If you have just logged in for the first time you should change your password now. Use the "change password" command by typing
: passwd
The system will ask you for you current (old) password and then your new one. It will make sure that you know your new password by asking for it again. It will also advise you if your password is too short or too simple. It is very important to pick a password that cannot be figured out using your name, other personal information, or a list of dictionary words, since these methods are commonly used to break into accounts. Your password should be 8 characters long, and should include at least one capital letter, one lower case letter, and one character that is not part of the alphabet. Certain symbols like the pound ("#") symbol and the at ("@") symbol are not recommended since they sometimes are used by the computer to hold special information.
1.2.3. Basic Command Information
There are functions that require you to type a character by hitting more than one key at once. These are known as control characters, and are typed by holding down the Ctrl key while you hit another key. We'll indicate control characters in this document with the caret (^). For instance, you can usually terminate whatever is currently happening by pressing ^C. Don't type the caret; just hold down the control key and hit the letter key.
To execute a program, whether a UNIX utility or a program you wrote, enter that program's name at the prompt. There is no "run" command. For example, to execute the date program (which gives the date and time) just enter:
: date
Thu Aug 6 15:12:25 PDT 1992
If you are stuck in something you can't get out of, try ^C. If your screen seems frozen you may have typed ^S by accident. Try ^Q to get out of this. If you are familiar with job control (see section 2.4) you can try to suspend and then kill a process. If none of these work, ask someone for help.
Also note that UNIX is case-sensitive, so that RM, rm, Rm, and rM are all interpreted differently. This applies to filenames as well as commands, so be careful when you type.
1.2.4 Logging Out
To log out, you must be at your prompt, :, and then you can type any of the following:
: logout
: exit
: ^D
It's generally not a good idea to leave yourself logged in while you are not around, as someone could change your files or look at files that you might not want any one to look at. Also, it is impolite to leave yourself logged in for a long time, as other people are waiting to use the computers.What is a file? Well, in UNIX a file is just a collection of bytes, or in other words just data. A file can be a love letter, a CS assignment, data from your last chemistry lab, or even a "directory" ; full of more files. The file's meaning depends solely on the program using it. UNIX doesn't require text files to have one format and the object code of a program to have another. To UNIX, files are files.
1.3.1 Common File Commands
The natural habitat of a file is a directory . A directory is just a file which is a list of other files. Whenever you log in, the computer automatically places you in your "home" directory. To get a list of the files in your current directory, you can use the ls command, which is short for "list" files. Try this:
: ls
Well, most likely you just got the % prompt back. This is because you don't have any files yet except that you may have "dot files." ; These files are hidden so the default ls command does not list them. To see these dot files type:
: ls -a
The "-" is a standard UNIX way of sending options to a program. In this case the option -a tells the program ls that you wish to see all of the files, including the dot files. If your account has been set up correctly, you should see a list of a bunch of files on your screen.
Just having files isn't very useful if you can't read them. The most common way to view a file in UNIX is the more command. For example, to view the .cshrc file, type:
: more .cshrc
When you get the "--More--" prompt, hit Return to see the next line of the file. Hit the space bar to see the screenful (or windowful). If you wish to quit before you reach the end of the file, hit "q" at the "--More--" prompt to return to your : prompt. A similar command that has more features (like allowing backwards viewing in a document) is the less command. Just type "less file" to view the file. Then use "f" and "b" to go forward and backwards in the document page by page, and use the up and down arrow keys to move up and down in the document line by line. Press "q" to get out of the less viewer.
Printing a file is just as easy as displaying the file on your screen. The lp command will take the file whose name you give it and print it out on cujo or odie (The academic computing printers. Just type:
: lp filename
where filename is the file you want to print. Other options modify the lp command, like the -d option, which prints to another printer besides the default one. Check the man pages by typing "man lp" to see the other options.
1.3.2. Other File Commands
Other useful things you can do with files is to copy, move, and remove them. The commands to do this are cp, mv, and rm. Note that since the name of a file also shows the file's location, the mv command is also used to rename a file.
cp
cp is used to copy files. This is useful for many things. A good thing to do
is to create a standard java template for your programs. Each time you start
a new program you can just do:
: cp template.java newfile.java
mv
mv is used to move files from one location to another, like with cp, you would
type in:
: mv oldlocation newlocation
This is useful when you notice that you wrote your program in the wrong directory, that maybe it's in your home directory instead of your cs5 directory, and you need to change it so that submit works.
rm
rm removes a file. After rm the file is no longer accessible.
: rm myfile
1.3.3. File Security
What about security? If you keep private letters on the system, how safe are they? Well, it is quite easy for people to look through your files if you let them, but if you want you can put up the "keep out" sign. You can set various permissions or modes on files. Every file has permissions. Permissions just tell the system who can do what with a file. To see the permissions set on your files, use the ls command with the -l option. The -l option, which stands for "long" format, tells you permissions information plus a few other items. For example:
: ls -l total 1 -rw------- 1 juser students 415 Mar 06 04:21 copy_of_newfile
Notice the first set of characters, the bar of hyphens with letters. That bar tells you what permissions your file has. The first hyphen tells you the type of the file. Plain files are denoted by - and directories are shown by d.
The next nine permission characters are split into three groups of three. The first group sets permissions for the "user" (that's the file owner -- you), the next three refer to the "group" (e.g., students or faculty) and the last three refer to "others" (everyone else). Each sub-group of three contains spaces for the letters rwx. The r tells you that you can read from the file, the w tells you that you can write to it, and the x tells you that you can execute or run it. For the above file, you can read or write to it but "students" and everybody else cannot read, write, or execute the file. To change permissions on a file you use the chmod command, which is short for "change mode." The chmod command has the format:
% chmod mode filename
where mode can be of the form
who operation permission
who is one of the letters: u for user (you), g for your group, o for others, and a for all users (user, group, and others). The operation is either a + or a - symbol, which stands for "give" or "take away" the following permission. And the permission is a combination of the letters: rwx. For example:
% chmod u-w copy_of_newfile
would prevent you (the user) from being able to write (modify or overwrite) to the file. It would also prevent you from deleting the file without first being asked to confirm such a request.
1.3.4. Directories
In addition to files, directories can hold other directories, known as subdirectories. Look at the results of pwd (Print Working Directory), a command that shows in which directory you are currently located.
% pwd
/home/juser
Your home directory juser is a subdirectory of the directory home which is a subdirectory under the directory / (slash), which is called root. root is the main directory in a UNIX system. Under root are all the other directories and subdirectories on the system. (Picture the file system as an upside-down bush with a single root and many branches.) The path includes all directories you have to go through, starting from root (/), to get to a particular directory. The names of all the directories along the path are given in order (starting from root) and are separated by slashes (/).
You can partition your directory into as many subdirectories as you want using the command called mkdir, which is short for "make directory." To use the command you just type
: mkdir newdir,
where newdir is the name of the directory you want to make. Subdirectories are nice because you can have one for each major category of work you do on the computer, like reports, CS homework, letters, and so forth. This keeps the clutter out of your home directory. It is suggested that you use subdirectories.
To get into a subdirectory use the cd command, which is short for "change directory." The format is
: cd directory
where directory is the name of the directory you want to move to. In UNIX, files lie along what is called a path. The path is formed by the names of subdirectories. Every directory has the hidden directory "..". This hidden directory points back up to the directory that holds the subdirectory, called the "parent". For example, when you're in your home directory juser and you type
: cd ..(that is two dots)
UNIX brings you back up one directory along the path to /home.
Before you go frolicking up and down the path of directories you must know a few things. First, if you ever want to get back to your home directory, just give the command (cd) without a directory name. It's like saying "There's no place like home" and clicking your heels together three times. Second, remember you can always find out where you are by using the pwd command. Also, remember that directories have permissions, just like any other files. Thus, other people can keep you out of their directories and you can keep other people out of your directories.
If you have a question or problem there are several things you can do:
We would prefer that you don't opt for the first choice! Many users are afraid to ask how to do something. Don't be. UNIX is hard to learn at first, so don't give up or be frightened by some of its cryptic forms.
1.4.1. Online Help
The second option is a good place to start. If you have a question about a particular command then try the man command, which is short for "manual." The man command is the usual way to get help on UNIX. All you have to do is tell the man command the name of the command you want, like so:
: man command
where command is the name of the command you want help on. However, if you don't know the name of the command you want help on, you can try using the -k (keyword) option. For example, if you wanted to know about the command for copying files, you might type:
: man copy
but this results in the message
No manual page for copy.
This means that there is no command called copy. The next thing you should try to find a command which copies files is:
: man -k copy
This will list every command with the word "copy" in its description. If you can't find something on the first try with the -k option, try using synonyms.
Another form of online help is the Frequently Asked Questions and the Quick-Reference pages on the computer science homepage,
http://www.cs.hmc.edu/tech_docs/index.html
1.4.2. Consultants
The third option is to ask someone. Usually there will be someone at the consultant chair in the front of the ac labs. If not, ask an upper classman, or a fellow class person. Chances are, your question is not new or unique.
1.5. Creating and Editing Files
There are many different methods of creating and editing files in a UNIX environment. emacs is the primary editor that you will be using to write your programs.. See Chapter 3, "Editing with emacs," for more editing material.
Alternative editors include vi and jove. To find out more about these editors, refer to the Editors FAQ or read the appropriate man pages .
1.6. Letting Others Know About You
Read the documentation on the finger command and then create .plan and .project files in your home directory. The finger command provides other users some information about you. The .plan file allows you to put in any text that you want other users to read when they try to find out about you. Both file names must begin with a dot (.). After you create these files try using the commands ls and ls -la to see how files which begin with periods are listed.
The mail utility is provided as a means of communication between users. Normally, mail is used when a user wants to leave a message for a particular user who is not currently logged in, or when a user wants to send mail to a user on a different computer system. For communication between currently logged in users, either write or talk can be used.
1.7.1. Reading Your Mail
Sometimes when you log in, the system will print out the message:
You have new mail.
At this, most people get all excited and scream "Wow, I got mail!" This message means that the system is holding some mail for you. To read your mail, just type:
: pine
The computer will then read your mail file (mailbox in your home directory) to find your current mail. It will then display a menu at the top of the screen and a smaller menu at the bottom. Use the up and down arrows to move among the menu options to choose what you want to do in pine. Select "Folder Index" to read mail in your default mailbox and use the keys at the bottom of the page to move between menus.
1.7.2. Sending a Mail Message
To send a mail message in pine, select "Compose Message" from the top main menu. Then fill in the "To:" line with the address of the person you will mail the message to.
The proper format for an address is
username[@machine-name[.domain-name]]
where username is the name of the account to which you are sending mail, machine-name is the name of the machine on which that account exists, and domain-name is the name of the network or organization to which that machine belongs. You need not specify the machine and domain names if you are sending mail to another account on the machine (e.g., orion) where you are currently logged in. (The square brackets just indicate that part of the address is optional; do not actually type them.) The computers in the Claremont Colleges, like any educational institution, belong to the edu domain (case is irrelevant in domain names).
Here are some sample addresses:
To: jschmoe (jschmoe must be a user on the same machine you are on)
To: jschmoe@orion
To: jschmoe@pomona.edu
To: srm3735@tybalt.Caltech.edu
In pine, fill out the carbon copies, attachment, and subject fields , pressing enter after each one. The attachment field allows you to tag other mail messages onto your message. Then begin editing and writing your message in the "Message Text" field. When you are finished, type "^T" to spell check you mail, and then type "^X" to send the message. You must confirm "yes" to send the message. Pine will then return you to the main menu to choose another option.
1.7.3. Getting mail to orion from outside of Harvey Mudd
When your friends at distant sites are trying to send you mail the following is your electronic address:
username@orion.ac.hmc.edu
They should also be able to reach you at:
Firstname_Lastname@hmc.edu
This address will send mail to your account on orion, which is the computer system run by Academic Computing. This can be changed using a forwarding file. More information on mail and mail forwarding can be found on the mail FAQ page (produced by the computer science department.
1.7.4. Automatic Email Forwarding
If you like to centralize your email, you can tell orion to forward all your incoming email to another machine.To forward your email to another machine: Create a file call .forward in your home directory (ie. ~/.forward ). This file should contain the email address your mail is to be forwarded to.
For example:
If your .forward file contains user@orion.ac.hmc.edu, all of your incoming email will be sent to user@orion.ac.hmc.edu. But be careful, if you forward your mail to the machine that you on, then mail loops happen, which can cause havoc.
The C shell, csh, is the command interpreter which is usually used on the Computer Science machines to read commands from the user's keyboard and run the appropriate programs (actually, most users, including all new users, use an enhanced version of the C shell called tcsh). The shell has features that provide convenient services to the user. The main benefits of the C shell include filename abbreviation and grouping, input/output redirection, job control, history substitutions, personalizing the environment by defining aliases, and allowing command line editing.
There are two reasons for filename substitution. First, this feature is useful when one wants to deal with a collection of files, such as deleting all files that end with .junk. Second, it can provide an abbreviation for a long filename. For example, if you wanted to delete all the files you own that end with .junk, you could type
: rm *.junk
The asterisk stands for any group of characters, including a null string. The pattern j*k may stand for any of junk, jk, and jhellok. Other special pattern matching characters are the question mark, which stands for any single character (but never a null string) and brackets, which match any one of the set of characters inside of the brackets. Within brackets one may also include a range of ASCII characters. So,
: more chapter.[1-46-9]
displays chapters one through nine excluding five.
Often it is desirable to redirect input or output from its normal path. There are four primary redirection commands, <, >, >>, and | (called "pipe"). The < takes input from a file, > writes output to a file, >> appends output to a file, and | pipes output from one program to another.
For example, the cat command, without parameters, is pretty boring; it simply takes input from the keyboard and outputs it to the terminal screen - not useful unless one wants to practice typing. However, using a single greater-than symbol, one can turn the cat command into a "create file" command.
: cat > newfile
I am typing information for storage in the file called newfile.
^D
This example takes input from the keyboard and sends its output to a file called newfile. Input may be similarly redirected using a less-than symbol. Follow the command with a less-than symbol (<), followed by the name of the file to be used as standard input (instead of the keyboard) for the command. For example:
: cat < newfile > copy_of_newfile
This simple example copies newfile into copy_of_newfile by reading its input from newfile then redirecting its output to copy_of_newfile. Of course the cp command does it more easily, but you get an idea of what redirection can do.
The echo command is used to repeat, or echo, the argument you give it back to the standard output device.
more, less, and pg let you page through the contents of a file one screenful at a time. Read the man pages for more information on each of them.
head and tail display the beginning or end of a file. By default head will display the first 10 lines. If you want to see more, use:
: head -n number filename
or
: head -number filename
Tail is similar, by default displaying the last 10 lines of a file.
Finally, an example of the use of the pipe is:
: ls -s | sort -nr 11 junk 3 old.stuff 1 cats 1 meow
The ls -s command lists the filenames with their sizes in the first column. This output is sent as the input of sort, which sorts and outputs these records numerically (-n) and in reverse order (-r).
Aliasing is simply a way of substituting one word for a list of words to save key strokes. For instance, if ll is aliased as ls -als, the command ll is first translated to ls -als and then the command is executed. One can set up this alias by typing
: alias ll 'ls -als'
To remove this alias, type unalias ll. To see a list of all of your aliases, type alias.
Aliases are usually done from the .cshrc file. This makes the aliases available automatically. You can create a file of aliases and use them by executing the source command. Suppose you edit your .cshrc to add some new aliases. To put these aliases into effect, execute the command
: source .cshrc
You can control jobs with a series of control character sequences. These sequences are listed with a short explanation.
^Z suspends the current process.
^C terminates the current process.
^D sends an "end-of-file" to the current process. (From a login shell, it logs you out of the system.)
When a command is typed, the program is run; when it completes, the prompt returns ready for the next command. What happens is that the C shell creates a subprocess to execute the command and then waits for that subprocess to complete. If you end the command line with an ampersand (&) the C shell will start the subprocess without waiting for completion, thus freeing up your terminal. This is called running a job "in the background." While jobs are running in the background, you can work on other things. The C shell will notify you when your background jobs are finished. For example:
: javac homework.java & [1] 2314 :
and when the job was done you would get the message
[1] Done java homework.c
The "1" in the brackets indicates that this background job may be referenced with %1.
If, while the job is running, you decide to terminate the job, you may type kill %1. You may also kill a process by first finding out its PID number using the
: ps -fu username
command, and then using
: kill -9 PID number
to terminate that process.
Often you may enter a command and later decide you want to do something else in the shell while the current command is running. This can be accomplished by typing ^Z while the job is running. This stops the job and gives the user a prompt. The stopped job may be continued in the background (the shell lets you continue entering commands while the job is running in the background) with bg, in the foreground with fg, or killed with the aforementioned kill command. To see a list of all your existing jobs, just use the command jobs.
If you try to log out with stopped jobs, the system will respond with:There are stopped jobs.
Remember, these jobs should be either killed or completed prior to logging out.
The C shell provides capabilities to facilitate programming in the shell, such as control flow commands and variables. Shell commands can be put into a shell script and executed. A shell script is a file which contains a collection of shell commands to be executed together. These commands are executed just as though the user were typing the commands from the keyboard. In this way one may write programs using the C shell commands. There are many books in the OS lab (in the computer science department) about shell programming that are helpful for beginning shell programmers.
2.5.1. The .tcshrc Script
The script that customizes your csh and tcsh operations is called .tcshrc. The C shell looks at this file, and executes the commands in the file, every time you log in and use one of the C shells, csh or tcsh. The commands in the .tcshrc file ReConfigure (hence the "rc") the C shell to your own liking. The .tcshrc file, together with the .login file allow you to personalize your working environment. You can use a text editor (such as emacs) to modify your .tcshrc file.
2.5.2. The script command
The script command creates a script of your session input and output. Using the script command, you can capture all data transmissions from and to your terminal screen until you exit the script program. This will be useful for debugging programs and keeping track of the commands that you have run.
:script [-a] (... your work...) exitThis will append (-a) all your work from when you started the script until you exit and it will append it to the file specified.
The C shell allows previously entered commands to be recalled, edited if need be, and re-executed. This feature of the C shell is commonly referred to as history substitution. To enable this feature, the shell variable history must be set. This can be accomplished by entering
set history=20
either in the C shell or in a .tcshrc file. In the example above, setting the history variable to 20 will cause the shell to remember up to the last 20 commands entered at the current shell level. Setting history can cause only subsequent commands to be remembered; the history feature will not work retroactively.
A list of commands remembered by the history mechanism can be obtained by simply typing history while in the C shell. Now consider the following example of such a list:
: history 47 11:44 ls /hmc1/hmc_2000/hmudd/cs164 48 11:54 ls /usr/games 49 11:57 cat file1 file2 file3 50 11:57 cat file4 file5 file6 51 11:58 cat krank1 krank2 krank3 krank4 krank5
The integers preceding each of the listed commands are called event numbers. (If you use tcsh you will also get a listing of the times when each command was run.)A history substitution may occur anywhere in the input stream of a command. The simplest form of a substitution consists of an exclamation mark and the number of the desired event or an exclamation point and the first letter of the command you want to execute. For instance, if we wished to re-execute command 48, we could type one of the following
: !48 to execute command 48 : !-4 to execute the fourth previous command : !ls to execute the most recent command beginning with the letters "ls"The last command says to execute the most recent command that starts with the letters "ls". All these history commands are equivalent to ls /usr/games (using the example above). Finally, within the tcsh shell, the up and down arrow keys can be used to scroll through the commands in the history file.
2.7. Sources of Additional Information
The main source of documentation exists in a paper entitled An Introduction to the C Shell by William Joy, developer of the C shell at Berkeley, in the Unix Users's Supplementary Documents section 4 (USD:4). It is highly recommended reading for learning about the C shell. You can also use man csh and man tcsh to learn more about the C shell and tcsh, an enhanced C shell. Also there are many books on shell programming.
Chapter 3 Editing with emacs
emacs is the most commonly used editor in the HMC UNIX environment. There are other editors based on it, such as jove.
To use emacs to edit a file, simply type
: emacs filename
There are two ways of entering commands into emacs. The most commonly used commands are bound to keyboard sequences using the Esc or Ctrl key. For example, ^V moves forward one page and Esc V moves back one page.
The second method of command entry is called the command line. Typing Esc X (also known as Meta-X, M-x, or Alt-X ) will cause a M-x prompt to appear at the bottom of the screen. You then type in a command and emacs will execute it. The commands here include all of the commands bound to keys as well as many others. For example, with the default set up M-x scroll-up is the same function as ^V but M-x apropos can only be invoked at the command line.
emacs can be customized. If you don't like the command that is attached to a key you can "bind" a different command. You can have emacs expand abbreviations automatically. Also there are many features you can turn on and off. Customizing is best done with your .emacs file (emacs run command file). Put any changes you make after the lines that are already in there, or alter the defaults as suggested by the comments.
emacs by default does an auto-save every so often. The amount of time is user-configurable. The auto-save filename will be the filename sandwiched between two # symbols. If the system crashes or you accidently exit without saving your changes, you can get some of them back by using the recover-file command. Edit the file again, and type M-x recover-file.
If you wish more information about how to use emacs try typing M-x and then as much of a command as you want followed by a ? and emacs will list all the commands that start that way. You can even simply type M-x ? to get a list of all commands. emacs has command completion so that at any time you may type a space to have emacs try to determine the rest of the command. It will type as much as it can and if the command is not yet complete continue the input process for the remainder.
You can also find out what command any keystroke or sequence of keystrokes will execute by using M-x describe-key and then hitting the key or key sequence you are curious about. The command M-x apropos will list all the commands in which the word or character string "keyword" appears. You can then use M-x describe-command to get a brief description of what the commands do.
Emacs Commands |
|
|---|---|
Action |
Command |
| invoke emacs | emacs filename |
| save file | ^X^S |
| exit emacs (with or withour saving) | ^X ^C |
| command line mode | Esc X |
| abort command | ^G |
| refresh screen | ^L |
| suspend emacs | ^Z |
| Search and Replace | |
| incremental search forward (may not work on some terminals) | ^S |
| search forward | ^S RETURN |
| incremental search backward | ^R |
| search backward | ^R RETURN |
| find and replace | Esc X replace-string |
| query find and replace | Esc X query-replace or Esc % |
| Movement Commands | |
| up one line | up arrow or ^P |
| down one line | down arrow or ^N |
| right one character | right arrow or ^F |
| left one character | left arrow or ^B |
| next word | Esc F |
| previous word | Esc B |
| beginning of line | ^A |
| end of line | ^E |
| page forward | ^V |
| page backward | Esc V |
| Delete Commands | |
| previous character | ^H or Delete |
| current character | ^D |
| to end of line | ^K |
| Cut and Paste | |
| mark beginning of region | ^<space> or ^@ or ^2 |
| copy region | Esc W |
| delete region | ^W |
| yank (paste) | ^Y |
| yank previous | Esc Y |
| File and Buffer Commands | |
| find file | ^X ^F |
| insert file | ^X I |
| view buffers | ^X ^B |
| change buffers | ^X B |
| delete buffer | ^X K |
| Useful Commands | |
| alias | list aliases |
| bg [job] | run a suspended job in the background |
| cat file | display the contents of file on the screen |
| cd [dir] | change working directory. If no directory specified, change to home directory |
| chmod ### file | change the protection mode (###) associated with file |
| cp file1 file2 | copy file1 to file2 |
| elm | an interactive mail system, predecessor of pine |
| emacs | a text editor |
| fg [job] | bring a job back out into the foreground |
| finger [user] | look up user information |
| ftp | file transfer protocol; transfers files between machines |
| grep expr file | find lines containing expr in file |
| history | list previous commands available in history buffer |
| jobs | see what jobs currently exist |
| kill PID | kill job with process ID number |
| less file | type a file to the screen and allows backwards movement |
| lp file | print a file out on the default printer |
| ls | list the files in your working directory. Dot files require ls -a |
| man command | look at the manual page for command |
| mkdir dirname | make a directory with the name dirname |
| more file | type a file out to the screen one page at a time |
| mv old_filename new_filename | move (change the name of a file) from file1 to file2 |
| ncftp | an interface for ftp that allows you to keep your sanity |
| passwd | set password for your account |
| pine | an easy to use mail system |
| ps | list processes and process ID's |
| pwd | show the current directory |
| rlogin machine | remote login to another computer |
| rm file | remove a file from current directory |
| rmdir directory | remove a directory |
| script | capture all terminal input and output into a file. Use ^D or exit to terminate |
| spell file | check spelling of words in file |
| talk | interactive communication with other users on turing |
| telnet machine | log into another computer over the network |
| trn | read USENET news |
| vi | an elegant and beautiful text editor |
| w or who | find out who is on the system |
| ^C | stop a job (forever!) |
| ^D | end-of-file (end-of-script) character. Also logs the user out at the command level |
| ^Z | suspend a job. See also bg and fg |
| Useful Features | |
| flags | flags can be used to get different options of a certain command. For
example, : ls -s lists the name and size of each file in your current working directory. Consult the manual pages for more information |
| pipes | pipes take the output of one command and give it to the input of another. This is very useful! To use a pipe, first type the command that will supply the output, then type a vertical bar, |, to pipe the output into the input of another command. Finally, give the command that expects to receive the input. For example:% a.out | more. In this example, the output of a.out could be many pages long. By piping a.out's output into more, the output can be viewed one page at a time |
| command < file | The "<" character tells the command it follows to take the named file as standard input instead of input from the terminal keyboard |
| command > file | The ">" character tells the command it follows to take the named file as standard output instead of outputting to the terminal screen |
| command >> file | The ">>" feature tells the command it follows to append standard output to the named file instead of outputting to the terminal screen |
| command >& file | The ">&" feature tells the command it follows to send standard error or diagnostic output to the named file instead of ouputting to the terminal screen. Note that this feature is specific to the C shell and tcsh |
| * | The "*" wildcard stands for any group of characters, including a null string |
| ? | The "?" wildcard stands for any single character, not including a null string |
| [ ] | The brackets match any one of the set of characters inside of the brackets. Ranges, e.g. a-p, may be used inside of brackets |
| ~ | The "~" is referred to as the tilde or twiddle. By itself it represents your home directory. Twiddle with a username after it represents that user's home directory. For example, cd ~juser will change directory to juser's home directory |
This document has been previously published by the Harvey Mudd college Computer Science Department in both hard copy and electronic form. Previous editions published 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1997. All rights reserved. No part of this document may be reproduced, stored in a data base or retrieval system, or transmitted, in any form or by any means, without prior written permission of the authors and the Harvey Mudd College Computer Science Department.
X Window System is a trademark of the Massachusetts Institute of Technology.
PostScript is a trademark of Adobe Systems, Incorporated.
Macintosh is a trademark of Apple Computers, Inc.
SunOS, SPARC, and Solaris are trademarks of Sun Microsystems, Inc.
Last modified 6/6/98 by Kendra