BASIC COMMANDS FILES AND DIRECTORIES All information is stored in files. names and COMMANDS commands are case sensitive. Case matters. Files Commands are what you the prompt. Com- are contained in directories. You start out in your mands have arguments on they operate. For own home directory, and your prompt usually tells example, in temp, the command is rm and the ar- its name. At any given , one of these directories gument is temp; this command removes the file called is your working directory, the one you are in. temp. Here I put arguments in UPPER CASE. Thus, You can refer to files in your working directory by words such as FILE are taken to stand for some other just their names. You can refer to a file that is in a word, such as temp. In the following list, I use [ ] for subdirectory by giving a subdirectory name, a slash, optional arguments that are not typicaly used. and the file name, e.g., /baron. You can refer to Commands have options that are controlled with any file on the computer by giving its full name, start- switches, which are usually letters following a single ing with a slash, such as /home7/b/baron/mbox. dash. Usually you can several letters after one dash. For example -l lists files in a long format, If the file is a program, typing its name will run it. with information. ls -a lists all the files, in- (That is what commands do.) If the program is some- cluding those that begin with ., which are usually thing you have just written and is in the director you files used by various programs. ls -al lists all the are in, put ./ before the name. If the file is not a files in the long format. The following list omits program, typing its name will give you an error mes- options. Many programs will give you a list of their sage. If you want to see its contents, for example, you options if you type the name of the program followed must use a command such as “more” before the file by -h or -?. name. Other options are controlled in special files usu- ls [DIRECTORY]: Lists files. (Also try: ls -f, ls -s, ls ally beginning with ., such as .emacs, .mailrc, and -a.) .newsrc. You can edit these. The file .cshrc con- rm FILE: Removes FILE. tains general options, plus aliases that you up more FILE or FILE: View FILE. (? or h for for commands you use often. .) |, the pipe symbol, takes the output of one command DIRECTORY: Change the directory you are in to and gives it to the second command as input, for DIRECTORY. example, ls -l | more allows you to view a long cd: Change to your home directory. file list through “more”. cd ..: Change to the next directory up in the hier- > directs the output to a file, e.g., ls -l > archy. listing.tmp puts the listing into a file named list- DIRECTORY: Make DIRECTORY. ing.tmp. > overwrites an old file of the same name. DIRECTORY: Remove DIRECTORY. >> appends to a file. rm -rf: Recursively remove a directory and anything * stands for any string of letters. For example, ls t* in it. lists all the files beginning with t. FILE1 FILE2: Moves or renames FILE1 to ↑ recalls previous commands, and you can edit these FILE2. commands using emacs editing. FILE1 FILE2: Makes a copy of FILE1, called The tab key completes commands if you type the first FILE2. few letters. FILE1 FILE2 > FILE3: Concatenate FILE1 ctrl-z suspends most programs. fg resumes. ctrl- and FILE2, calling the result FILE3. stops most programs. 644 FILE: Unprotect FILE for others to read abbreviates a series of commands, separated or copy. by semicolons. Useful in .cshrc. chmod 755 FILE: Unprotect program or “script.” chmod 755 DIRECTORY: Unprotect DIRECTORY, GETTING HELP needed for web page directories. KEYWORD: Looks for commands related to and : Print the and bottom of a text KEYWORD. file. man COMMAND: Shows manual pages on COMMAND. This is the authoritative source on the items de- TEXT FILE MANIPULATION scribed here. The commands can do much more These commands operate on files. The output goes than is listed here. to the “standard output,” which is your terminal dis- whatis COMMAND: Tells what COMMAND does. play. If you want to “redirect” the output to a file, use > FILENAME at the end of the command (with elm psych-general@psych to post to FILENAME being the name of the file). Use >> instead upenn.psych.general.) of > if you want to append to the file rather than lynx [URL]: Reads web pages as text files. write it from scratch. ssh : Connects to a remote computer. : the differences between two text files. USERNAME: Allows you to talk with someone LETTER-STRING FILE1 [> FILE2]: Prints (or logged on. The full username must be specified puts in FILE2) all lines of FILE1 that contain for remote computers, and you must use ntalk LETTER-STRING. Use the - switch to get lines instead of talk. It is not a good idea to use this not containing the string. casually unless you know that the other person will s/STRING1/STRING2/g: replace STRING1 with not be annoyed. STRING2 throughout a file. See also the y switch for replacing characters. TRANSFERRING FILES -d" " -f2 FILE: Extract the second column Many computers on the internet have ftp or ssh, but from a file, where the columns are delimited by all of the programs for transferring files depend on spaces. Use to put such cuttings back to- having the relevant software on both computers. gether. ftp and scp: Fast way of uploading and down- FILE: Sort the lines alphabetically. loading, or moving any file from one com- FILE: Remove adjacent duplicate lines. Typi- puter to another. For example, scp myfile cally used with the output of sort, e.g., sort FILE [email protected]: - you need the colon | uniq. Use the -c to count the number of ad- at the end. jacent examples of each line. rsync: synchronize files or directories on two differ- FILE: Count characters, words, and lines. ent computers. Good for backing up.

WHAT’S GOING ON? EDITING [USER]: is using the computer. This is useful pico FILE or emacs FILE xemacs FILE or FILE: to see whether you are logged on twice. (See and Edit FILE. One of these editors may be specified , below, in case this happens.) Also try who and as the default for mailing and news programs. Pico finger. is easiest because it has all the commands listed at finger USER: Gives information about the user, in- the bottom of the screen, but it is the least useful cluding the files .project and .plan, if you have because it has few commands. these files. You can sometimes use this for people on other computers. You can keep useful infor- COMPRESSING, ENCRYPTING, and SE- mation in your .plan, such as your schedule, your CURITY phone number, etc. cvf FILE.tar and tar xvf FILE.tar: Create quota -v: Tells you how much of your quota for files and extract an archive file. Useful for backing up is used up. directories. On xvfz will extract and unzip ps -fu USERNAME: Lists the processes that you are in one step. running, if you put in your username. You can use FILE: Reduce the size of files for storage. use this to find the number of processes that you want gunzip FILE to unzip them. Files “zipped” with to kill, such as those left over when you did not gzip have the suffix .gz. < > log out properly. It is the first number listed. crypt FILE1 FILE2: Encrypts or decodes kill PROCESS-NUMBER: Kills the process you don’t file1 so that you need a password to read it. But if want. If this doesn’t work, try kill -9 you want to be absolutely sure beyond any doubt PROCESS-NUMBER. that nobody will read your files, do not leave them last -22: Shows you the last 22 users who logged on cattell. > in. antiword FILE1 FILE2: Decodes a Word file into text. (That is all most of them are.) Save THE INTERNET storage space. You can use this with Mutt or Elm mutt and elm: Read and write electronic mail. Each to read doc files sent in email messages. has its own “help”. See the discussion of these in : Change your password. the psychology web page computer section. Jon Baron, September, 2003 slrn and tin: Read news (and respond to postings). Pnews: Post to newsgroups. (You can also say mutt psych-general@psych or