A blitzkrieg introduction to Unix/Linux, in no particular order These are for the TC Shell (tcsh); other options (e.g., bash) are very similar. ------------------------- Getting out of things, and general control of the situation: Control-c: [shorthand: "^c"] stop the command or process (they're the same) that was running. This sometimes works. Control-d [^d]: usually interpreted as "exit", it will get you out of a lot of things. It can log you off if you're not careful. Control-z: [^z] Stop the command/process and make it wait. You get a prompt back. Then, bg: makes it run but "in the background" so you can type other commands at the same time while it's running (see "&" below.) fg: make it run in the foreground like it was before, doesn't let you do other stuff at the same time. ps : shows your current processes ps -a: I think this shows processes in the background too. Check. Control-s [^s] : you don't usually want to do this. This will stop your computer from printing what's going on to the screen, even though it can still read your key strokes and react to them. This is a command sequence in some programs (like Emacs) so it doesn't have that effect there. Usually you type it as a mistake, and here's how you get out of it: Control-q [^q]: start the screen going again after output was suspended. Types of commands, -abcd.... : this is usually the way you change how a command operates. There will be different letters you can put after a minus sign to give options, and you have to read the man page on the command to know what they mean and what they do. So, "ls" does not (by default) show files that begin with a "." whereas "ls -a" does. "rm -i" asks you if you really want to delete a file, whereas "rm -f" doesn't. There's a default option for every command, but quite often the system guy will make an "alias" for certain commands. So, when you type "rm " the alias turns it into "rm -i " before it gets interpreted, so that the computer asks you if you really want to erase . &: run a command in the background, so that you can do other things at the same time. Commands in the background will keep working even after you log off. To see them you can type "ps -a" (see below); this gives you their process id# to kill them with too. nice : run the command, but give it a low priority to be "nice" to other users of the same computer. < : do command, taking input from the file you name. First you need to know what commands take input: these are typically programs, like mathematica. > : make the output of a command go to into the file rather than onto the screeen. This destroys the previous contents of the file. So, "ls > myfiles" puts the output of ls (a list of the files in the directory) into a file "myfiles" (which it creates if there wasn't one before.) >> : append the output of the command to the filename ratherthan destroying previous comments. ; : do command1 first, then command2. So, "ls ~/research > researchfiles ; grep deborah researchfiles >> debfiles" does: 1. list the files in directory ~/research (the /research subdirectory of your home directory) and put the output in the file researchfiles in your current directory (which doesn't have to be the home directory); then 2. print out those lines in file "researchfiles" which contain "deborah" and put the resulting lines at the end of the (maybe preextant) file debfiles. | : "pipe" the output of the first command through the second before showing them to you. So, "ls |grep matzner" shows you the output of ls, but only those lines that have the word "matzner" in them, and "ls |more" shows you the files in a way that they don't scroll off the screen too quickly. \ : do command, without allowing the computer to substitute an "alias" if there is one which would apply. For instance, there's usually an alias to make "rm" interpreted as "rm -i", that is, the computer asks you if you really want to delete a file before it does. Control-d: quits some things. Sometimes this will log you out of a unix session, if you type it on a blank line. "Shells", and typing and editing commands: There are different "Shells" in Unix: each is a system which interprets what you type. These are what make Unix tick. They all agree on the basic stuff I tell you below, but some are fancier than others. "man shell" or "man tcsh" tells you some good stuff. Here's what I know: csh: The comand "csh" puts you in the C-Shell. This is the basic Unix shell and might be what you have already. It allows you to edit your current command (by typing, backing up, inserting characters, stuff like that) tcsh: the command "tcsh" puts you in the TC-Shell or something like that. It allows you to edit commands you typed before; it completes things if you have typed enough to specify a command or file name and then press tab. Some of the stuff below is in tcsh not csh. There are other shells. I use tcsh. exit: leave the shell you're in and go back into the one you were in when you started that shell. If you're in your login shell (the top layer) this might log you off. I'll use the symbol "^" to mean the Control key. So... "^p": meaning, "Ctrl-p" or Control and "p" typed at the same time: edit the previous command (type again for the one before that.) This is great if you type a long command with a typo. Up-arrow-key works for this too. "^n": edit the next command (if you're at a command you typed a while back.) "^b" "^f": go back & forward in the current command to insert or delete characters. "^d" usually deletes the character under the cursor rather than the previous one. The delete key usually does the previous one, or maybe the backspace key. Unfortunately the meaning of these keys changes depending on what computer you're on, what terminal you're on, and what program you're running. {If you're on "Telnet" on a Mac, "Apple-s" lets you edit the Mac's use of some important Unix keystrokes. I just blank them out. Also, there's a menu thing to change the backspace and delete stuff,usually.} (You can probably use the arrow keys for ^p,^n,^f,^b instead.) (these are also commands in Emacs, so it's good to know them by heart.) "!": repeat the last command which began with . ^^: repeat previous command substituting string2 for string1: for instance, ^5^1 : repeat pevious command substituting "1" for every occurrance of "5" "[tab]": this completes the string if there's only one logical choice. Believe me, this can speed things up in specifying directories, etc. This works also in command windows in Emacs (there you can hit the space bar too to see a list of possible completions.) "^d" : this gives you a list of the possible completions of your command that all start with "string". So, you can just go through the alphabet to find out what commands there are. Not that they'll all make sense!. NOTE: on some shells this doesn't work; use "[tab]". Startup files: (these start with a "." and don't show up in a "ls" but do in a "ls -a".) Some files are run when you start up the computer, open a window, log out, etc. I should send you my version of these files. .login : stuff the computer does when you log in. Probably tells you the date & time ("date",) sets what kind of terminal you usually use (e.g., "setenv TERM vt100",) etc. .cshrc : stuff it does every time you open a window (if you're on a terminal that can do that,) or a new shell. Most things belong here rather than in .login . Never put a command in here that starts a new window, if you ever use a window terminal, or one that starts a new shell. .forward : a file containing an address to send messages if you want to read them at a different computer instead. I think there's some file like .forward which can send a reply every time you get a message, like "I'm on vacation until June; I'll ignore your message when I get back," but I forget what that is. Be very careful not to have two .forward commands pointing at each other (a forwarding loop)! .plan, .project, .finger: files containing information you want to appear if someone does a "finger" of your name. Usually the finger daemon is shut off for security reasons these days. __________________________________________ General commands: List of some useful commands (there are plenty others.): man ps pwd ls cd cp mv rm rmdir mkdir cat more date finger who telnet rlogin rsh emacs ftp talk write fg bg from tail last sort diff trn rn alias unalias setenv set stty csh tcsh chmod grep awk script lpr lp _________________ man : give manual information on the command. This is what you should read to know more. I would say this is the most important command! apropos : give a list commands whose description contains "" ^d : that's 1.type some characters 2. hit control-d. The computer will show you all the possible way to compete what you typed assuming it's a command. alias : Have the computer interpret string1 as string2. So, you could say "alias chris matzner@physics12.berkeley.edu" and then if you type "talk chris" the computer will act as if you had typed "talk matzner@physics12.berkeley.edu". Read the man page ("man alias") to see how to put spaces in the alias, I think it's by putting stuff in 'single quotes'. alias : On its own, shows you the list of aliases that are active. unalias : removes the alias for a string. \ : ignore alias (if there is one) for command. Note this is a backward not a forward slash. So, " \rm research/ion*.dat " removes all the files starting with "ion" and ending with ".dat" in the subdirectory "research/"of the current directory, without asking you whether you're sure, whereas "rm research/ion*.dat" will ask if you're sure. This is generally a lot safer than doing "unalias rm" and then "rm research/ion*.dat", because then "rm" never asks if you're sure again. whoami: prints your login name. date: prints the date and time set: show what options you have set, the current configuration of stuff setenv: show that for the environment variables (these are more important parameters to have set right, they control a lot of things about the way the computer works.) set