Unix (Basic Introduction)

(Downloaded/slightly modified by S. Gao from scar.utoronto.ca)

1 What is an operating system?

An operating system is a control program for a computer or in our case, a network of computers. Its purpose is to allocate computer resources and schedule tasks. Computer resources include all the hardware such as the central processing unit (CPU), system memory, disk and tape storage, printers, terminals, modems, and anything else connected to or inside the computer. The operating system provides an interface to the user - it gives the user a way to access the computer resources. It determines how the computer is to operate.

An operating system performs many varied functions almost simultaneously. For example, it keeps track of filenames, where each file is located on the disk, and monitoring every keystroke on each of the terminals. An operating system schedules tasks so that the central processor is working on only one task at a given moment, although the computer may appear to be doing several things at once.

2 What is Unix and why should we use it?

Unix is a multi-user operating system which allows more than one person to use the computer resources at a time. It was originally designed as a time-sharing system to serve several users simultaneous. Unix allows direct communication with the computer via a terminal, hence being very interactive and giving the user direct control over the computer resources. Unix also gives users the ability to share data and programs among one another.

Unix is a generic operating system which takes full advantage of all available hardware such as 32-bit processor chips, expanded memory, and large, fast hard drives. Since Unix is written in a machine-independent language (C/C++) it is portable to many different types of machines including PC's. Therefore, Unix can be adapted to meet special requirements.

3 How do I begin to use the Unix system?

To begin to use Unix, you must "log on" by providing your user-id number or login name followed by your password. For security reasons, each user account has a password that restricts access to that authorized user. Different accounts are setup in Unix as a way of separating the files owned and the programs run by different users.

4 What is my login name?

Your login name is used to differentiate your files and account from other files and accounts on the Unix system. Your login name is the first two digits of your student number followed by the first 6 letters of your surname and given name all in lowercase characters.

Example: Login Name: 89kentcl

Note that Unix is case-sensitive. Ie. 89kentcl is not the same as 89KENTCL or 89KentCl.

5 What is my password?

For newly created accounts your password will simply be your student number. Once inside the Unix system however, you should change your password from this via the passwd command (see Section 7).

6 What is the Unix shell?

Once inside Unix you are confronted with a command interpreter known as the shell. When you enter a command on the command line, the shell interprets the command and calls the program or utility that you want. For instance, if you wish to know today's date and time, you may simply give the command date. If you suddenly forget your identity, simply type the command whoami. The last command that you should finish your Unix sessions with is the logout command which exits you from the system.

If you wanted access to a different server or machine, you could give the command rlogin followed by the server you wish to access. rlogin stands for remote login.

7 How to change my password?

Give the command passwd to the shell prompt. The shell then executes the utility designed to allow a change of password. The first item the passwd utility asks for is your old password. This verification is necessary to disallow any unauthorized users to alter your password. The utility then requests the new password twice (to eliminate any typing errors between the first and second inputs).

8 What are control-commands?

Control commands are those commands which do not require you to press the Enter key for them to execute. Rather they are usually a combination of the Ctrl (Control) key and some other alphabetic character. For example, you can delete the entire line that you are typing before you press Enter by holding down the Ctrl key and then pressing u. This is designated as Ctrl-u. Another useful keystroke is Ctrl-c which aborts a running program. This may prove necessary if a Unix program takes longer than expected to terminate or if you simply ran the wrong process.

9 What is a file?

A file is a collection of information that you can refer to by a unique filename and is usually stored on a disk storage device. If the information contains just ASCII characters or plain text (without any formatting like underline, bold, etc.), the file can be thought of as a text file. An editor, such as Emacs, vi, or Easy-Edit are Unix utility programs designed to create, read, or modify text files. An executable file, one which contains an image, a document with formatting and other files which contain more than just ASCII characters are known as binary files.

A filename can also consist of an extension to help distinguish between the many types of files. For example, a file containing the latest automobile facts and statistics may be called automobile.txt or automobile.facts.and.statistics.

10 What are some useful and common file commands?

At some point, you may want to rename a file to make its function or purpose easier to recall. For example, you may wish to rename the file automobile.txt to automobile.facts.and.statistics. To do this you should use the mv (move) command as follows:

Example: mv automobile.txt automobile.facts.and.statistics

You may find that your directory is becoming cluttered and filled with files whose use is no longer needed. In this case, you may wish to remove or delete them to make more space. To do this you should use the rm (remove) command as follows:

Example: rm junkfile.txt.wasting.space

You may want to make an exact duplicate of file that may be "experimentally" changed. In this case, you would want a copy of the original, unaltered file in case the new modifications were undesirable. To copy a file you should use the cp command as follows:

Example: cp automobile.txt automobile.txt.backup.

Finally, you may want to obtain a hardcopy of a textfile. In this case you must send the file to the line printer with the lpr command as follows:

Example: lpr automobile.txt

To summarize, the syntax of these 4 useful commands are:

copy a file: cp (filename) (new filename)

delete a file: rm (filename)

rename a file: mv (old filename) (new filename)

print a file: lpr (filename)

11 How does Unix organize its files?

The structure by which Unix organizes its files is called a file system. The Unix file system stores files in directories which in turn are arranged under other directories and so on in a tree-like fashion. This structure enables users to effectively organize files by grouping related ones into directories. The Unix file system is similar in concept to the file cabinet where the cabinet represents the main or root directory, the drawers represent subdirectories, the file-folders in the drawers represent further subdirectories, and so on until we reach the actual report which represents our file. Each user has one primary directory (file cabinet) and as many subdirectories as required (drawers and file folders).

A useful command is the ls command which lists all the files in the directory that you are currently in (the current working directory). Typing ls Mail will list all the files in the Mail directory. Three other useful directory/subdirectory commands are cd (change-to directory), rmdir (remove directory), and mkdir (make directory). So, typing

ls directory-name will list all the files in the named directory

cd directory-name will place you in the named directory

mkdir directory-name will create a new subdirectory with the specified name

rmdir directory-name will remove the named subdirectory.

12 What are Unix "man pages"?

Unix provides an on-line help facility in the form of pages from the system documentation. These pages are known as man pages since you use the man (manual) Unix utility to display the them. This documentation can be helpful especially if you know what utility or program you want to use but have forgotten the correct way to use it. To find out more about a utility, type man followed by the name of the utility (Manuals are also available online).

Example: man whoami

gives a helpful but terse description about the utility whoami

13 What is X-Windows?

The X Window System, called X for short, is a network-based graphics window system. One of its main purposes is to provide a more user-friendly environment when working with Unix. In other words, X-Windows turns a text-based environment into a graphical interface where a mouse can be used. X also allows you to work with multiple programs simultaneously, each in separate windows.

Unix allows each user to run more than one job at a time allowing for a switch of attention between jobs. This multitasking ability allows users to be more productive. The X Window System makes it easier to keep track of all your different processes by allowing multiple viewports to your work environment. The windows often overlap much like sheets of paper on a desk or a stack of cards. Note that one of the windows contains the Unix shell awaiting a command.