Operating Systems An operating system is the software that controls the computer. When you turn a computer on, the operating system is loaded into memory and basically takes charge providing services to you and to the programs you use. The functions of the operating system fall into two broad categories:
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 as dual boot systems; that is, they can run either Linux or Windows 7. The two operating systems are stored in separate partitions on the hard drives of the computers and the user can choose which to load into memory during the boot process. Many Linux system files and all student and faculty home directories are stored on a Linux server named cs.roanoke.edu, commonly known as CS.
The User Interface: Most computer programs these days provide a Graphical User Interface (GUI) consisting of windows, icons, and menus where the user interacts and gives commands by pointing and clicking. 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 a GUI environment similar to that in Microsoft Windows and Macintosh computers.
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 bouchard cpsc | | | | | | | | | | --------- --------- ... ... | | | | | | | | | | | ecom public_html cs120 public_html public_html | | | | | | Labs | ----------- | | | | | myPage.html | | --------- May2008 UnixQuestions | | | lab0 lab1 | | | | | | ecom LabQuestions | | Hello.java | ------------- | | index.html syllabus.html
File Names
In 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 Hello.java in the lab1 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 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, C for the hard drive or E for the thumb drive (USB key)). 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 Shell 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", cd for "change directory", and cp for "copy") 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
-rw-r--r--
drwx--x--x
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
(type ls -l
to see permissions for all files in a directory or
ls -l filename
to see permissions on a given file).
Review Questions