The Complete Unix Guide



Introduction to UNIX

Unix was invented at Bell Labs in USA. The entire OS was written in the C language. Later, different versions of Unix evolved like SCO Unix, Digital Unix and Unix clones. The latest rage is Linux developed by Linus Trovaldt. Unix is the OS of choice in Local Area Networks & Intranets. Most web servers and ISP servers on the Internet too run on Unix or Sun 0S.

Unix Basics

Unix is a multi-user, multi-tasking OS (i.e can perform many tasks together like Windoows) To have access to a Unix PC or server you need to have an account on that server. The account details consist of a login and a password. Only users in possession of the password can have access to the server. The server is maintained by the system administrator.

The Unix file structure

The Unix filing system is different from the DOS/Windows type. There are different levels of file ownerships - the filing system is hierarchial or pyramidal. At the top of the pyramid is the system administrator or root who has full authority to manage the system. At the next level are the group ownership rights and then finally individual ownership. Every file is owned by an individual or a group of users. The owner owns the file by virtue of having copied it or created it himself/herself. There are 3 types of file access permissions in Unix - read, write and execute permission. Read permission allows read access to the file, write permission allows write access to the file i.e modification of file and execute permission allows the person to execute the file. The owner can set file permissions by using the chown command explained later. Group ownership rights can be changed by the chrgp command.

Here's an example to make things clearer :

rwxr--r-- root root 10990 March 21 runme

This directory listing indicates that the file belongs to root. The first 3 characters indicate permissions for the user (i.e file owner), the next 3 are permissions for group users and the last 3 characters indicate permissions for others (i.e not individual/group file owners).

Take another example :

drwxr-x--- root root 10990 March 21 runme

In this example the d at the beginning indicates that it is a directory. rwx suggests that the owner has full access permissions to the file while group ownership is limited to read and execute access and it cannot be accessed by other users.

Shells

Unix OS is composed of a Kernel which is the core od the OS and a shell which is written in C and acrs as a link between the user and the kernel. The shell scans the input typed by the user and sends it to the kernel to be executed. There are 4 main types of shells :

  1. Bourne shell or BASH shell (Bourne Again Shell) in some machines
  2. Korn shell
  3. C shell
  4. Restricted shell
The shell is just a program written in C. It always runs behind the scenes. The shell program is stored in the /bin directory. Each user who has an account on the server is assigned a shell to work in. The profile file stores the login details and shell type for each user. The restricted shell is a shell for users with limited access rights. It does not allow users to change directories or run certain other commands reserved exclusively for the system adminitrator. The present working shell can be changed by the set shell command. eg. set shell=/bin/sh - changes to Bourne shell set shell=/bin/ksh changes to Korn shell set shell=/bin/csh changes to C shell

Using Internet in Unix

Internet access is also possible in Unix. Unix offers a text-based browser Lynx. Lately, with graphical enhancements to the OS setting up Internet has become an easy task. Now, Netscape Communicator is also available fot Unix/Linux thus making for a better browsing experience.

Other Internet facilities - Telnet and FTP

Telnet can be used to login to a remote server from a distant location.

eg. : telnet del2.vsnl.net.in

Now you can login to a remote server if you have an account. FTP (File Transfer Protocol) can be used similarly to download files from a remote server.

Miscellaneous Unix Concepts

Another feature of Unix is piping i.e supplying the output (result) of one command as the input of another.
eg: who | wc counts the number of users on the local network at the moment. As it is a multi-tasking OS - each process has a process ID number to identify it. The ps command shows the number of processes running concurrently along with their process ID.
eg: ps
bash 119
x windows 120

The kill command terminates a current process. eg: kill 120

Future of Unix

The future of Unix is bright - Linux (an Unix variant) is rapidly entering homes as it becomes more user friendly with a number of GUI interfaces being available for it like KDE, Gnome etc. with the emergence of the X Windows environment similar to Windows.

Unix Commands

Command Syntax What it does
rm filename delete file
cp filename destination copy file
ls filename Display file
cat filename Displays file contents
who Displays online users
passwd change your password
wc filename Counts words, characters, lines in the file and displays stats
mv filename newname rename filename
cd filename change directory
mkdir dirname make directory
rmdir dirname remove directory
pwd displays present working directory
Most of these can be piped too.