Menu

Class 1: Introduction


Reading
Read this site: http://catb.org/esr/writings/taoup/html/ch02s01.html for a brief history of Unix. It's taken from Eric S. Raymond's freely available book, The Art of Unix Programming.

Get on the Internet and search for "History of Unix" and "History of Linux" then read, read, read. Notice just how many people are using it.

Homework
Printout the Class 1 Homework and answer the questions on that paper.

What's this class about?
IC221, as you might have guessed from it's course title, is about systems programming. More specifically, we're going to look at the many ways a program receives input and sends output; which in all cases it does via the operating system. This course will be broken up into four distinct parts. They are the basics of using Unix and:
  1. Programs Interacting with the Operating System
  2. Programs Interacting with Other Programs on the System (via the Operating System)
  3. Programs Interacting with Other Programs on Different Systems (via the Operating System and Network)

Since this is a programming course, as you can imagine we'll be doing quite a bit of programming. The language we'll be using is C, with a bit of C++ when possible. Unlike last semester, where you learned about programming on a PC running Windows XP, this course will introduce you to the other operating system powerhouse out there: Unix. To be clear, when I talk about "Unix", I'm actually talking about the many varieties out there, like Solaris (which you'll use this semester), Linux, and Mac OS X.

Why are we learning Unix? Who actually uses it?
Unix might predate operating systems like Windows, but that doesn't mean it's antiquated. Quite the contrary actually; Unix has evolved quite a bit over the years. While Microsoft Windows currently has a significant market share for desktop computers, the same cannot be said for servers.

After you leave the Academy, you'll encounter Unix machines in a variety of different situations. I discussed some of the specifics in class.

They say the best way to learn a language is immersion...
And they're right! During this course, you'll be using an operating system and user environment that you're not used to, and for many of you, it's probably the first time you've ever seen a Unix terminal. Spending time on the machines will certainly help, but if you're up for a little challenge and want to become really comfortable in the Unix environment (and learn a ton), then I would encourage you to take advantage of your privilege as a Computer Science or IT major to dual-boot the Linux operating system on your personal computer. Dual booting allows you to choose which operating system to run when you start the computer. Go ahead and give it a shot! You've got nothing to lose (as long as you back up your data!) and what you gain will be comfort in the environment you'll be expected to use frequently from now until you graduate and beyond.

If you're interested, talk to me or Dr. Crabbe and we'll point you down the path to get you started!

For those not interested in taking the full plunge and installing Linux on their systems, you can download a program called cygwin, which will enable you to connect to our machines in Michelson hall and run programs on them with the display set to your machine. Actually, you can do a whole lot more with it than just that since Cygwin has Windows implementations of many Unix tools and libraries. I gave a short demo in class.

Windows Organization
The general organization of a Windows computer system is a file and directory hierarchy that starts with your hard drive at the top. Each drive has a particular label associated with it. Floppy drives are A:, and hard drives start at C:, and other drives on the system start after that. Does anyone remember what the B: drive is?. Under the hard drive are folders like "Documents and Settings" and "Program Files". Somewhere on the system, you have a folder just for you. Inside of that folder you have things like "My Documents", and "My Music" and a bunch of other stuff. If you're not using your own computer, you always have the ability to do what you want (theoretically) within your own home folder, but you can't, for instance, come to Michelson and install software on our hard drives.

Unix Organization
Unix is organized a little differently, but the concepts are the same--directories are still directories (in Unix we say "directory" not "folder"), and files are still files. Instead of something like "C:" being at the root of my directory structure, Unix uses "/", also called "root". From the user's perspective, Unix simply has files and directories. What physical hard drive they reside on is invisible.

Here are some of the directories present on a Unix system, along with a general description of what's contained in each:

Just like on the PC back in the hall, there's nothing that forces the system administrator to put files in particular locations, but the above scheme is a convention that's generally followed. The "computer organization police" don't beat down your door when you store a music file in the "My Documents" folder instead of the "My Music" folder do they? Different system administrators have different ways of organizing their respective systems. It's the system administrators job to keep the system organized, for two reasons: it's difficult to add or upgrade software if you don't keep track of where everything is and it's hard to use a system if it's not organized.

So...where do all my files go?
Every user on a Unix system has a home directory. This home directory is named the same as the user's login name. All the home directories are located in the /home directory on our system, so if your user name is m001234, then your home directory would be /home/m001234. Your home directory is your own personal "sandbox" where you have unlimited access to create new files and directories, run programs, and organize the contents as you see fit.

Limits of Access
On a Windows system, only the Administrator or users designated with Administrator privileges can do things like install programs, or modify systemwide settings. This concept isn't new--Unix has done it since the 1970s. On a Unix system, there is one user, called root, who has unlimited access to change absolutely everything on a Unix system, including giving some permissions to other users on the system. Of course, more than one person might be able to log in as root, but there is one and only one root account. Everyone else is a user. In fact, the root account is so powerful (and a serious security risk if not controlled properly) that system administrators typically don't log in as root unless they absolutely have to.

You got a demonstration in class of what happens when you try to do something you don't have permission to do. The idea is this: you can mess up the files and directories you have permissions to access, but you can't mess up ones you don't have permissions to access ... and we don't give you access permissions for important stuff!

Paths
In Unix, there's always a notion of "being in" a directory. The directory that you're in at any time is called your working directory. Most of the time, this will be your home directory, or some subdirectory of it, but if you're a system administrator this may not always be the case.

There are two ways of identifying a location within the file system: absolute and relative.

Absolute paths are paths that start with "/", so they reference a location relative to the root directory. For instance, to use our hypothetical user example again, if m001234 was a user and he had a subdirectory called IC221 within his home directory, then the absolute path of that directory would be /home/m001234/IC221. In Windows, this would be like accessing a folder by giving it's location relative to the hard drive letter, so something like C:\Documents and Settings\m001234\IC221.

Relative paths don't start with "/". They reference a directory based on your current working directory. So, for instance, if the user m001234 was in his home directory (i.e. his working directory is his home directory) then he could reference his IC221 directory as IC221.

Special directories
Every directory on a Unix system contains two "special" directories: . (dot) and .. (dot dot).

. references the current directory. This might seem a bit useless right now, but it's actually a big help for us as we'll see in a few classes.

.. references the directory immediately above in the hierarchy.

The directory ~ always refers to your home directory. You can also use it in front of another user's name to reference their home directory. You can reference my home directory from your account as ~wcbrown.

We did a couple of examples in class where I put up a directory hierarchy, and you gave me the paths in both relative and absolute form to a bunch of different places in the hierarchy. During the first lab, you'll see how we actually use paths to get around in the system.


Eric Hardisty
Last modified: Wed Jan 7 14:07:16 EST 2009