CPSC 120 Principles of Computer Science Using Multimedia Design Fall 2008

Lab 1: Introduction to Linux

Introduction

An operating system is the basic software that runs the computer - it controls the hardware of the computer (such as disks and memory) and runs application software (like word processing programs and web browsers). It is the first thing loaded when the computer starts up.

Most of you are familiar with one or more of the Microsoft Windows operating systems (Windows XP and Windows Vista are the most recent versions). You may also have used a Macintosh, which uses the Mac OS X operating system. The Math/CS Department at HWS uses an operating system called Linux on its computers. Linux is a version of Unix, an operating system often used for servers and in academic environments. It is also an ideal operating system for computer programmers. This lab is designed to introduce you to the Linux environment at HWS.

This lab contains a lot of useful information, and has some specific tasks to accomplish mixed in. These tasks are marked with a checkmark icon (shown on the right) to help you find them. However, you'll get a lot more out of the lab if you read through it in order instead of just skipping to the checkmarks.

Much of this lab was originally written by Professors Eck, Orr, and Bridgeman.

Starting Linux

The Math/CS Department has a computer lab in Lansing 310 with 12 computers running Linux and Mac OS X, although most of the time they will be running Linux. You can use these computers to work on assignments outside of lab.

Gulick 208 has 31 computers configured to run both Windows XP and Linux. Only one operating system can control the computer at a time, so these computers are configured as dual-boot machines. When you sit down at one of these computers, it will probably be running Windows. To start Linux, reboot the computer by pressing ctrl-alt-delete to get the Windows login screen, then click the "Shutdown" button on the screen. Make sure that "Restart" is selected in the dialog box that appears, and click "OK". A message indicating that "Windows is shutting down" will appear, and the machine will reboot. Wait a little while, and eventually you will see a screen with the IBM ThinkCentre logo on it, immediately followed by a menu which allows you to choose "Microsoft Windows XP Professional" or "Kubuntu Linux". Use the down arrow key to select "Kubuntu Linux" (quickly - you only have 30 seconds to do it) and press the "Enter" key. Wait some more, and eventually you will get the Linux login screen.

You can also use your own computer to work on assignments outside of lab. If you have a Windows or Apple computer, you'll need to install a free program called VNC which will allow you to connect to a computer in the Lansing lab. See the "VNC" section of Professor Eck's Using Linux at HWS document for information on how to obtain and use the software.

Regardless of how you start Linux - by sitting down in front of a computer in Lansing 310, by rebooting a computer in Gulick 208, or by using VNC to connect - you should now have a login screen where you can enter your username and password.

Logging In and the KDE Desktop

