Using Linux

Tom Kelliher, CS 220

Sept. 14, 2005

The purpose of this lab is to get you up to speed quickly on the basics of Linux -- enough to get started. Becoming a Linux guru requires years of devotion to the ``one true way.'' For more information, refer to the plethora of links on the class home page. I can also give recommendations for Linux books to those interested.

SSH'ing to Kestrel

On the lab machines, look under the Programs menu for the SSH Secure Shell entry and choose Secure Shell Client. Click ``Quick Connect,'' set the host name to kestrel.goucher.edu, fill in your user name, and click ``Connect.'' You will then be asked to enter your password.

To access kestrel from your own computer, you'll need to install an SSH client. Follow the SSH link on my home page for various SSH client options.

Changing your password

The password I've given you is one only a computer could love. Well, it was generated by a computer, so what do you expect? You'll probably want to change it. Use this command from a command prompt: passwd. (Uh, that period ends the sentence, it's not a part of the command. Watch out for this in the following examples, too. OK?)

Editing Files

Three editors are available: pico, vi, and emacs. Pico is the easiest to use. It will remind you of wordpad. It's the least powerful of the three, meaning you'll quickly outgrow it and you will then curse it the rest of your miserable days. Discriminating users use either vi or emacs. The enlightened use emacs. Actually, ``Pish!'' to anyone who uses vi.

Files, Directories and Navigating the Filesystem

You always start out in your home directory when you log in. The command ls is used to list the files in your current directory. ls -l will give you details. The cd command is used to change your current directory. For instance, the web server looks in your public_html directory for web-related files (This refers only to phoenix, not kestrel.). To enter that directory, type cd public_html. System configuration files are in /etc. To go there just type cd /etc. To go back home from anywhere (yes, you can go home again) just type cd.

If you create a web-related file and the web server gives you ``Permission denied'' errors, you'll need to change the access permissions on the file using chmod: chmod go+r <file> (where <file> is replaced with the actual file name, but you already knew that).

To create a new directory, use mkdir <directory_name> Use chmod go+rx <directory_name> to allow others access to a directory you just created. Use rmdir <directory_name> to delete a directory.

Use rm <file> to delete a file. Once a file is deleted, it can't be brought back again, so be careful!

Printing Files

Type lpr <file>, then run to the printer in either HS 149 or the X Lab (the default printing location). If you want to print to your own printer from kestrel first install Linux and then come see me. To print to a specific printer you can use the -P switch:

lpr -P hs149ps <file>
The printer in the X Lab is named hs123ps.

Exercise

  1. Using the mkdir command, create a sub-directory within your home directory for this lab: linux1. It is a good idea to create a new directory each time you start a new assignment or project, so that you don't clutter up your home directory.

  2. cd to ~kelliher/pub/cs240/linuxlab1 and use cp to copy the file addn.spim there to the directory (~/linux1) you just created. Note that after typing the l in linuxlab1, if you press the Tab key, the rest of the directory name is filled-in for you. This is the shell's file completion feature. emacs has a similar feature. You can use the ls command to list the files in my directory.

  3. You should now be in the directory you created. Using lpr, print the file addn.spim.

    Again, if you want to save some walking, you can print to the printer in HS 149 using this command:

       lpr -P hs149ps <fileName>
    

  4. Use less to read through the file you copied. If necessary, see the man page for help on less.

  5. Start SPIM:
       spim
    

  6. Type ? at the SPIM command line to get a list of available commands.

  7. Load addn.spim into SPIM.

  8. Run addn.spim.

  9. Quit SPIM.

  10. Use an editor to modify the prompt strings in addn.spim and re-run the program.

  11. Remember to use logout to log out of kestrel.



Thomas P. Kelliher 2005-09-13
Tom Kelliher