The operating system we will use in this course is Linux, an open source implementation of the Unix operating system. This handout gives you an overview of a few Linux/Unix concepts.
The Roanoke College Linux Setup: The computers in the second floor Trexler lab are set up to run either Linux or Windows XP - the two operating systems are stored in separate partitions on the hard drives of the computers. Many system files and all student and faculty home directories are stored on a Linux server named cs.roanoke.edu, commonly known as CS.
Booting into Linux: To start up a computer one must go through a process called booting the system. During the boot process, the system checks the hardware on the machine and then loads the operating system -- brings it from auxiliary memory (usually a hard disk) into main memory (RAM). The lab computers are dual boot systems that can load either Windows XP or Linux. During the boot process, the system pauses briefly and displays a graphical menu asking which operating system to load. The default is Windows XP, but you can direct it to load Linux instead. The in-class portion of the lab gives instructions for booting the machines into Linux.
The User Interface: As you recall, your textbook groups the functions of an operating system into two categories: (1) it provides a user interface that allows the user to interact with the machine; (2) it manages the hardware resources of the computer (CPU, memory, storage devices, other auxiliary devices). For the user interface the version of Linux in the labs has a public domain X-Windows system with a desktop managing program called Gnome. This desktop environment is similar to that in Microsoft Windows and Macintosh computers. It is a GUI environment where one interacts primarily by pointing and clicking with a mouse.
An alternative to a GUI interface is a command line interface where one interacts with the operating system by typing in commands. Such interfaces are often favored by programmers because, once you learn the commands, it is faster and more efficient. In UNIX systems, the command line environment is called the shell. Actually the shell is an interface program that interprets operating system commands you type in and executes them (if the command was correct; otherwise you are given an error message). Learning the syntax of basic shell commands is the first task in becoming a skilled user of Linux. In Linux, shell commands are typed into a window called a shell window or a terminal window (also called an xterm).
The Unix File System: From a user's perspective, the operating system function he/she is most aware of (other than the user interface) is that of managing the storage of data on auxiliary memory (typically disk). User data (such as a research paper or a program) and system data (such as password information and the machine code for carrying out operating system commands) are stored in files. (The files are called documents in Windows.) The operating system is responsible for saving files, opening files, deleting files, and letting the user organize the files. In a GUI environment this is done by various combinations of pointing and clicking and dragging and dropping. Files are generally organized in folders or directories. Such an organization is logically a hierarchical, tree structure with one main folder (directory) with other folders inside of that, and each of those may contain other folders and documents. This is the organizational structure of the Unix File system. Most files are either regular (also called ordinary) files or directories. Regular files (usually just called files) contain text, programs, or other data. Directories contain names and addresses of other files and directories. Some special directories are as follows:
A part of the Roanoke College Linux file system may be visualized as follows:
/ | | ----------------------------------------- | | | | | | | | ... etc usr home bin ... | | ---------------------------------------- | | | | | | students staff department | | | | | | ------------------ --------- ------ | | | | | | | | | | | ... jdoe bozo ingram hughes cpsc | | | | | | | | | | --------- --------- ... ... | | | | | | | | | | | ecom public_html cs120 public_html public_html | | | | | | myPage.html | May2005 | | LabQuestions | ecom | | ------------- | | index.html syllabus.html
File NamesIn general, a file can always be referenced either using its full (also called absolute) pathname or a pathname that is relative to the current working directory. An absolute pathname gives the path of the file through the tree starting at the root /. Subdirectories along the path are separated by slashes. A relative pathname gives the path from the current working directory.
Example: Consider the file named myPage.html in the cs120 subdirectory of a student with username bozo (see the diagram above).
The hierarchical file structure used in Unix is similar to that used in Windows XP and the earlier MS-DOS systems. (In fact, MS-DOS borrowed its file structure and many operating system commands from Unix.) One difference however is that Unix does not use the idea of drive letters for physically different disk drives (for example, A for the floppy drive and C for the hard drive). There is only one system with each separate physical drive mounted under some directory. For example, the lab computers actually mount the /home directories from CS (the Linux server), while the rest of the file system is stored locally, but you can't tell this as the user -- it looks like it's all on the same machine. Hence, the one large logical file structure can physically reside on several different computers.
Basic Unix System Commands
The shell commands we will use are those that let you do things such as create directories, change from one directory to another, see a listing of files in a directory, copy files from one directory to another, and print files. Each command has a name (usually fairly short such as mkdir for "make directory") and usually has one or more arguments. For example, to create (make) a directory named myDirectory as a subdirectory of your current directory (where you are now!) you type the following into a terminal window:
mkdir myDirectoryThe name of the directory you want created is the argument. Some of the basic shell commands are summarized in the attached table. Note that in the table the command name is in bold and the arguments are in italics.
File and Directory Permissions
Every file or sub-directory in a directory has a list of permissions assigned to it. Three sets of permissions are assigned: one to the owner of the file, another to the group (users may be put in groups), and the third to all others. These permissions define who has the right to look at ("read"), modify ("write"), or execute that file or directory. Permissions for a particular file or directory are shown as a sequence of 10 characters:
Some examples are
The first example indicates a regular file where the owner has read and
write permissions (the r and w) but not execute permission (the -) and both
the group and all others have only read permission. The second example
indicates a file that is a directory where the owner has read, write and
execute permissions but the group and others have only execute permission.
One can see the permissions on files by using the ls command with the l (the
letter "el") option
ls -l to see permissions for all files in a directory or
ls -l filename to see permissions on a given file).
The Emacs Editor
The Emacs editor can be used to create new files, modify existing files, delete existing files, manage directories, etc. All these files that Emacs can create and modify are plain text files. That is, Emacs is designed to help the user with creating and modifying files that contain nothing but character data. Non-character data such as codes that word processors use to denote boldface or italics cannot be created by a text editor. A text editor basically just lets you create "unprocessed" words!
You will get some practice with Emacs in the in-class portion of the lab.