unix

Tuesday, April 7, 2009

Tuesday, March 17, 2009

unix programming books for 3rd cse

unix books list


for first unit
unix_book Frank G. Fiamingo

for 2nd,3rd and 4th
Sams.Unix.Shell.Programming.3rd.Edition.eBook-LiB

for 5th,6th and 8th units
Advanced Programming In The UNIX Environment 2nd Edition 2005

for 7th unit
Advanced UNIX Programming


to see the above books click the download button
DOWNLOAD

UNIX PROGRAMMING PREVIOUS PAPERS

to get the unix previous papers click the
DOWNLOAD

unix programs

click the download button for unix programs
DOWNLOAD

Thursday, February 19, 2009

unix online bits

DOWNLOAD

EXCELLENT_HARDWARE_PRESENTATION

if u want to know about the hardware components in cpu click the following download link

DOWNLOAD

Wednesday, January 21, 2009

UNIX COMMANDS MANUAL

click the download button for entire unix commands manual.

DOWNLOAD

Monday, January 19, 2009

unix filesystems - evolution, design and implementation

wiley & sons - unix filesystems - evolution, design and implementation

DOWNLOAD

grep command

to see for more details about the grep family and regular expressions click the download button

REGULAR EXPRESSIONSDOWNLOAD

GREP FAMILYDOWNLOAD

Monday, December 29, 2008

awk command

click the download button to know about the awk command
DOWNLOAD

Wednesday, December 10, 2008

unit1

Introduction to unix:

What Is UNIX?

  • UNIX is a computer operating system.

  • An operating system is the program that controls all the other parts of a computer system, both the hardware and the software. It allocates the computer's resources and schedules tasks. It allows you to make use of the facilities provided by the system. Every computer requires an operating system.

  • UNIX is a multi-user, multi-tasking operating system. Multiple users may have multiple tasks running simultaneously. This is very different than PC operating systems.

  • UNIX is a machine independent operating system. Not specific to just one type of computer hardware. Designed from the beginning to be independent of the computer hardware.

  • UNIX is a software development environment. Was born in and designed to function within this type of environment.

  • The "UNIX" trademark, previously owned by AT&T and then deeded to UNIX Systems Laboratories (USL), an AT&T subsidiary, passed to Novell when it acquired USL. After a brief period of negotiations with rival Unix vendors Sun Microsystems, Santa Cruz Operation, International Business Machines, and Hewlett-Packard, Novell granted exclusive licensing rights to the UNIX trademark to X/Open Co. Ltd., an Open Systems industry standards branding agent based in the United Kingdom.

History of UNIX

  • 1969: Developed at AT&T Bell Labs in Murray Hill, New Jersey, one of the largest research facilities in the world. Created in an environment when most computer jobs were fed into a batch system.

    Developed by researchers who needed a set of computing tools to help them with their projects and their collaborators. Allowed a group of people working together on a project to share selected data and programs.

  • 1975: AT&T makes UNIX widely available - offered to educational institutions at minimal cost. Becomes popular with university computer science programs. AT&T distributes standard versions in source form: Version 6 (1975), Version 7 (1978), System III (1981).

  • 1984 to date: University of California, Berkeley adds major enhancements, creates Berkeley Standard Distribution (BSD)

  • 1984 to date: Many Berkeley features incorporated into new AT&T version: System V

  • UNIX has become the operating system of choice for engineering and scientific workstations.

  • Two variations maintain popularity today, AT&T System V based and the Berkeley Standard Distribution.

  • Current versions (1/95)are System V release 4.2 .and 4.4 BSD

  • Work is in progress to develop a Portable Operating System specification based on UNIX (IEEE POSIX committee).

Why UNIX?

  • Hardware independence

    • operating system code is written in C language rather than a specific assembly language

    • operating system software can be easily mov ed from one hardware system to another

    • UNIX applications can be easily mo ved to other UNIX machines. Porting is usually as simple as transfer of the source and a recompile

  • Productive environment for software develo pment

    • rich set of tools

    • versatile command language

  • UNIX is available at virtually all HPC centers, allowing researchers relative ease in utilizing the facilities at each center.

  • Distributed processing and multi-tasking