Go ahead and log in - enter your username and password. Do not make any other modifications or selections on the login screen (for example, the "session type" should be set to KDE). Your username is the same as it is for Windows login (but be sure to type it entirely in lowercase letters). Your password should have been provided to you (see the instructor if you do not know your password) - it will be different from your Windows password! (You'll have a chance to change your password to something easier to remember a bit later.) Press "Return" or click the "Go" button, and wait while KDE starts up. This can take a while, especially the first time you log in.

Eventually, the KDE Desktop will appear. If this is your first time logging in, it will may take 5 or 10 minutes to appear (if it isn't your first time, then it should appear fairly quickly). Also, if it is your first time logging in, a "KPersonalizer" window will pop up to allow you to configure your desktop. Click "skip wizard" for now. KPersonalizer will then ask you again if you want to quit. Click quit (ignore the error message about losing any changes). You should then see your desktop screen (the background image is blue with a gray menu bar at the bottom of the screen).

The KDE Desktop is similar in function to the desktop in Microsoft Windows, and you'll notice a number of common features. For now, move on to the rest of the lab (you'll have a chance to explore KDE more in a bit).

Logging Out and Shutting Down

When you are done working for the day or are going to be away from the computer for a while, you need to be sure to log out - if you don't, anyone who comes along will have access to your account and all your files! To log out, click on the KDE head/start menu in the lower left corner of the screen (the icon you are looking for is shown on the right) and look for "Logout ..." option at the very bottom of the menu that pops up. If you are in Lansing or using VNC, just choose "logout" in the window that pops up. If you are in Gulick, you also need to reboot the computer - choose the "Restart Computer" option in the dialog box that pops up and click "OK". The computer will automatically reboot to Windows, so you don't need to wait around for it to finish.


The remainder of this lab (if you are reading it on paper) is available online at http://math.hws.edu/mcorliss/teaching/fall08/cs120/labs/lab01. (You can also find this lab, and all of the other labs for the course, on the lab schedule page at http://math.hws.edu/mcorliss/teaching/fall08/cs120/lab_schedule.html.)

You can run KDE's web browser (Konqueror) by clicking on its icon (shown on the right) in the panel at the bottom of the screen (note: it is the upper lefthand icon in a 2x2 group of small icons) or you can click on the KDE menu (the blue "K" in the bottom left corner of the screen) and choose "Internet", then "Web Browser", then either "Konqueror" or one of the other choices.

To save paper, the remainder of the lab is online. If you are reading this on paper, then you will need to open the web browser and goto the address: http://math.hws.edu/mcorliss/teaching/fall08/cs120/labs/lab01/.


Getting Around in KDE

As mentioned above, KDE looks a lot like Windows and you should use what you know about Windows to help you use KDE. Although your desktop is initially empty, you can place files, folders, and shortcut icons on it just as in Windows (in fact, we will do this later in the lab). At the bottom of the desktop is the panel, which provides the KDE menu, icons for launching certain common programs, and access to minimized windows (very much like the panel in Windows).

On the far left side of the panel is a blue KDE icon - this is the KDE menu, which is just like the Start menu in Windows. To the right of the KDE icon are a collection of icons that can be used to quickly launch various programs. If you move your mouse over these icons then a message will pop up telling you about the program.

There are three others part of the panel to notice. In the middle of the panel (taking up most of the panel), you will see an area like the following:

This area of the panel shows a tab for each window that has been opened on the desktop. Clicking a tab will bring a window to the front (and restore it if it has been minimized).

Further right on the panel (just right of the previous area and left of the icons and clock) is the "pager", which looks like the following:

The "pager" lets you choose between several "virtual desktops" (two virtual desktops by default, although this can be changed). Clicking on the pager lets you switch between them. Multiple desktops can be useful for organizing your work if you have lots of windows open at once.

Finally, on the far right of the panel is the trash can, which is pictured below.

Use this trashcan just like you would in Windows. You can drag and drop any files into the trash in order to delete them. To empty the trash, click on it and select "Empty Trash Bin".

Take some time to explore KDE - explore the menus, open some windows, try a few games, try clicking and right-clicking on some things. KDE has tooltips, so if you move the mouse pointer over an icon and leave it for a moment, a little message describing the icon will pop up. This is very useful for exploring a new environment. Note: by default, KDE is a one-click environment, so you only need to click once on an icon to start a program. If you forget and double-click on something, you will get two copies of the same program running at once. You can change this behavior if it annoys you.

Choosing "System Settings" from the KDE menu lets you configure many of KDE's options, such as the single-click behavior. It's worth exploring what the options are, even if you don't want to change anything right away.

Konqueror

The application Konqueror (i.e., the web browser you are using to view this page) has many uses. It can be used to view web pages such as this one. It can also be used to navigate through folders and to open files. In this way, it is similar to the Explorer in Windows and the Finder in Macintosh. Throughout the semester, you will use Konqueror in both ways. You will use Konqueror to view the course web pages as well as the web pages that you write in the labs. You will also use Konqueror to navigate to various folders, create new folders, and to move files around.

Click on the "location" menu at the upper, left of the Konqueror window. Select "New Window" to open a second window (alternatively, you can select "New Tab" to open it as a second tab within the first window). You will use this new window to navigate and manipulate your files and folders. Click on the home icon (shown on the right), this will display your initial files and folders.

Learning More

If you are new to Linux or new to the HWS environment, you should check out the website Using Linux at HWS written by Professor Eck. Pay particular attention to the "Limits" and "Emergencies" sections.

You can find out more about Kbuntu Linux and KDE by clicking on the KDE menu and clicking on "help".


Changing Your Password

The first thing you should do is change your password to something only you know, and which is easier to remember than the random one you were assigned. You can use the same password as you use for Windows login if you want.

To change your password click on the blue KDE menu icon (pictured on the right) in the lower lefthand corner.

Select the "System Settings" from the menu. System Settings is similar to the Control Panel in Windows and System Preferences in Mac OS X. You can configure many different system properties in this window (some only if you are an administrator, which you are not). To change your password select "About Me" underneath the "Personal" settings. You will then see a page that will let you add information about yourself. Skip over that for now, and click on the button that says "Change Password".

This will open a window that will allow you to change your password. You will be prompted for your current password (the one you were given), and then your new password (whatever you want). Your password won't be shown on the screen, so type carefully. You'll be asked to enter the new password twice as a precaution against typos. You can use any characters except spaces in your password - you should avoid real words (including real words spelled backwards), and use a mix of letters and non-letters. Also, your password is case-sensitive, so make sure the "Caps Lock" key isn't on (unless you mean for it to be). If your password was successfully changed, you should see a window pop up with the message "You're password has been changed" on it.

System Settings

System Settings can be used to change more than just your password. It can also be used to change your desktop, set your screen saver, etc. You should browse around and see if you can customize your desktop.

We will use System Settings to make one last (rather complicated) change to your preferences. We're going to make Konqueror the default file manager application. This change is more complicated than changing your password, so make sure you follow along closely.

To begin, click "Overview" near the top, underneath, "File". This will bring you back to the main menu. Then click on "Default Applications". In the panel that is displayed, you will see two large icons on the far left: one that says "Default Applications" and one that says "File Associations". Click on the icon that says "File Associations". To the right of these icons, there is a panel that will allow you to "configure file associations". Within this panel, select "inode". Several choices will appear, below inode and you should select "directory" from this list. On the far right of the panel, underneath "Application Preference Order" select "Konqueror". The System Settings window should then look as follows:

Once you have "Konqueror" selected, click on the "Move Up" button. It should then appear above "Dolphin". Click on the "Apply" button in the lower right hand corner of the window and then you are done. (Konqueror is now the default file manager application instead of Dolphin.) If you are done with System Settings (i.e., you don't want to do any more customization) then close it by clicking on the X at the upper righthand corner of the window.

Navigating Directories

Linux Directory Structure

As in any operating system, files in Linux are organized into "folders", which are often called "directories" in Linux. Each folder can contain files and/or subfolders, which in turn contain files and/or subfolders. The picture on the right shows part of a directory organization. The folders such as classes and mcorliss have a picture of a folder along side them. Ordinary files such as kjes and index.html do not. The contents of a folder are indicated via the arrows. An arrow from one folder, A, to another file or folder, B, indicates that B is contained within the folder A. It's important to emphasize that this is only part of the organization, there are many folders and files not shown.

The directory structure is often represented by a hierarchy; the top (unnamed) folder is known as the "root folder" or "root directory". This folder appears at the top of the picture on the right. All other files and folders are contained, either directly or indirectly, within the root folder. In other words, we can follow the arrows from the root folder and reach any other file or folder. For example, the file kjes is within the folder cs120, which is within the folder cs120, which is within the folder f08, which is within the folder classes, which is within the root folder. Note: two files and/or folders can have the same name so long as they are not within the exact same folder. For example, there are two folders with the name cs120, but this is alright, since they reside in different locations.

It is sometimes useful to textually refer to the location of an item (i.e., a file or folder). The representation varies from operating system to operating system, but in Linux, we use the following the technique. We concatenate the name of each folder from the root folder to the folder containing the item. After each folder, we insert the character '/'. This is known as the path to the item. Finally, we concatenate to this string, the name of the item. For example, the textual representation of the location of kjes is /classes/f08/cs120/kjes. There are two cs120 folders and each has a separate, unique text-based location. The first is /classes/f08/cs120 and the second is /afs/.afs.hws.edu/home/mcorliss/handin/cs120.

Files

As in Windows, there are many different types of files. There are files that contain simple text; files that contain the code for a web page; files that contain a program, which you can run; and many others.

The type of file is usually indicated in the file's name. For example, a file ending in ".doc" contains a Word document on a Windows machine. In the picture of the directory structure above, essay.txt contains simple text because it ends with ".txt" and index.html contains web page code because it ends with ".html" (HTML is the language web pages are written in). In general, file names consist of a base name, followed by ".", followed by an extension. The extension ("txt", "html", "doc") specifies the type of file. The base name, of course, is a meaningful name that was specified by the creator of the file. For example, essay in essay.txt indicates that the file contains an essay.

Not all files have extensions. For example, the file kjes in the picture above does not have an extension. In Linux, a file without an extension usually (but not always) indicates that the file contains a program that can be run. kjes is a program we will use to write (Python) programs later in the semester.

Home Folder

You have a "home folder" (or in Linux terminology a "home directory"), which contains your personal files. When you click on the home icon in Konqueror (as you did earlier) this takes you to your home folder. My home folder is shown in the picture of the directory structure above. It is the folder named mcorliss (/afs/.afs.hws.edu/home/mcorliss). Your home folder will be contained within the same folder as mine (/afs/.afs.hws.edu/home), but it will of course not be named mcorliss. Instead, it will have the same name as the user name that you used to log in to this machine. In this course, you will almost always work within your home folder.

Changing Folders

To change folders, you can click on a folder icon as you would in Windows or Macintosh. Click on the Konqueror window that is displaying your home folder and click on the "Desktop" folder. This takes you into the Desktop folder and you can see the contents of that folder. This folder contains the files and folders that are located (and visible) on your desktop.

As in a web browser, you can use the back button (it looks like a left arrow near the upper left of the Konqueror window) to move to a previously viewed page. Use this button to go back to your home folder. Likewise, the forward button (it looks like a right arrow near the upper left of the Konqueror window) to move back to the Desktop folder. You will also notice an up arrow next to the forward and back buttons. This allows you to go the parent folder (the folder that contains the current folder).

Working with Folders and Files

Creating Folders

Folders are important for keeping your work organized. You can create new folders by right clicking (clicking on the right mouse button) within the Konqueror panel that is displaying the contents of the current folder. Be careful though not to right click on any particular file or folder. After right clicking, a menu will appear on the screen near where your mouse is currently located with several options for manipulating the current folder. To create a new subfolder within the current folder, you would then click "Create New" and select "Folder...". Another window will appear that will allow you to name your new folder. Once you type in a name and click OK, the new folder will be created within the current folder (it might take a second or two).

Go to your home folder and try creating a folder named "test". Once you have created this folder, move into it by clicking on it. Then move back to your home folder by using the back button. You should now see the contents of your home folder, which should also contain the folder test.

Creating Files

Creating a file is similar to creating a folder. To create a file, right click somewhere on the panel displaying the contents of the current folder (without putting mouse over any particular file or folder). Select the "Create New" submenu and then click "Text file...". A window will appear, which will allow you to type in the name of the file. Type in test2.txt and click OK.

Deleting Files and Folders

Sometimes you will need to delete a file or folder. To do this, navigate to the folder containing the file or folder you want to delete. Then you can drag the item that you want to delete to the trash can. Alternatively, you right click with the mouse over the item This will bring up a menu with options for manipulating that particular folder or file. To delete it, select "Move To Trash". With either approach (dragging or right clicking), this will bring up a screen asking you if are sure you want to delete this item. Click "Trash" to delete it. You can recover this folder, by clicking on the trash can in the lower right of the screen. To permanently remove the files and folders in the trash, click on the trash and select "Empty Trash Bin".

Try deleting the folder test, which you created above.


Moving and Copying Files and Folders

There are also two ways to move or copy files. First, you can simply drag the file or folder that you want to move or copy. If you want to put it on your desktop, then you would drag the file or folder to the desktop. When you release the mouse, you will be given several options to either copy it, move it, link it, or cancel the action (linking is discussed below). If you want to move the file or folder to somewhere besides the desktop, then you may need to open a second Konqueror window, go to the target location, and drag the item from the first Konqueror window to the second.

You can also move and copy files and folders via the right clicking. To move a file, you can right click on that file and select "cut". Then you can move to the destination (some other folder), right click somewhere within that folder (but not on any particular file or folder) and select "paste". Copying a file is similar to moving a file except you should select "copy" rather than "cut". Folders are moved and copied in the same way as files.

Move to your home folder, if you are not already there. Then create a folder called test in the current folder (which should be your home folder). Then copy this folder to the desktop. After you finish, remove both test folders.

Renaming Files and Folders

To rename a file or folder, right click on the item you want to rename and select "Rename". Then type in the new name of the file. Make sure you use the appropriate extension (e.g., ".html" with HTML files, ".txt" with text files, ".doc" word documents, etc.).

Move into the home folder, if you are not already there. Rename the file test2.txt, which you created above, to test3.txt.

Linking Files and Folders

It is sometimes useful to create a link or what is called a shortcut in Windows. A link is a reference to a file or folder that actually resides in a different location. In fact, we will create some links below that you will use throughout the semester.

First, you will create a link to a folder a where you will do most of your work. This folder will actually reside in my home folder so that I will be able to grade your assignments. To create this link, go to my home folder by typing /afs/.afs.hws.edu/home/mcorliss into the location bar (the bar where you type in web addresses when you are using Konqueror as a web browser). Note: it will probably be easiest if you just erase your username and type in mine. Once you have typed this in, hit return and you will see the contents of my home folder. Click on the handin folder and then click on the cs120 folder. You should now see a list of folders. There is one folder for everyone in the class. Look for a folder that has the same name as your username -- this will be your working folder. Once you see it, drag it to the desktop and click on "Link Here" (make sure you click on "Link Here" as opposed to "Move Here" or "Copy Here"). As a last step, rename this link on your folder to "cs120" (a better name).

The second link you will need is to the application, which we will use to write (Python) programs throughout this course. To create this link, go to my home folder by typing /classes/f08/cs120/ (make sure you type it correctly -- it won't work if you make a mistake)) and hitting return. You will then see a list of files and folders. Drag the file called kjes (which has a turtle with glasses for an icon) to your desktop and select "Link Here".

Let's now make sure you were successful. Try clicking on the cs120 folder on your desktop. This should open a window displaying the contents of the cs120 folder. You should see a folder called lab01 (which is empty). If not, then you probably made a mistake. When you are done, you can close the window by clicking on the X at the upper righthand corner of the window. Now try clicking on the kjes program and seeing if it will run properly. You should see a few windows appear. One will be a "Welcome to JES" window. Click on "Ok" within this window. It will disapear and you will then see a "JES Setting" window. You can click, "Cancel" in this window. Finally, you will see a last window, which you can close by clicking the X at the upper right hand corner.

Modifying Files

There are many programs for modifying files in Linux (as with other operating systems). Some are specialized for certain types of files others are designed to work with nearly all types of files. In this course, we will use two programs for modifying files: kjes, which you just opened and ran and a program called Kate. Kate is a general-purpose program for modifying programs. In Linux, such programs are called editors.

In Konqueror, move to your home folder, if you are not already there. Right click on the file test3.txt and select the "Open with" submenu. From the submenu, select "Kate". A new window will appear containing the Kate application, which will allow you to modify your file. Kate is similar to other applications you have used in the past such as Microsoft Word (although it is more general). Type some sample text into Kate and then save it by clicking on the "File" menu at the upperleft of the window, followed by "Save". Then close Kate by clicking on the X in the upper right corner. Finally, remove the file test3.txt (you will not need it again).

Printing

There are many ways to print things in Linux.

One important thing to keep in mind is that by default, any printing command will print to the laser printer in Lansing 310. This is not what you want if you are in Gulick, or are logged in remotely from your own computer. However, you can print to another printer if you know its name. The names for the available printers are:

(Linux can only print to printers it has been configured for, so you can't print to your own printer in your dorm room.)

Most GUI programs provide their own printing functions (usually under the "File" menu). But be careful, some Linux programs do not do a good job of printing. Konqueror (a web browser) is one well-behaved program - the "Print" command is on the "Location" menu, and gives you a drop-down menu to select the printer from. To save paper, you should click on "Properties" near the printer selection and choose to print two pages per sheet. If you choose to print out the lab handouts, you should use this option!

Exercises

Here are the exercises for this week's lab writeup. The writeup is due in lab next Friday (at the start of lab). There are a total of 5 exercises. The first 4 exercises are required, and the last exercise is for extra credit (i.e., it won't hurt your grade if you do not attempt it).

You will write-up your answers to all the exercises except exercise 4 (which must be e-mailed) within one file. Create this file within the lab01 folder within the cs120 link on your desktop. Name it "answers.txt". You can write-up your answers using the application Kate. Make sure you make it clear, which text goes with which exercise. Also, make sure that the text within the file is easy to read and understand.

  1. Answer the questions below, which can be found at the web site: Using Linux at HWS.

    1. If you accidentally delete a file, is there anything you can do to get it back? Explain.
    2. If your computer crashes, why shouldn't you just reboot it? Explain, and list two strategies for fixing problems without rebooting.
  2. Write at least two paragraphs about other things you found while exploring and learning about Linux and/or KDE. You should show that you've made an effort to explore the environment and the available resources beyond the bare minimum that is mentioned in this lab. For example, what interesting things did you find in the KDE menu? What interesting games did you find and play? Did you find the KDE help center? What kind of information does it have?

  3. Explore the KDE menu and look for a non-game, media application (e.g., an application for manipulating pictures). Experiment with the application for a while. Write at least two paragraphs about this application. You should discuss what you liked about the application, what you didn't like about the application, and how it can be improved. In addition, compare and contrast it to an application you have used in the past on a Windows or a Mac.

  4. Send me (corliss@hws.edu) an email telling me the following:
    1. your name
    2. any computer courses you have taken in the past (e.g., high school courses)
    3. your experience with computers (other than programming experience) - this could be using them to write papers, read email, play games, etc
    4. any programming experience you might have had (list languages and what you did) - this includes things like programming calculators
    5. why you are taking this course
    6. are there any particular types of multimedia (pictures, sounds, movies, games, etc.) you are more interested in? are there particular kinds of things you would like to be able to do with multimedia?
  5. For extra credit (i.e., optional) lookup the following people using Google and give a brief biography for each person. In addition, describe their impact on computer science and/or media computation.


Good luck and have fun!


Valid HTML 4.01!