Unix

Ken Thompson and Dennis Richie started working on UnixTM in 1969. The first edition of Unix was completed in 1971, which was used for text processing of patent documents. Fourth edition of Unix was released in 1973. This was written in C programming language, and from then on, Unix has become portable across different hardware platforms. History of Unix and other interesting facts are available form unix.org.

Before one learns Unix, it is probably better to understand a little bit about Unix philosophy. Unix is open source, flexible, scalable, portable, stable, secure and based on open standards. In Unix, programs are often designed to do one simple thing right. Unix provides ways for interconnecting these simple programs to work together and perform more complex tasks.Popularity of Unix systems only increased when Linus Torvalds created a Unix type operating system called Linux that can run on Intel® based personal computers. Today, while Microsoft® holds large share of PC operating systems, the Unix/Linux systems lead the server market. Linux costs less, and often are free. However, users still need to learn to adapt to the new environment. With Windows like GUI and initiatives like Open Office, Linux based systems are becoming increasingly popular.

Interfaces

Command Line interface is a simple text only interface. Users can type Unix commands, and the Unix shell reads and interprets these commands. For example if you want to see the files in a folder, you type ls and the shell lists the files. Those who are used to GUI, working with command line interface may find a little daunting. However, once mastered, a command line interface is easy to use, flexible, and very powerful. If you want to get close to the operating system, command line interface is probably the best.

A number of Graphical User Interfaces are also available,including IDEs.

Common Unix Commands

Many Unix commands are shell specific. However, there are many commands that are common. They are discussed here. Note that Unix commands are case sensitive. To get help on using any of the commands, you may type man command-name. Of course,if you need help on using manual pages, you can type man man. Manual pages are not recommended for beginners. Here is one basic Unix tutorial.



Unix CommandDescriptionEquivalent
DOS Command
ls List files dir
cp Make another copy of a file copy
rm Remove a file del
cd Change Directory cd
mkdir Make Directory md
rm Remove a directory rmdir
man Manual Pages help

Creating Files

For creating files in Unix, a number of text editors are available. Examples are: vi, emacs, and pico. If you are a novice user, you may find pico easier to use.

To use pico, type:

                pico myfile.txt
                

where, myfile.txt is the name of the file you want to create. Click here for a tutorial.

Vi Editor

Vi stands for visual editor. To edit/create a file in Vi editor, from the Unix (shell) prompt, type vi filename. Vi editor has two modes, namely, command mode and text entry mode. Vi normally starts up in command mode. The following keys are understood in the command mode.

  1. x -- for deleting a character (3x will delete 3 characters, nx will delete n characters where n is an integer)
  2. dd -- for deleting a line (similarly, ndd will delete n lines)
  3. u -- to undo last change
  4. :w -- to save your work (sometimes you have to type :w! to force a save)
  5. :q -- to exit from vi (you may exit without saving changes by typing q!)
  6. a -- to switch to text entry mode from command mode
vi modes

You need to switch to text entry mode for entering text (See figure). If you are editing a document and wish to go to any other line other than the current line, you may need to switch to the command mode by typing the meta key (normally escape key). Your arrow keys may not work in text entry mode. You may not be able to use your mouse either.

The above description applies in general, but there can be slight variations from one system to another. Click here for documentation on vi.

Unix Architecture

Figure below shows the Unix architecture. Inner most layer is the hardware. Unix kernel is direclty above the hardware. Kernal manages all hardware devices and controls programs run on your computer. User programs and utility programs interact with Unix kernal through system calls. Kernel Interface provides the system calls. When you type ls, the command shell (say, csh) reads your input and makes a number of system calls for obtaining the names of the files in the current folder. Once it gets all information, it displays them in a well defined format.

Unix Family

  1. Free BSD
  2. Linux

Unix Shells

A unix shell provides an interface to the operating system. Shell is a program like any other program that executes at login time, but waits for user commands, parses and executes them. You can execute a shell by typing its file name. You can also specify the default shell, which will be automatically executed at the login time.

Shell File NameDescription
sh Borne Shell is one of the earliest shell, and also called standard shell. (Documentation)
rc Mostly C syntax. Interactive. (Documentation)
csh C like syntax. Not much in use. (Documentation)
ksh Korn Shell is more complex and has richer features. Bourne shell compatibile. (Documentation)
tcsh Next generation csh. (Documentation)
zsh Powerful and configurable. Can emulate other shells (sh, ksh, csh). (Documentation)
bash Combines the strength of ksh and csh. Available from GNU.(Documentation)

Next:More Shell Commands

You may share this article on Facebook.