UNIX Components

  • Kernel

    • The core of the UNIX system. Loaded at system start up (boot). Memory-resident control program.

    • Manages the entire resources of the system, presenting them to you and every other user as a coherent system. Provides service to user applications such as device management, process scheduling, etc.

    • Example functions performed by the kernel are:
      • managing the machine's memory and allocating it to each process.
      • scheduling the work done by the CPU so that the work of each user is carried out as efficiently as is possible.
      • accomplishing the transfer of data fr om one part of the machine to another
      • interpreting and executing instructions from the shell
      • enforcing file access permissions

    • You do not need to know anything about the kernel in order to use a UNIX system. These details are provided for your information only.

  • Shell

    • Whenever you login to a Unix system you are placed in a shell program. The shell's prompt is usually


      visible at the cursor's position on your screen. To get your work done, you enter commands at this prompt.

    • The shell is a command interpreter; it takes each command and passes it to the operating system kernel to be acted upon. It then displays the results of this operation on your screen.

    • Several shells are usually available on any UNIX system, each with its own strengths and weaknesses.

    • Different users may use different shells. Initially, your system adminstrator will supply a default shell, which can be overridden or changed. The most commonly available shells are:
      • Bourne shell (sh)
      • C shell (csh)
      • Korn shell (ksh)
      • TC Shell (tcsh)
      • Bourne Again Shell (bash)

    • Each shell also includes its own programming language. Command files, called "shell scripts" are used to accomplish a series of tasks.

  • Utilities

    • UNIX provides several hundred utility programs, often referred to as commands.

    • Accomplish universal functions
      • editing
      • file maintenance
      • printing
      • sorting
      • programming support
      • online info
      • etc.

    • Modular: single functions can be grouped to perform more complex tasks

System V vs. BSD

  • AT&T distributes System V for their computers. System V is also the basis for several commercial implementations including:
    • Hewlett-Packard HP-UX
    • Apple AUX
    • Amdahl UTS
    • Cray UNICOS
    • IBM AIX.

  • BSD, from the University of California Berkeley, has undergone extensive modification and enhancement in the university environment.

  • BSD is available directly from UCB and in a number of commercial versions including: Sun, Apollo, DEC Ultrix, Gould UTX/32.

  • System V and BSD contain a large set of commands in common. Some of these commands, however, support different options and have different default behaviors and output formats. ex: ls, stty, mail, grep

  • Each version also has its own unique utilities. Some very common tasks, such as browsing a file, are performed by totally different utilities: System V uses "pg" whereas BSD uses "more".

Architecture of unix

Unix follows a layered approach.
Layer 1 :
This layer is the hardware over which the different OS layers are built.Hardware is not a part of the Unix OS.

Layer 2 : This layer is the Kernel, which is the most important part of the Unix system.It is a collection of programs which directly communicate with the hardware. It is that part of the Unix system that is loaded into memory when the system is booted. Itmanages the system resources, allocates time between users and the processes, decides priorities of different processes, etc.

Layer 3 : This layer contains programs that interact with the Kernel by invoking a welldefined
set of system-calls. Typically, these programs are Unix commands like wc,grep, etc.

Layer 4 : This layer is called Shell. Technically another Unix command, it is the interpreter of user requests. It takes a command from the user, deciphers it, and communicates with the Kernel to see that the command is executed. It is actually the interface between the user and the kernel, which effectively insulates the user from the knowledge of kernel functions. It also has a programming capability of its own. The kernel and shell together make the Unix system work. The shell provides a processing environment to the user programs.


Kernel:
The Kernel performs various primitive operations on behalf of user programs:
  • Control of execution of processes - creation, synchronization, termination,suspension and communication of processes.
  • Scheduling of processes - deciding of time-sharing of processes.
  • Memory management - Allocation of memory for executing processes. Two methods are used:
  1. Swapping: Entire process is written to swap device to accommodate another process.
  2. Paging: Pages of memory is written to swap device.
  • File system service - Allocation of secondary storage efficiently for user data files.
  • Controlled access to peripherals, which are treated as special files.

Main Features of UNIX:


Portability : As Unix has been re-written in C , hence it can run on machines from microcomputers to mainframe computers.

Security : Unix is a very secure operating system. Without the proper username and passwords, it is not possible to work on Unix.

Background Processing : Unix employs a technique of Background Processing, wherein jobs/tasks are executed in the background with the minimal interaction from the user.

