Name: _____________________ Class: CET 421
SSN/ID:   _____________________ Section & Group: ____________
Introduction to Linux


This experiment introduces the student to the Linux operating system. It will cover how to start Linux, log in and log out, open files, examine the GNOME and (if installed) KDE Graphic User Interfaces (GUI), and how to create and manage simple text files. To prepare for this lab, read chapter 1 and be prepared to refer back to this chapter as you work this lab. You will be responsible for this information in future labs.

What is Linux?

Linux is a free Unix-type operating system originally created by Linus Torvalds with the assistance of developers around the world. It is an alternative to other operating systems, like Windows and Mac OS. Linux is not a program like a word processor and is not a set of programs like an office suite.

Starting LINUX

To start a Linux session, you must reboot the lab computer. Perform a normal shut down, except you should select "restart" rather than shut down. When the computer starts, you will see the usual BIOS information, then a blue screen showing the choices of operating system to load. Use the cursor keys, as the mouse isn't loaded yet, to select Linux. You only have a few seconds so act fast. Press ENTER to start the Linux boot process.

Logging in and logging out

After some time passes and Linux displays all the operations it must perform in order to boot, you will see a blue screen asking for your username. The username for everyone is u1. It is case sensitive. Press enter after entering the username. The next screen asks for your password. Everyone has the same password, passu1, which is also case sensitive. Press Enter. The system will boot to the GNOME GUI.

Once you log in, you will see something similar to the following image.



When you are ready to leave Linux, left click on the Red Hat symbol , which is the main menu. Select Log out from the menu, then choose restart the computer. Press Enter. Linux will shut down, the computer will start again, and you get the boot loader screen again. If you do nothing, it will default to Windows and it will then start the Win2K operating system.

Getting a Shell and editing a file

The C++ language requires a clean text format for its source code. Word processors should not normally be used unless you can save your job as plain text. For that reason, it is highly recommended that you use "Emacs", the standard Linux full screen text editor. The older VI editor is not recommended due to its complexity. For old timers, VI is similar to DOS EDLIN, and just as complicated (or worse). Note: for this lab, you can also use GEdit, which is similar to Notepad.

To start gedit the easy way, simply right click in the work space (the big blue empty screen) and click on New Terminal (alternatively, there might be a "Terminal" icon on the menubar that you can click to launch the Terminal). This brings up a kernel shell which allows you to enter commands from the keyboard, just like the good old days BW (before windows).

Type gedit after the prompt and the editor will appear.

In use, it works a lot like notepad, so we won't go into details here. The text shows another way to locate gedit from the menus (in a subsequent lab, we will get intimately familiar with Emacs, our editor of choice).

Type in some text, a few lines will do. Try the edit features, and then, when you are finished, save the file you just created by clicking on SAVE, then enter the file name you wish to call your file in the box at the bottom of the window. Click on OK to save the file. There are other ways to save files in other places, but for now, we will save things in your current directory. Close the editor window to return to the shell.

To examine the contents of your directory, type the command "ls -l" and press ENTER. The list of files in your current directory will appear. By typing ls without the -l option, you get a list but no additional information, like the DOS command dir /w.

Copying a File to somewhere else

The Linux copy command is "cp source file_destination", where source file is the name of the file you wish to copy and destination is where you want it to go. If you created a file named test.txt and you want to copy it to the ZIP drive, you would type: "cp text.txt /mnt/zip" and press ENTER.

Note: Since we always press ENTER to complete commands, I will no longer specifically tell you to press ENTER any more.

You would probably like to see if the file did get copied. You can examine the contents of the zip drive by bringing up the workspace menu again (right click in the empty screen area) then selecting DISKS from the menu. A list of your installed disks appears. Left click on ZIP and a new icon appears on your workspace for the ZIP drive. Double click the ZIP icon, and a window showing the contents of the ZIP disk appears. To examine the contents of the file you copied, double left click on it and a screen appears asking you what to do with it. Since it is a text file, select display, and you can view the file contents. Note the navigation icons at the top of the window. If you push back, then you'll go back to the listing screen.

If you should have Microsoft Word or Excel files on the disk, and you select them, Linux will open its Open Office equivalent and attempt to import the files. It may not be 100% successful, particularly with highly formatted files, but it'll do the best it can.

To save a file directly from gedit to somewhere other than your local home directory, choose save as from the file menu. Double click on the "../" symbol to go up one level. Double click again, and you should be at the root. From there you will see several possibilities. One of these should be mnt/ .

This is where the other drives may be found. Double click on zip/ and the contents of the zip drive are displayed. By clicking on OK you can save your file to the zip drive directly. To navigate back to your home directory, there is a small window just above the file list centered which will show the current directory you are in. Click on the caret symbol at the side to bring up the directory path. The single slash mark is the root directory. You can't go higher than that. Select the root, and then you'll see the selection of sub directories, one being /home. Double click that to see the /u1 directory, double click that and you're back to where you started. After a little practice, it comes pretty easy.

Linux obviously uses names other than A: B:, etc for drives. It takes some getting used to.

Likewise, you can edit a file on the zip drive by starting gedit with the path and file name. For example, you have a file named proj1.c on the zip drive. Open it with gedit by entering the command:

gedit /mnt/zip/proj1.c (Note: spacing is exaggerated for clarity)

Obviously, what applies to the zip also applies to the floppy drive or drives. If you have a floppy handy, give it a try.

Dealing with GNOME and KDE

Now, we will examine GNOME a little bit. Close any open files and shells. The Red Hat symbol is the main menu. Feel free to examine the contents. It's similar to the Windows START function. Examine the games and play one if you wish. We'll relax the no game playing rule this time. It's an educational experience.

When you decide to leave Gnome, you have several options. If you just select log out, you will get a new log in screen. At the bottom are several possibilities. Choose session. If the KDE GUI is loaded, click on it and then log in using KDE. It's similar to GNOME, but also different. You should examine the features of KDE if it's available. After you finish playing with KDE, log out of KDE and log back in to GNOME.

Examine the various features of GNOME until you think you've had enough. You might try to install the weather icon to provide you with local weather. Google has basic information on using GNOME, KDE and the shell. Refer to these pages and attempt as many possibilities as you can in the time you have available. The weather report is in here somewhere, so I leave it to you to look it up.

This completes lab 1. You can see it is basically a self exploration exercise, which you should take the time to complete and be as thorough as possible. We will look at more LINUX in the next lab.

Just for Fun

If you want to try a C++ program, open gedit, and type in the following:

#include <iostream> using namespace std; int main(void) { int age; cout << "How old do you think you are? "; cin >> age; cout << "So you claim to be " << age << ". Sure you are!\n\n"; return 0; } Save the file with any name you like, but be sure it ends with .cpp Example: test.cpp

To compile it, enter the command g++ -o test test.cpp substituting the filename you chose for test.

If there are no other errors reported, run it by typing "./test"

It should work.

(The reason you need to put "./" in front of the program is that Linux thinks all executables are in another directory. "./" tells Linux to run the program from your current directory. Picky, isn't it?)


Ricky J. Sethi <rickys at sethi.org>
Last modified: Tue Mar 22 05:21:37 PST 2005