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 such as Windows XP, Vista, Windows 7, and Windows 8. Some of you may also have used a Macintosh, which uses the MacOS operating system - Snow Leopard, Lion, and Mountain Lion are recent versions. Some of you might even have used Linux, the operating system that the Math/CS Department uses on its computers. Linux is a version of Unix, an operating system often used for servers and in academic environments.
This tutorial will introduce you to the Linux environment at HWS. You'll learn how to start Linux, navigate the desktop, navigate the file system and copy files, use a text editor, and print things. Later labs will introduce the Processing development environment that you'll use for most of the course.
(There are actually many different versions of Linux, known as distributions. HWS uses a version called Linux Mint. All versions of Linux work the same way underneath, but different distributions may look different or be configured differently.)
Don't worry about memorizing all of the details in this handout. Just make a note of what information there is, so that you can come back and look up how to do something when you need to.
Rosenberg 009 has computers configured to run both Windows 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.
Restart the computer by pressing ctrl-alt-delete to get to the Windows login screen, then use the small "power button" menu on the bottom right and select "Restart". (Or, if the computer is off, turn it on.)
As the computer restarts, you will eventually see a screen with a menu that allows you to choose "Windows" or "Linux Mint".
Use the down arrow key to select "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.
If you are working on assignments outside of lab, you can work in Rosenberg 009 (when not in use for classes) or in the Math/CS Department computer lab in Lansing 310. The Math/CS Department lab has 12 dual-boot computers (Linux and Mac OS X) primarily running Linux, so you will generally not need to reboot them.
You can also use your own computer to connect to a Linux machine from your room. If you have a Windows 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. If you have a Macintosh, you can use VNC or ssh (see the "SSH" section of Using Linux at HWS). See me if you need help getting things set up.
Regardless of how you start Linux - by sitting down in front of a computer in Lansing 310, by rebooting a computer in Rosenberg 009, or by using VNC or ssh to connect - you should now have a login screen or prompt where you can enter your username and password.
You will be provided with a username and password in lab. Note that while your username might be the same as your email login, this is a separate account from your HWS network account and has a separate password.
At the Linux login prompt, enter the username and password you were given. (They are case-sensitive, so be careful to get any capitalization correct.) Do not make any other modifications or selections on the login screen.
Wait while the desktop starts up. (This may take a while, especially the first time you log in.) If this is your first time logging in, some windows may pop up displaying information or allowing you to configure your desktop. Close or otherwise dismiss those windows - ask if you get one that you aren't sure about.
You should end up with something like this:
To save paper, the remainder of this lab and all other labs for the course will be only posted online. To view it, you'll need to start a web browser:
Bring up the Applications menu:
Click on the Menu icon - it should be in the bottom left corner of the screen.
On the Applications menu:
Look for the category "Internet" (move the mouse over it), then click on "Firefox Web Browser" to start Firefox.
Once Firefox starts up:
Go to the syllabus page at http://math.hws.edu/lasseter/teaching/S14/cpsc120/index.html. You may want to bookmark this page so you can easily return to it.
Locate the lab 1 link on the syllabus page and click on it.
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:
Bring up the Applications menu.
Click on the sideways "power button" icon (second from the bottom, on the left side of the menu). It will give you a chance to cancel the operation - click "Log Out" to log out immediately. (For now, cancel instead of logging out.)
If you are in Rosenberg, you will also need to reboot the computer back to Windows for other lab users.
On the Linux login screen, look for the icon showing two interlocking gears (the rightmost icon under the "Username" box) - click on it and choose "Restart the computer". (But don't do that now.)
Unlike Windows and MacOS, where the desktop that you interact with is bundled with the rest of the operating system, Linux supports many different desktops with different features and appearances. The desktop used at HWS is called Cinnamon.- google chrome is also available - If you know the name of the application you are looking for but not how it might be categorized, you can look under "All Applications" or type the name of the application in the search box at the top of the menu window.
The Cinnamon Desktop is most similar to the desktop in Microsoft Windows, and you'll notice a number of common features. One such feature is the bar running across the bottom of the screen - Windows calls it the taskbar; Cinnamon calls it the panel.
You've already encountered the Menu icon (on the left side of the panel) and the Applications menu (similar to the Start menu in Windows). You can locate applications by navigating through the appropriate category (like you did to start Firefox), going to "All Applications" and looking for what you want, or by typing the name of the application in the search box at the top of the Applications menu.
There are a number of other icons in the panel. On the left side (near the Applications menu), you may have icons for launching common programs such as Firefox. On the right side, you may find a clock and some icons for controlling settings such as sound volume. If you move your mouse over the icons and wait for a moment, a message will often pop up telling you something about it.
As you start up different programs, the large empty area in the middle of the panel will fill with tabs those running programs. (There should be a tab for Firefox, for example.) As in Windows, you can restore minimized windows or bring up a window that got buried by clicking on the appropriate tab.
On the desktop itself, you may see two icons labeled "Computer" and "home" in the upper left corner - these provide access to your files. (More on that later.)
As with Windows and Mac, much of your interaction with Linux can happen by clicking on icons and menus. However, some tasks require the use of the commandline where you type in the command you want to run. (Much of what you do with icons and menus can also be done via the commandline, but we'll only use it when necessary.) Both Windows and Mac also provide a commandline interface - perhaps you've used it.
The Linux commandline is accessed through a terminal window.
To start a terminal window:
Open the Applications menu, go to the Accessories section, and locate the application called Terminal.
You should change the random password you assigned to something only you know and which is easier for you to remember. You can use the same password as your HWS network account if you want, or something different.
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.
To change your password:
Open a terminal window if there's not already one open.
In the terminal window, type the command passwd and press "Return".
When prompted, enter your current password and then your new password. You'll be prompted for your new password twice to protect against typos. Note that your typing won't be echoed to the screen as you enter your passwords - this is to protect your passwords from someone looking over your shoulder.
If your password was successfully changed, you should see a message to that effect.
As in any operating system, files in Linux are organized into folders (often called directories in Linux). Each folder can contain files and/or subfolders, which in turn contain files and/or subfolders. At the top of this hierarchy is the root folder - all other files and folders are contained, either directly or indirectly, within the root folder. In other words, you can start at the root folder and repeatedly open subfolders to reach any other file or folder.
You can use a program called Nautilus to navigate through your directories and manage files and folders.
To start Nautilus:
Click on the icon on the left side of the Applications menu, or on the "Computer" or "home" icons on the desktop.
You have a home folder (or in Linux terminology a home directory), which contains your personal files. (This is similar to "My Documents" in Windows.)
To go to your home directory:
Click on the item "Home" on the left side of the Nautilus window if Nautilus is already running, or launch Nautilus by clicking on the "home" icon on the desktop.
You should see something like the following: (it may not be exactly the same)
For some special folders, like the root folder and your home folder, you can simply say "the root folder" or "my home folder" and people know what you are talking about. However, for other files or folders, the only way to specify which thing you are talking about is to explain how to find it - and it is useful to have a concise way of writing down this explanation. The exact representation varies from operating system to operating system, but in Linux we concatenate the names of each folder from some starting point to the folder containing the item, putting a slash (/) between each folder name. This is known as the path to the item. For files, the name of the file is appended to the path.
The root folder has a very short path: / (just a slash).
The path for your home directory is /afs/afs.hws.edu/home/username, where username is your actual username, not the word "username". This means that your home directory is in a folder called "home" which is in a folder called "afs.hws.edu" which is in a folder called "afs" which is in the root directory (indicated by the / at the beginning of the path).
There's also a special shortcut that can be used to refer to your own home directory. It's very short: just ~ (a tilde).
A second shortcut can be used to refer to a particular user's home directory: ~bridgeman, for example, refers to the user bridgeman's home directory (i.e. mine). You could also refer to your own by putting your username instead of "bridgeman" (but leave the ~ in there exactly as shown). It would also be fine to use the full path /afs/afs.hws.edu/home/bridgeman instead of ~bridgeman to refer to my home directory.
Note: details matter! ~bridgeman means bridgeman's home directory while ~/bridgeman means the directory called "bridgeman" within your own home directory.
To change directories in Nautilus, you can double-click on a folder icon as you would in Windows or Macintosh. You can back up to a previous folder by clicking on the back arrow in the upper right corner of the Nautilus window, or jump to a particular folder higher in the hierarchy by clicking on its name displayed just above the area showing your files and folders. (Click on the little left-pointing triangle to reveal the full path if needed.) You can also go straight to certain directories by clicking on one of the entries displayed on the left side of the Nautilus window. ("File System" takes you to the root directory.)
One directory that you'll need later on is the handin directory. This is a directory I've set up so that I can access your work for grading.
The handin directory for this course is /afs/afs.hws.edu/classes/cs120.
In Nautilus, navigate to the handin directory. Use what you've learned about textual path names and navigating directories to get there.
Inside the handin directory, you'll find a folder labelled with your last name. That's your own personal handin folder, and that's where you'll copy your files when you are ready to hand things in.
Navigate back to your home directory. (See if you can do this in just one step!)
To keep things organized, you should create a directory to hold the files you'll create for this course.
Navigate to your home folder in Nautilus if you aren't already there.
Choose File->Create New Folder from the menubar in Nautilus, or right-click in the background of the Nautilus window and choose Create New Folder. (Be careful not to right click on any particular file or folder.)
This will create a new folder called "Untitled Folder", with the folder name highlighted and ready for editing.
Rename the "Utitled Folder" to cs120 (exactly as shown - use lowercase for "cs").
Note that unlike Windows, Linux is case-sensitive so cs120 and CS120 are two different directories. You should be careful to observe the case of things when typing in names.
Since you created the cs120 directory in your home directory, its path would be /afs/afs.hws.edu/home/username/cs120 (again, with your own username in there instead of "username"). Or you could use the first shortcut (~/cs120) or the second shortcut (~username/cs120 - with your own username, of course).
It's also a good idea to have a separate directory for each lab or project.
Navigate to your cs120 directory and create a new directory named lab0.
You can select files and folders like you do in Windows - click on a file or folder to select just that item, or click on a file or folder and then shift-click on another file or folder to select the range of items between the two, or click on a file or folder and then ctrl-click on others to include them, or click in the background of the Nautilus window and drag to select all of the files/folders in a region.
Sometimes you will need to delete a file or folder. You have two options: delete (making the item gone for good) or moving it to the trash (where you can delete it for good or restore it to its original location).
To delete file(s) and/or folder(s):
Select the desired item(s) in Nautilus.
Either go to the Edit menu or right-click on one of the selected items and choose Move To Trash or Delete.
The trash can be accessed via the list on the left side of Nautilus window if you want to restore an item or empty the trash.
Give it a try:
Create a new directory called test inside your lab0 directory.
To move files and folders from one place to another, you can open two Nautilus windows, navigate to the folder containing what you want to move in one and the target location in the other, and drag the file(s)/folder(s) from one window to the other.
You can also select, cut or copy, navigate to the target folder, and paste to move or copy files. Access cut/copy and paste through the Edit menu or by right-clicking on a selected item (cut/copy) or in the background of the Nautilus window (paste).
Give it a try:
Create a new directory called test2 inside your home directory.
Move test2 into your lab0 directory. (Note that is it no longer present in your home directory.)
Delete the test2 directory.
To rename a file or folder, right click on the item you want to rename and select "Rename..." or select the item and choose "Rename..." from the Edit menu. Then type in the new name of the file. Make sure you include the appropriate extension (e.g., ".html" with HTML files, ".txt" with text files, ".doc" word documents, etc.).
Most of the time you will be creating and editing files within the Processing environment. Sometimes, though, you'll need to create other kinds of files (such as text files). Linux provides several text editors suitable for working with text files, but I recommend using gedit.
To start gedit:
Open the Applications menu, go to the Accessories section, and locate the application called gedit. (Or type gedit in the search box at the top of the Applications menu.)
There are a few exercises at the end of the lab handout that ask you to write up your answers. While you don't have any answers yet, you can get started by creating a file with your name, the date, and the name of the lab.
In the main (empty) area in gedit, type something like the following:
Arthur Dent Lab 1, 1/25/13
(Use your own name of course.)
Save the file by clicking on Save in the toolbar or choosing "Save" from the File menu. The first time you save a file, you are prompted for where you want to save it and what you want to name the file. Name the file lab0-writeup.txt and make sure to save it in your lab0 folder. (You'll probably need to navigate to the right folder before clicking "Save".) Remember that Linux is case-sensitive, so pay attention to the capitalization (or lack thereof) in the filename.
For readability, please keep each line of the file to 80 characters or less. (This is the amount of text that fits on one line when the file is printed.) It's easy to forget to do this because gedit will automatically wrap long lines when you get to the edge of the window - but this is just a display thing, and doesn't insert line breaks into the file.
To edit an existing file, you can either use Nautilus to navigate to the folder that contains it, right-click on the file, and choose "Open With Text Editor" (at the very top of the menu) or you can start gedit and choose "Open" from the File menu.
You will be handing in your labs and projects electronically so you do not need to print your files for handin. Try this now to make sure you understand the process.
To hand in your files:
Copy your lab0 directory into your handin folder. (Recall that your own handin folder is the one with your name on it inside /afs/afs.hws.edu/classes/cs120.) This means you'll want to choose the lab0 directory itself (not the files in it) as the thing to copy to your handin folder.
Check that it worked by navigating to your handin folder and verifying that it contains a folder called lab0 and that the lab0 folder contains a file called lab0-writeup.txt.
You will be handing in your labs and projects electronically so you do not need to print your files for handin. However, it is still sometimes useful to print something out.
Most GUI programs provide their own printing functions (usually under the "File" menu), though not all Linux programs are well-behaved about printing. If you choose to print out the lab handouts, please save paper by going to the "Page Setup" tab (after choosing "Print" in Firefox) and set "Pages per side" to 2. (A similar option is available in other programs besides Firefox - it's worth looking for.)
When you go to print, you will see a list of available printers. You should use only cslab (in Lansing 310), ros009 (in Rosenberg 009), or libmul (in the Library Multimedia Lab). Do not use faclw or mfd - these are for faculty use only. Note that Linux can only print to printers it has been configured for, so you can't print to your own printer in your dorm room.