Pipes : Using the concept of pipes, a Unix user/administrator can easily link and work with multiple commands at the same time.

Redirection Tools : These tools allow data to be re-directed between files as per the requirement of the user.

Software Development Tools : Unix supports a wide variety of tools using which the user could create and work on different programs .viz. C Language on the Unix Operating system. Unix supports any language that has an interpreter or compiler.

Stable and Reliable : Unix is a very reliable and stable Operating System. It is less prone to crashes.

Easy to write programs : Its easy to write programs in Unix as it hides machine architecture from the user.

Hierarchical File System : Unix employs a hierarchical file system which is easy to implement and maintain.

Shells : Unix has different types of shells .viz. Bourne, C, Korn, etc.

Communication : Unix has commands which allow communication between different users connected to the system.


Introduction to Unix File System:

The Unix file system follows a tree structure with root represented by ‘/’. Every non-leaf node is a directory of files and the leaf nodes can be directories, regular files or special device files.

The main features of a Unix file system:
  • Hierarchical structure
  • Consistent treatment of file data
  • Create and delete files
  • Dynamic growth of files
  • Protection of file data
  • Treats peripheral devices as files
  • Keeps track of files using i-node numbers.
  • Information of files is kept in the i-node block.




.....for more information on Unix file system click the download button
DOWNLOAD


Introduction to vi
vi (pronounced "vee-eye", short for visual, or perhaps vile) is a display-oriented text editor based on an underlying line editor called ex. Although beginners usually find vi somewhat awkward to use, it is useful to learn because it is universally available (being supplied with all UNIX systems). It also uses standard alphanumeric keys for commands, so it can be used on almost any terminal or workstation without having to worry about unusual keyboard mappings. System administrators like users to use vi because it uses very few system resources.

To start vi, enter:

$ vi filename

where filename is the name of the file you want to edit. If the file doesn't exist, vi will create it for you.

Basic Text Input and Navigation in vi
The main feature that makes vi unique as an editor is its mode-based operation. vi has two modes: command mode and input mode. In command mode, characters you type perform actions (e.g. moving the cursor, cutting or copying text, etc.) In input mode, characters you type are inserted or overwrite existing text.

When you begin vi, it is in command mode. To put vi into input mode, press i (insert). You can then type text which is inserted at the current cursor location; you can correct mistakes with the backspace key as you type.To get back into command mode, press ESC (the escape key). Another way of inserting text, especially useful when you are at the end of a line is to press a (append).

In command mode, you are able to move the cursor around your document. h, j, k and l move the cursor left, down, up and right respectively (if you are lucky the arrow keys may also work). Other useful keys are ^ and $ which move you to the beginning and end of a line respectively. w skips to the beginning of the next word and b skips back to the beginning of the previous word. To go right to the top of the document, press 1 and then G. To go the bottom of the document, press G. To skip forward a page, press ^F, and to go back a page, press ^B. To go to a particular line number, type the line number and press G, e.g. 55G takes you to line 55.

To delete text, move the cursor over the first character of the group you want to delete and make sure you are in command mode. Press x to delete the current character, dw to delete the next word, d4w to delete the next 4 words, dd to delete the next line, 4dd to delete the next 4 lines, d$ to delete to the end of the line or even dG to delete to the end of the document. If you accidentally delete too much, pressing u will undo the last change.

Occasionally you will want to join two lines together. Press J to do this (trying to press backspace on the beginning of the second line does not have the intuitive effect!)

Moving and Copying Text in vi
vi uses buffers to store text that is deleted. There are nine numbered buffers (1-9) as well as the undo buffer. Usually buffer 1 contains the most recent deletion, buffer 2 the next recent, etc.

To cut and paste in vi, delete the text (using e.g. 5dd to delete 5 lines). Then move to the line where you want the text to appear and press p. If you delete something else before you paste, you can still retrieve the delete text by pasting the contents of the delete buffers. You can do this by typing "1p, "2p, etc.

To copy and paste, "yank" the text (using e.g. 5yy to copy 5 lines). Then move to the line where you want the text to appear and press p.

Searching for and Replacing Text in vi
In command mode, you can search for text by specifying regular expressions. To search forward, type / and then a regular expression and press . To search backwards, begin with a ? instead of a /. To find the next text that matches your regular expression press n.

