Unix Tutorial


Due February 7, 2006
Those who do not understand Unix are condemned to reinvent it, poorly.
Henry Spencer, University of Toronto
Unix: Some say the learning curve is steep, but you only have to climb it once.
Karl Lehenbauer

1 Introduction

Modern versions of Linux allow an experienced computer user to do normal computing tasks immediately without any additional training, but to begin to harness some of the power of Linux a little work is required. In particular, much of the power of Linux and other variants can be found in their command line interfaces (CLIs). Many current users of Microsoft and Apple operating systems have little experience with CLIs and are only used to graphical user interfaces (GUIs). The purpose of this exercise is to you expose to the Linux CLIs in order to give you the experience necessary to be more productive using Linux and other Unix operating systems in the future. Note that if you find the Unix tools that you will learn about here useful, there are options for available for installing them on your Microsoft Windows computers. MacIntosh OS X users will find that most of the tools mentioned here are already installed on their computers, though they may not be well advertised.

2 Tutorial

The Unix tutorial at http://www.ee.surrey.ac.uk/Teaching/Unix/index.html will be the focus of this exercise. Start at the first section (Typographical Conventions) and work your way through the entire tutorial, other than Tutorial Seven, which you can skip. Make sure that you do all of the exercises listed.

The tutorial is setup for users at another college, but all of the commands in it should work here as well, though the file paths are different. Another thing to note about the tutorial is that it uses the command shell called csh. Here at CSB/SJU we use another shell, tcsh which is based on csh, but has some more advanced features. This should not be a problem because tcsh is more or less a superset of csh, so you should be able to do everything in the tutorial. Note, though that there are other shells that are not as compatible with tcsh. In particular, the most commonly used shell on Linux is bash and bash has many syntax differences from tcsh. If you would like to try a different shell, you can type its name at the command prompt. You can also change your default shell, but I wouldn’t recommend that at this point.

To run through this tutorial you should log into one of the department’s Linux computers. Start up a web browser — Mozilla, Firefox, Konqueror, or any other browser should work fine — and go to the page mentioned above. To run the examples described in the tutorial you will also need to have a terminal window (also known as a command shell) open. There are several types that will work: xterm, konsole, Eterm, and rxvt to name a few.

Before you start working through the exercises type “set history = 1000”. This will save a list of the commands that you typed into that terminal. After you are finished with these exercise type “history | enscript -2r” into that same terminal window. This will send a copy of the history to the printer. Tape this into a lab notebook — it will be a part of your grade for this exercise. Note that for this exercise each group will only need to hand in one notebook. For other labs each member will have to hand in their own notebook. Also, each member of each group should do some of the typing for this exercise, so you should switch off who is in control of the keyboard as you work.

Before you get started let me add a couple more time saving hints. In tcsh (and bash), you can scroll through previous commands that you have typed with the up and down arrow keys. This is a big time saver if you make a typo. Also, Unix (or more accurately the X Windows System which provides the GUI for most Unix systems) has several methods of copy and pasting. The Unix style way of copy and pasting is to select using the left mouse button, then move the pointer to the place you want to paste to, and then click the center mouse button. Try it a little bit. This method would make it quite easy to do this entire assignment without doing any typing, but I suggest you type most of the commands given, since that will make it more likely that you will remember them. Many programs also support the Microsoft Windows style copy and pasting from their ”Edit” menus (also available using Control-C, -V, and -X). Another trick with the middle mouse button involves web browsers. If you middle click on a link in most Unix browsers, the linked page will open in a new tab or window. Also, if you select the text of an URL with the left mouse button, and you paste to a blank spot on web page, the URL will be loaded on the browser.

3 Post-Test

Using the documentation for the ls command, find out how to list full details about all of the files in a directory, listing the files from the newest file to the oldest. (Note: you should only have to use ls, sort will not be needed). Use this command to list the files in the directory “/usr/people/plasma/group_docs”. Save the results to a file, print the file using “enscript -r FILENAME”, and tape the results in your lab notebook.