www.csua.berkeley.edu/~twohey/using_unix.html
The Labs and Your Account On the first day of class you should have been given an account form. If you forget your login name while you are logged in, you can find it by typing: % whoami at the shell prompt. Note that you are not supposed to type the %, it is the shell prompt. Shells and Terminals The UNIX shell is a command line interface similar to DOS, but much more powerful. The UNIX shell is difficult to learn, but once mastered can be made to do almost anything. There are several different UNIX shells, but they all share a similar interface. When you want more than one shell running, launch a new terminal by typing: % xterm & One of the most important tasks the shell performs is launching programs. To launch a program, type its name at the shell prompt, followed by the arguments to the program and then hit enter. To do this you need to go to your log in shell and type: % logout The log in shell is the window named shell . If you have minimized your log in shell it will be a white rectangular box with the word shell in the middle. Emacs and Scheme emacs is a thermonuclear text editor, a program with unlimited potential. Most of the commonly used emacs features are control sequences (C-x) , while the less commonly used features are meta sequences (M-x). C-x is the standard notation for control sequences, it is obtained by pressing the control key and then the x key. On the HP and Solaris computers M-x is obtained by pressing the alt and x keys at the same time. To start the scm scheme interpreter, withing emacs type M-x run-scheme . You will notice that after you type M-x, the text cursor has moved to a separate area at the bottom of the emacs window. This area is called the Mini-Window and is where emacs expects text input for its commands. You can always hit (C-g) to quit out of the Mini-Buffer if you make a mistake. To quit scm, either kill the buffer it is contained in, or type (quit) at the scheme prompt. To open an already existing file, go to the File menu and select Open File (C-x f) and type the name of the file and hit enter. To create a new file, go to the File menu and select Open File (C-x f) and type the name for the new file want the file and hit enter. This can be confusing because creating a new file and opening an existing file use the same interface. To save a file, make sure the cursor is active in a window that is editing the file and select Save Buffer (C-x s) from the File menu. When emacs prompts you if you want to save changes to the buffer, type y and hit enter. To save all open files, use the keyboard shortcut (C-x C-s) . When emacs prompts you if you want to save changes to a particular file, type y and hit enter. If you have more open files than windows, you can select which file you want to view in a window by clicking in the window and then selecting the appropriate file from the Buffers menu. You can switch between buffers in this mode by moving the cursor over the buffer and pressing enter or clicking the mouse. To close a file, select Kill Buffer (C-x k) from the File menu. To quit emacs select Exit Emacs (C-x C-c) from the File menu. When you are in the Mini-Window and have type part of a long meta command or file name, emacs will guess which command you want if you hit the tab key. To split the emacs window with the cursor in it horizontally, select Split Window (C-x 2) from the File menu. To split the emacs window with the cursor in it vertically use the keyboard shortcut (C-x 3). To switch between open windows click in the window you want to make active or use the keyboard shortcut (C-x o). To collapse all the emacs windows into one window, select One Window (C-x 1) from the File menu. Unix Copy and Paste To copy text, hold down the middle mouse button and select the desired text. To paste text, click the middle mouse button where you want the copied text to start. This form of copy and paste works across most UNIX applications. Caveat: Extremely large blocks of text being copied or pasted with the mouse may lose some data. Files and Directories The UNIX file system is organized around files and directories. Your home directory is where you should save your files. Your home directory has a two special names: $HOME and . Forward slashes are used to delineate directories in a path. Files are case sensitive, BOX and box are two different file names. You can specify more than one file with a path by using wild cards. The * wild card matches any number of characters, while the ? When you are working within the shell, it keeps track of the directory you are using. This directory is called the current working directory, or the current directory. To create a new directory named foo, type: % mkdir foo To create a copy of a file foo called bar, type: % cp foo bar To move file bar into directory foo, type: % mv bar foo To remove a file foo, type: % rm foo To remove a directory you must first ensure that the directory does not contain any other files or directories, then type: % rmdir directory When you remove or delete something on a UNIX system it is gone forever. There is no way to recover deleted files, so be careful. To prevent the servers from running out of disk space, your accounts are only allowed to store a limited amount of data. To find out how much room you have left, type: % quota Printing All the printing commands will print to the printer nearest the computer you are logged into unless you tell them otherwise. All the instructional printers in Soda Hall are named after the room they are in. The printer in 330 Soda Hall is called lw330, while the downstairs printer in 274 is called lw274. After you have issued a print command, your print job is put into a queue and printed when all the print jobs before it are done printing. Near homework and project deadlines the queue is often large (over 100 print jobs), so be prepared and print early. When you login to a computer, the default printer is the print to which your print jobs will go if you do not specify another printer. The default printer is usually the printer the is closest to the computer to which you are logged in. Do not ever use enscript on anything other than a text file, it will make the printer spew out random stuff for thirty minuets and it will make everyone behind you in the print queue very angry. Remote Access One of the strengths of the UNIX operating system is that it works well over a network. You can use a Solaris machine in Australia to login to a HPUX computer in Tokyo and use the programs on the HP machine, without having have them on your computer. The best way to log into a remote computer from another UNIX computer is to use the ssh command. It uses strong encryption and is secure against most attacks. You may have heard of other programs like rlogin and telnet. These are insecure, do not use them, it is too easy for a hacker to intercept your password and steal your account. To login to a remote computer named dilbert, type: % ssh dilbert If you have never logged into dilbert before ssh will ask you if you really trust dilbert, you should answer yes . If you want to login to the CS computing facilities from home and use graphical applications you will need X Windows software.
The department provides FSecure for Mac OS, but unless you have an X Server for Mac OS, Nifty Telnet is the better choice. Processes Every time you launch a program, it is given a process id number (PID), this number distinguishes this process from all other running process. To list all the process you have launched from a shell, type: % ps To list all the process you are running on the computer on which a shell is running on, type: % ps -u your-login Occasionally a program crashes or refuses to quit, if this happens you can kill it. To kill a process, type: % kill PID If the kill command didn't kill the process, try again. If the process is still alive, type: % kill -9 PID Be careful when you use kill -9 , it is very powerful and should be used with extreme caution. Web and Email The only decent web browser on UNIX is Netscape Communicator, launch it by typing: % netscape & Netscape Communicator is a good web browser, but it is overkill for...
|