To search and replace all occurences of pattern1 with pattern2, type :%s/pattern1/pattern2/g. To be asked to confirm each replacement, add a c to this substitution command. Instead of the % you can also give a range of lines (e.g. 1,17) over which you want the substitution to apply.

Other Useful vi Commands
Programmers might like the :set number command which displays line numbers (:set nonumber turns them off).

To save a file, type :w. To save and quit, type :wq or press ZZ. To force a quit without saving type :q!.

To start editing another file, type :e filename.

To execute shell commands from within vi, and then return to vi afterwards, type :!shellcommand. You can use the letter % as a substitute for the name of the file that you are editing (so :!echo % prints the name of the current file).

. repeats the last command.

Quick reference for vi
    Inserting and typing text:
    i insert text (and enter input mode)
    $a append text (to end of line)
    ESC re-enter command mode
    J join lines

    Cursor movement:
    h left
    j down
    k up
    l right
    ^ beginning of line
    $ end of line
    1 G top of document
    G end of document
    G go to line
    ^F page forward
    ^B page backward
    w word forwards
    b word backwards

    Deleting and moving text:
    Backspace delete character before cursor
    (only works in insert mode)
    x delete character under cursor
    dw delete word
    dd delete line (restore with p or P)
    dd delete n lines



    d$ delete to end of line
    dG delete to end of file
    yy yank/copy line (restore with p or P)
    yy yank/copy lines

    Search and replace:
    %s///g

    Miscellaneous:
    u undo
    :w save file
    :wq save file and quit
    ZZ save file and quit
    :q! quit without saving

...........for more information on vi editor click the download button
DOWNLOAD

File Handling Utilites:

File-Handling Utilities

In this context, file handling means copying, moving and deleting files. Later, we will look at ways of changing file attributes (owner, permissions).

mkdir, touch: Creating Empty Directories and Files


mkdir (MaKe DIRectory) is used to create directories. Its syntax is simple:

mkdir [options]  [directory ...]

Only one option is worth noting: the -p option. It does two things:

  1. it will create parent directories if they did not exist previously. Without this option, mkdir would just fail, complaining that the said parent directories do not exist;

  2. it will return silently if the directory you wanted to create already exists. Similarly, if you did not specify the -p option, mkdir will send back an error message, complaining that the directory already exists.

Here are some examples:

  • mkdir foo: creates a directory foo in the current directory;

  • mkdir -p images/misc docs: creates the misc directory in the images directory. First, it creates the latter if it does not exist (-p); it also creates a directory named docs in the current directory.

Initially, the touch command was not intended for creating files but for updating file access and modification times[3]. However, touch will create the files listed as empty files if they do not exist. The syntax is:

touch [options] file [file...]

So running the command:

touch file1 images/file2

will create an empty file called file1 in the current directory and an empty file file2 in directory images, if the files did not previously exist.

rm: Deleting Files or Directories


The rm command (ReMove) replaces the DOS commands del and deltree, and adds more options. Its syntax is as follows:

rm [options]  [filedirectory...]

Options include:

  • -r, or -R: delete recursively. This option is mandatory for deleting a directory, empty or not. However, you can also use rmdir to delete empty directories.

  • -i: request confirmation before each deletion. Note that by default in Mandrakelinux, rm is an alias to rm -i, for safety reasons (similar aliases exist for cp and mv). Your mileage may vary as to the usefulness of these aliases. If you want to remove them, you can create an empty ~/.alias file which will prevent setting system wide aliases. Alternatively you can edit your ~/.bashrc file to disable some of the system wide aliases by adding this line: unalias rm cp mv

  • -f, the opposite of -i, forces deletion of the files or directories, even if the user has no write access on the files[4].

