20-755: The Internet


Recitation 1: UNIX Survival Guide.


Goals:

The aim of this laboratory is to help you obtain the basic skills to manipulate some the resources you will be using to complete the class project.

Exercise:

  1. Using telnet to connect to Euro.

    You will use the standard windows telnet client to connect to Euro.  You can use any of the following methods

    This will pop up a telnet window with a login prompt. Type your euro login id and password to log in:

    login: <your login id, same as your Andrew id>
    Password: <your euro password>

  2. Changing your password.

    It is recommended that you change your password after your first logon. You might want to choose a password that is easy to remember but at the same time is hard to guess by another person.  The password selection guidelines might be helpful.

    To change your password use the passwd command:

    $ passwd -l
    Changing password for <username>.
    Old password:
    New password:

    The password command first ask for the old (current) password and then asks for the new password twice to confirm to prevent mistakes in while typing the new password.

    For more information check: http://www.cmu.edu/computing/documentation/unix/Password.html

  3. The UNIX shell

    The shell is a command interpreter that executes commands read from the standard input (console) or from a file.  The shell program is executed automatically by the login process after the user has been authenticated.  The shell provides the basic interface to run other programs and manage its execution.

    The input of a program can be redirected from a file using the operator "<".  For example: $grep sh < output.txt  (Grep is   a program that searches the named input files (or standard input if no files are named, or the file name - is given) for lines containing a match to the given pattern

    The output of one program can be redirected to be the input of another program using the | (pipe) operator.  For example: $ps au | grep sh

    Exercise:

    1. Execute the cat program in the background
    2. Bring it to the foreground.
    3. Cancel it.
    4. Execute the cat program again now in the foreground
    5. Send it to the background
    6. Kill the cat process
    7. Create a file processes.txt with the list of all processes currently running.
    8. Find if there is any process with the name init
  4. Finding more information, the man pages

    The man command formats and displays the on-line manual pages.  For example, to obtain more information about ps type: man ps

    Exercise:  What is the ping command for?

  5. File Systems introduction

    The file system is probably the most visible aspect of an operating system.  It provides the mechanism for on-line storage of and access to both data an programs.   The file system consists of two distinct parts: a collection of files, each storing related data, and a directory structure, which organizes and provides information about all the files in the file system.

    A file is a collection of related information that is recorded on secondary storage (disk).  It can be data, a paper, a graph, a computer program, a drawing, or anything else you might want to store on a computer.

    A directory is a special type of file that can contain other files and directories. A directory within a directory is often called a subdirectory.

    The entire system of directories and files is arranged in a tree-like (hierarchical) structure, beginning with the root (the directory from which all other directories stem), and extending into branches and leaves. The root ("/") of the tree is at the top instead of the bottom, and all directories grow down from there.

    The directory that you are working in is called your current or working directory.

    Pathnames: A path name (also called simply path) is like the address of a file or directory. No two files or directories have the same path. A pathname is a chain of directory names, starting at the root and proceeding down the tree until it stops at a particular file or directory. Each directory name is separated by a slash (/).

    Commands to manipulate directories

    Commands to manipulate files

    Exercise:

    1. Create a directory named lab1 in your home directory.
    2. Create two directories dir1 and dir2 inside the directory lab1.
    3. Create a file "list.txt" in the lab1 directory with the list of the files in the directory /etc.
    4. Rename the file list.txt to listetc.txt
    5. Copy the file listetc.txt to the directory dir1.
    6. Remove the directory dir2.
  6. Using the editor to write your programs.

  7. GNU Emacs is popular here and elsewhere because of its portability, extensibility (it's written in Lisp), and copious features and documentation.  To start emacs, type "emacs filename" at the shell prompt.

    To save, type ctrl+X ctrl+S
    To exit, type ctrl+X ctrl+C

    - EMACS Intro and commands

    Exercise: Write a perl program that prints the message "Hello world!" to the standard output.

  8. Running perl programs in Euro.

    To run a perl program, type: perl program_name

    To turn your script into an "executable" that can be run directly:

    1. Add the following line at the beginning of the script.
      #!/usr/local/bin/perl
    2. Change the file mode to executable with the command:
      chmod +x scriptname
    3. Run it:
      ./scriptname

    Exercise:

    1. Run your "hello world" program executing the interpreter explicitly.
    2. Turn your "hello world" program into an executable.

[References]

Information on related topics