Unix Tutorial


Due January 22/25
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 Unix 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), and the once that are not can be downloaded fairly easily.

2 Account Setup

You will probably find many occasions during this lab when you will want to transfer files back and forth between your Windows and Unix accounts. While there are many ways to do this (including email them to yourself, put them a USB drive, or on a CD), the easiest ways involve transferring the files directly between the accounts involved. To get this to work takes some setup. In this section I will explain how you can get direct access to your Windows files from Linux, and vice-versa.

2.1 Windows File Access from Linux

  1. Setup your M: drive so that it is web accessible (if you haven’t already done so) by going to http://homedir.csbsju.edu/ .
  2. Then you can access your M: Drive from Konqueror (which is both a web browser and a file manager) by opening links of the form:

    webdavs://WINDOWS_USERNAME@homedir.csbsju.edu/homedir/WINDOWS_USERNAME,

    where you should replace WINDOWS_USERNAME with you username. When you attempt to go to that link, you should be prompted for your password. This should allow to to move files between your accounts using Konqueror by using Konqueror as a file manager similar to Microsoft’s Windows Explorer. You can drag and drop files, etc.

  3. Once you have the link working, you should make a bookmark to your M: drive with Konqueror, so that you can easily get back there.
  4. You may also make put a link on your desktop to your M: drive. To do this, first copy the webdavs link from the Konqueror url bar. Next, go to your home directory in Konqueror — clicking on the house icon is an easy way to do this. Then click on the Desktop icon to go to the Desktop directory. Next, right-click on an empty space in the Konqueror window. Then choose “Create New — Link to Location (URL)...” . Next, paste the webdavs link into the “Enter link to location (URL)” box. Then change the “File name:” to “M:drive” (or whatever you would like to call it) and hit enter. A link should show up on you Desktop by the next time you log in.
  5. You can also use any webdavs URL, like the one for your M: drive, with other programs such as cadaver, which is a text-mode file browser.

2.2 Linux File Access from Windows

While these directions are for accessing Linux files from Windows, we are going to set it up using Citrix, a program which lets you run Windows programs from Linux.

  1. Goto http://citrix.csbsju.edu/ and logon using your Windows account info. Or you can use Citrix menu option under the CSBSJU menu on the foot menu. Currently you can only use the Citrix plugin from Mozilla-based browsers (like Firefox and Seamonkey), so you can’t use Konqueror for this part. Note that you must use your Windows username and password for Citrix.
  2. Open up Windows Explorer (not Internet Explorer) from the top-level Applications screen of Citrix.
  3. Under the “Tools” menu of Windows Explorer, click “Map Network Drive”.
  4. On the Map Network Drive Window, pick any unused letter for the Drive: choice (X:, Y:, Z:, etc.) . For the folder, put:

    \\samba.csbsju.edu\YOUR_UNIX_USERNAME

    where you should replace YOUR_UNIX_USERNAME with your Unix username (e.g. abstuden).

  5. Your Linux directory should then show up as a drive under My Computer for Windows Explorer whenever you startup the program. It should also be accessible from other Windows programs.

3 Playing with the GUI

Before we get to learning about the Linux CLI, I would like you to play around a bit with the Linux GUI. Explore the menus. Try out a few programs. Change some of the settings (maybe the wallpaper?). Then pick a game that you have never played before and try it out for a few minutes. Write down the name of the game, how it works, and what score you got (if the game has a score) in your lab notebook.

4 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.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, gnome-terminal, and rxvt to name a few.

For this exercise, you need to keep a record of the commands that you typed. I recommend that you use the script command to do this. After you open a terminal type: script tutorial.txt — where “tutorial.txt” is the file name that your commands will be saved in. If you have to stop this exercise and start it up again you will want to use a different file name the second time, otherwise you will lose your work from the first file.

Note that for this exercise each of you should work on your own. You are free to ask for help from other students, but do the entire tutorial yourself.

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 middle 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. (You can also configure Firefox and Mozilla to act this way on Windows and Mac computers.)

Also, if you get stuck while running a program from the terminal try hitting Control-C, which should exit out of the program. If that does not work, you can also try Control-Z, which suspend the program.

Another useful command is finger. Try: “finger jcrumley” and Try: “finger YOUR_LASTNAME”.

5 Post-Test

After completing the tutorial, do the following tasks:

6 Turning in your work

Hand in your lab notebook when you are done with this exercise.