Some examples:

  • rm -i images/*.jpg file1: deletes all files with names ending in .jpg in the images directory and deletes file1 in the current directory, requesting confirmation for each file. Answer y to confirm deletion, n to cancel.

  • rm -Rf images/misc/ file*: deletes, without requesting confirmation, the whole directory misc/ in the images/ directory, together with all files in the current directory whose names begin with file.

[Warning]Warning

Using rm deletes files irrevocably. There is no way to restore them! (Well, actually there are several ways to do this but it is no trivial task.) Do not hesitate to use the -i option to ensure that you do not delete something by mistake.

mv: Moving or Renaming Files


The syntax of the mv (MoVe) command is as follows:

mv [options]  [filedirectory ...] 

Some options:

  • -f: forces operation –– no warning if an existing file is overwritten.

  • -i: the opposite. Asks the user for confirmation before overwriting an existing file.

  • -v: verbose mode, report all changes and activity.

Some examples:

  • mv -i /tmp/pics/*.png .: move all files in the /tmp/pics/ directory whose names end with .png to the current directory (.), but request confirmation before overwriting any files already there.

  • mv foo bar: rename file foo to bar. If a bar directory already existed, the effect of this command would be to move file foo or the whole directory (the directory itself plus all files and directories in it, recursively) into the bar directory.

  • mv -vf file* images/ trash/: move, without requesting confirmation, all files in the current directory whose names begin with file, together with the entire images/ directory to the trash/ directory, and show each operation carried out.

cp: Copying Files and Directories


cp (CoPy) replaces the DOS commands copy and xcopy and adds more options. Its syntax is as follows:

cp [options]  [filedirectory ...] 

cp has a lot of options. Here are the most common:

  • -R: recursive copy; mandatory for copying a directory, even an empty directory.

  • -i: request confirmation before overwriting any files which might be overwritten.

  • -f: the opposite of -i, replaces any existing files without requesting confirmation.

  • -v: verbose mode, displays all actions performed by cp.

Some examples:

  • cp -i /timages/* images/: copies all files in the /timages/ directory to the images/ directory located in the current directory. It requests confirmation if a file is going to be overwritten.

  • cp -vR docs/ /shared/mp3s/* mystuff/: copies the whole docs directory, plus all files in the /shared/mp3s directory to the mystuff directory.

  • cp foo bar: makes a copy of the foo file with the name bar in the current directory.


Access Permissions:

  • UNIX is a multi-user system. Every file and directory in your account can be protected from or made accessible to other users by changing its access permissions. Every user has responsibility for controlling access to their files.
  • Permissions for a file or directory may be any or all of:
r   -   read
w   -   write
x   -   execute = running a program
     
  • Each permission (rwx) can be controlled at three levels:
u   -    user = yourself
g   -    group = can be people in the same project
o   -    other = everyone on the system
     
  • File access permissions are displayed using the ls -l command. The output from the ls -l command shows all permissions for all levels as three groups of three according to the scheme:
 owner read (r)
 owner write (w)
 owner execute (x)
      group read (r)
      group write (w)
      group execute (x)
          public read (r)
          public write (w)
          public execute (x)
which are displayed as:        -rwxrwxrwx
     

Example outputs from the ls -l command:

     -rw-------  2 smith  staff 3287 Apr  8 12:10 file1
        - User has read and write permission. Group and
          others have no permissions. 
     -rw-r--r--  2 smith  staff 13297 Apr  8 12:11 file2
        - User has read and write permission.  Group and
          others can only read the file. 
     -rwxr-xr-x  2 smith  staff 4133 Apr  8 12:10 myprog
        - User has read, write and execute permission.
          Group and others can read and execute the file. 
     drwxr-x---  2 smith  staff 1024 Jun 17 10:00 SCCS
        - This is a directory. The user has read, write and 
          execute permission. Group has read and execute 
          permission on the directory. Nobody else can 
          access it. 
     
  • Note: a directory must have both r and x permissions if the files it contains are to be accessed.
  • The chmod command is used to change access permissions for files which you own. The syntax is:

chmod [who] [action] [permission] filename

             [who][action][permissions] filename
     

where:

      who          action       permissions
      u = user        + = add         r = read
     g = group       - = remove      w = write
     o = other                     x = execute
     a = all
     

Examples:

     chmod   a+r   sample.f
        - Adds read permission for all users to the file
          sample.f. 
     chmod   o-r   sample.f
        - Removes read permission for others to the file
          sample.f. 
     chmod   og+rx   prog*
        - Adds read and execute permissions for group and 
          others to all files which contain "prog" as the
          first four characters of their name. 
     chmod   +w   *
        - Adds write permission for user to all files in
          current directory. 
     
  • File access permissions can also be changed by a numerical (octal) chmod specification. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r  w  x
4  2  1
     

These values are added together for any one user category:

     0   =   no permissions
     1   =   execute only
     2   =   write only
     3   =   write and execute (1+2)
     4   =   read only
     5   =   read and execute (4+1)
     6   =   read and write (4+2)
     7   =   read and write and execute (4+2+1)
     

So access permissions can be expressed as three digits. For example:

                        user    group   others
      chmod 640 file1       rw-     r--     ---
     chmod 754 file1       rwx     r-x     r--
     chmod 664 file1       rw-     rw-     r--
     
  • Never set write permission for all other users on a file or directory which is in your home directory. If you do other users will be able to change its content. This can represent a serious security risk.
  • The umask command is used to set your default file permissions. Typically, the umask command is included as part of your .profile, .cshrc or .login file.

The umask command accepts only octal specifications. Note that these are different than those used by the chmod command, and in fact, represent which permissions to "mask out", or remove.

     Octal number             Access permissions given
         0                    rwx     read, write and
                                      execute
         1                    rw-     read and write
         2                    r-x     read and execute
         3                    r--     read only
         4                    -wx     write and execute
         5                    -w-     write only
         6                    --x     execute only
         7                    ---     no permissions
     

Example umask commands:

     umask 077
        - Subtracts 077 from the system defaults for files 
          (666) and directories (777). Results in default 
          access permissions for your files of 600 
          (rw-------) and for directories of 700 
          (rwx------). 
     umask 002
        - Subtracts 002 from the sytem defaults to give a 
          default access permission for your files of 664 
          (rw-rw-r--) and for your directories of 775 
          (rwxrwxr-x). 
     umask 022
        - Subtracts 022 from the system defaults to give a 
          default access permission for your files of 644 
          (rw-r--r--) and for your directories of 755 
          (rwxr-xr-x).  




The information pertaining to the Unix files is kept in the i-node (identification node) block, which is reserved exclusively for the use of kernel. Every file in the file system will invariably have an entry in this area. Every file is associated with an i-node number, called the i-number.

The command ls is used to list the contents of the current directory. The option –i used
with ls would indicate the i-node number for a file.


There are 2 ways to access any file in Unix. They are :
  • Absolute Path.
  • Relative Path.
In Absolute Path method, the complete path from the root to the required file is mentioned.
E.g. To access a file called file1, present in directory trng10, we need to write
/home/trng10/file1
In Relative Path method, the path from the current position to the required file is
mentioned.
.. represents parent directory.
. represents present working directory itself.

E.g. If the current directory is /home/trng10, then to go to the previous directory , we write ..


How Unix Works



Disk Utilities:



The df Command

The df command lists the current total disk usage for all file systems accessible by your workstation.
    Syntax: df -k

The du Command

To determine your current disk quota usage, use the du command.
    Syntax: du [options] directory
By default, the du command by itself will give a summary of quota usage for the directory specified and all subdirectories below it.
    du /users/username
For a summary of total disk usage, use the -s option.
    du -s /users/username
For a summary of your own disk usage, enter
    du -s ~

The quota Command

On the Sun, HP Alpha, and Linux workstations, the quota command displays your current usage. This command does not display relevant information on the SGI systems.
    Syntax: quota -v username


On-line Information

    man df
    man du
    man quota


Networking Commands:

Connecting to Remote Machines


telnet machinename
telnet provides an insecure mechanism for logging into remote machines. It is insecure because all data (including your username and password) is passed in unencrypted format over the network. For this reason, telnet login access is disabled on most systems and where possible it should be avoided in favour of secure alternatives such as ssh.

telnet is still a useful utility, however, because, by specifying different port numbers, telnet can be used to connect to other services offered by remote machines besides remote login (e.g. web pages, email, etc.) and reveal the mechanisms behind how those services are offered. For example,

    $ telnet www.doc.ic.ac.uk 80
    Trying 146.169.1.10...
    Connected to seagull.doc.ic.ac.uk (146.169.1.10).
    Escape character is '^]'.
    GET / HTTP/1.0

    HTTP/1.1 200 OK
    Date: Sun, 10 Dec 2000 21:06:34 GMT
    Server: Apache/1.3.14 (Unix)
    Last-Modified: Tue, 28 Nov 2000 16:09:20 GMT
    ETag: "23dcfd-3806-3a23d8b0"
    Accept-Ranges: bytes
    Content-Length: 14342
    Connection: close
    Content-Type: text/html

    Here www.doc.ic.ac.uk is the name of the remote machine (in this case the web server for the Department of Computing at Imperial College in London). Like most web servers, it offers web page services on port 80 through the daemon httpd (to see what other services are potentially available on a machine, have a look at the file /etc/services; and to see what services are actually active, see /etc/inetd.conf). By entering a valid HTTP GET command (HTTP is the protocol used to serve web pages) we obtain the top-level home page in HTML format. This is exactly the same process that is used by a web browser to access web pages.

  • rlogin, rsh
rlogin and rsh are insecure facilities for logging into remote machines and for executing commands on remote machines respectively. Along with telnet, they have been superseded by ssh.

  • ssh machinename (secure shell)
ssh is a secure alternative for remote login and also for executing commands in a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network. X11 connections (i.e. graphics) can also be forwarded over the secure channel (another advantage over telnet, rlogin and rsh). ssh is not a standard system utility, although it is a de facto standard.

    ssh clients are also available for Windows machines (e.g. there is a good ssh client called putty).

Network routing utilities:
  • ping machinename
The ping utility is useful for checking round-trip response time between machines. e.g.

    $ ping www.doc.ic.ac.uk

measures the reponse time delay between the current machine and the web server at the Department of Computing at Imperial College. ping is also useful to check whether a machine is still "alive" in some sense.

  • traceroute machinename
traceroute shows the full path taken to reach a remote machine, including the delay to each machine along the route. This is particularly useful in tracking down the location of network problems.
Remote File Transfer
  • ftp machinename (file transfer protocol)
ftp is an insecure way of transferring files between computers. When you connect to a machine via ftp, you will be asked for your username and password. If you have an account on the machine, you can use it, or you can can often use the user "ftp" or "anonymous". Once logged in via FTP, you can list files (dir), receive files (get and mget) and send files (put and mput). (Unusually for UNIX) help will show you a list of available commands. Particularly useful are binary (transfer files preserving all 8 bits) and prompt n (do not confirm each file on multiple file transfers). Type quit to leave ftp and return to the shell prompt.

  • scp sourcefiles destination (secure copy)
scp is a secure way of transferring files between computers. It works just like the UNIX cp command except that the arguments can specify a user and machine as well as files. For example:

    $ scp will@rose.doc.ic.ac.uk:~/hello.txt .

    will (subject to correct authentication) copy the file hello.txt from the user account will on the remote machine rose.doc.ic.ac.uk into the current directory (.) on the local machine.

Other Internet-related utilities
  • netscape
  • netscape is a fully-fledged graphical web browser (like Internet Explorer).

  • lynx
  • lynx provides a way to browse the web on a text-only terminal.

  • wget URL
  • wget provides a way to retrieve files from the web (using the HTTP protocol). wget is non-interactive, which means it can run in the background, while the user is not logged in (unlike most web browsers). The content retrieved by wget is stored as raw HTML text (which can be viewed later using a web browser).

    Note that netscape, lynx and wget are not standard UNIX system utilities, but are frequently-installed application packages.

User Information and Communication
  • finger, who
  • finger and who show the list of users logged into a machine, the terminal they are using, and the date they logged in on.

    $ who
    will pts/2 Dec 5 19:41
    $

  • write, talk
  • write is used by users on the same machine who want to talk to each other. You should specify the user and (optionally) the terminal they are on:

    $ write will pts/2
    hello will

    Lines are only transmitted when you press . To return to the shell prompt, press ctrl-d (the UNIX end of file marker).

    talk is a more sophisticated interactive chat client that can be used between remote machines:

    $ talk will@rose.doc.ic.ac.uk

    Unfortunately because of increasingly tight security restrictions, it is increasingly unlikely that talk will work (this is because it requires a special daemon called talkd to be running on the remote computer). Sometimes an application called ytalk will succeed if talk fails.

Printer Control
    • lpr -Pprintqueue filename
    • lpr adds a document to a print queue, so that the document is printed when the printer is available. Look at /etc/printcap to find out what printers are available.

    • lpq -Pprintqueue
    • lpq checks the status of the specified print queue. Each job will have an associated job number.

    • lprm -Pprintqueue jobnumber
    • lprm removes the given job from the specified print queue.

    Note that lpr, lpq and lprm are BSD-style print management utilities. If you are using a strict SYSV UNIX, you may need to use the SYSV equivalents lp, lpstat and cancel

    Text processing utilities:



Followers