001_what is unix

Upload: michaelmccabe18

Post on 05-Apr-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 001_what is Unix

    1/34

    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 thecomputer's resources and schedules tasks. It allows you to make use of thefacilities provided by the system. Every computer requires an operatingsystem.

    UNIX is a multi-user, multi-tasking operating system. Multiple users mayhave multiple tasks running simultaneously. This is very different than PCoperating systems.

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

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

    The "UNIX" trademark, previously owned by AT&T and then deeded toUNIX Systems Laboratories (USL), an AT&T subsidiary, passed to Novellwhen it acquired USL. After a brief period of negotiations with rival Unixvendors Sun Microsystems, Santa Cruz Operation, International Business

    Machines, and Hewlett-Packard, Novell granted exclusive licensing rights tothe UNIX trademark to X/Open Co. Ltd., an Open Systems industrystandards branding agent based in the United Kingdom.

    History of UNIX

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

  • 8/2/2019 001_what is Unix

    2/34

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

    1975: AT&T makes UNIX widely available - offered to educationalinstitutions at minimal cost. Becomes popular with university computerscience 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 andscientific workstations.

    Two variations maintain popularity today, AT&T System V based and theBerkeley 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).

    UNIX Philosophy

    Make each program do one thing well. Reusable software tools: 1 tool = 1function

    Expect the output of every program to become the input of another, yetunknown, program to combine simple tools to perform complex tasks

    Prototyping: get something small working as soon as possible and modify itincrementally until it is finished

    Use terse commands and messages: reduces typing and screen output

    Why UNIX?

    Hardware independenceo operating system code is written in C language rather than a specific

    assembly languageo operating system software can be easily moved from one hardware

    system to anothero UNIX applications can be easily moved to other UNIX machines.

    Porting is usually as simple as transfer of the source and a recompile Productive environment for software development

  • 8/2/2019 001_what is Unix

    3/34

    o rich set of toolso versatile command language

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

    Distributed processing and multi-tasking

    UNIX Components

    Kernelo The core of the UNIX system. Loaded at system start up (boot).

    Memory-resident control program.o Manages the entire resources of the system, presenting them to you

    and every other user as a coherent system. Provides service to userapplications such as device management, process scheduling, etc.

    o 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 from one part of the

    machine to another interpreting and executing instructions from the shell enforcing file access permissions

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

    Shello 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 positionon your screen. To get your work done, you enter commands at thisprompt.

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

    o Several shells are usually available on any UNIX system, each withits own strengths and weaknesses.

    o Different users may use different shells. Initially, your systemadminstrator will supply a default shell, which can be overridden orchanged. The most commonly available shells are:

    Bourne shell (sh) C shell (csh)

    Korn shell (ksh) TC Shell (tcsh)

  • 8/2/2019 001_what is Unix

    4/34

    Bourne Again Shell (bash)o Each shell also includes its own programming language. Command

    files, called "shell scripts" are used to accomplish a series of tasks. Utilities

    oUNIX provides several hundred utility programs, often referred to ascommands.

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

    o Modular: single functions can be grouped to perform more complextasks

    System V vs. BSD

    AT&T distributes System V for their computers. System V is also the basisfor several commercial implementations including:

    o Hewlett-Packard HP-UXo Apple AUXo Amdahl UTSo Cray UNICOSo IBM AIX.

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

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

    System V and BSD contain a large set of commands in common. Some ofthese commands, however, support different options and have differentdefault 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 Vuses "pg" whereas BSD uses "more".

    This concludes the tutorial. Return to theTable of Contents

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#Overviewhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#Overviewhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#Overviewhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#Overview
  • 8/2/2019 001_what is Unix

    5/34

    Logging On To The System

    Before you can begin to use the system you will need to have a validusername and a password. Assignment of usernames and initial passwords istypically handled by the System Administrator or a "Computer Accounts"office.

    Your username, also called a userid, should be unique and should notchange. Initial passwords can be anything and should be changed after yourfirst login.

    To login to your account1. Type your username at the login prompt. UNIX is case sensitive -

    if your username is kellyk do not type KellyK . Press theRETURN or ENTER key after typing your username.

    2. When thepasswordprompt appears, type in your password. Yourpassword is never displayed on the screen as a security measure. Italso is case sensitive. Press the RETURN or ENTER key afterentering your password.

    What happens after you successfully login depends upon your system:o Many UNIX systems will display a login banner or "message of the

    day". Make a habit of reading this since it may contain important

    information about the system.o Other UNIX systems will automatically configure your environment

    and open one or more windows for you to do work in.o You should see a prompt - usually a percent sign (%) or dollar sign

    ($). This is called the "shell prompt" (the shell is discussed in detaillater). It indicates that the system is ready to accept commands fromyou.

    If your login attempt was unsuccessful, there are several possible reasons:0. You made a typing error while entering your username or password1. The CAPS LOCK key is on and everything is being sent to the

    system in uppercase letters.

  • 8/2/2019 001_what is Unix

    6/34

    2. You have an expired or invalid username or password, or the systemsecurity has changed.

    3. There are system problemsExample

    login: kellykkellyk's Password:************************************************************* Welcome to the Maui High Performance Computing Center************************************************************** Aloha no! (Greetings)** System maintenance is scheduled today from 2:00* until 4:00 pm HST

    ** Mahalo nui loa (Thank you very much)*************************************************************

    %

    Begin the "Logging On To The System" Exercise

    Logging On To The System

    The details of logging in to a UNIX computer will differ from system to system. The

    steps covered here are specific for the MHPCC classroom.

    1. The instructor will assign every student a unique userid and password.Make sure you know yours before proceeding. The instructor will also show

    you how to setup your terminal for logging on.

    2. After your computer terminal is ready for logging on, review the screen andlook for a place to type in your userid and password.

    3.

    Type in your userid, making sure that you distinguish between uppercaseand lowercase letters as required. Press the return key when finished.

    4. Type in your password, also making sure that you distinguish betweenuppercase and lowercase letters as required. It will not appear as you type

    for security reasons. Press the return key when finished.

    5. If you are unsuccessful at logging in, the system will give you another try.Keep trying until you succeed. If you don't succeed after 5 tries, call the

    instructor.

    6. After you have successfully logged in, the system will automatically createyour initial environment including a clock and a window for enteringcommands.

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Loginhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Loginhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Login
  • 8/2/2019 001_what is Unix

    7/34

    7. Notice the window - it should ask you which type of session you want.Answer the prompt by typing in the number which matches:Introduction

    to UNIX. You will then be prompted to "start Netscape" - type y for yes.

    8. After a few seconds, you should see the Introduction to UNIX window. Ifyou do not, call the instructor.

    9. Return to the tutorial to learn about the next section before proceeding.

    Using UNIX CommandsThis exercise will familiarize you with the basics of issuing UNIX commands.

    1. You should still have a window on your screen from the previous exercise.Select that window by dragging the mouse pointer into the window and

    then clicking with the left mouse button. The window is now ready to

    accept input from you.

    2. Try a few simple commands which require no arguments or options:date - show date and time

    whoami - show your useridwho - show who is logged onto the systemw - show who is logged onto the systempwd - print the working directory's nameclear - clear the screen

    3. Now try some commands which require arguments and/or options:ls -a - list all files in current directoryls -al - long list of current directorycat .cshrc - display contents of .cshrc file

    mkdir dir1 - make a directory called dir1cd dir1 - change directory to dir1cd .. - change to parent directoryrmdir dir1 - remove directory dir1cp .login new.login - copy the .login file to new.login

    wc new.login - count the lines, words andcharacters in the new.login file

    wc -l new.login - count just the linesrm new.login - remove the new.login file

    4. Try using multiple commands on one line. Don't forget to include the semi-colon between commands.

    cp .login testfile ; cat testfile- copy a file and then show its contents

  • 8/2/2019 001_what is Unix

    8/34

    ls -l testfile ; rm testfile ; ls -l testfile- list (long) a file, remove it, and then try tolist it again

    5. Return to the tutorial to learn about the next section before proceeding.

    Special CharactersThis exercise will acquaint you with the use of several of the UNIX special

    characters.

    1. First, make sure you are in your home directory (issue the "cd" commandwith no arguments). Now "cd" to this exercise's subdirectory by using the

    command:

    cd GetStart

    2. Using the "*" wildcard character, list all of the files in this subdirectory:ls *

    3. Using the "?" wildcard character, list all files with 3 character names:ls ???

    4. Using square brackets and wildcard characters, try listing files severaldifferent ways:

    ls [a-c]*ls [abcde]*ls [a-z]*ls [z]*ls ??[c]*ls ?[e]*

    5. Using the right angle bracket ">" and the semi-colon ";", concatenate threefiles into a single new file and then display it:

    cat alpha beta gamma > newfile ; cat newfile

  • 8/2/2019 001_what is Unix

    9/34

    6. Return to the tutorial to learn about the next section before proceeding.

    Terminal Control KeysThis exercise will familiarize you with several of the terminal control keys used by

    UNIX.

    1. Erasing the command line: At the command prompt, begin typing severalcharacters. It doesn't matter what you type (but don't press the Return

    key) because you will then erase the line by typing CTRL-u.

    2. Killing a command: Start the commandsleep 300 which simply"sleeps" for 300 seconds. After it is started, try using another UNIX

    command such as "ls". What happens? Kill the sleep process by using CTRL-

    c, and try it again. What happens now?

    3. Backspacing: At the command prompt, begin typing several characters. Itdoesn't matter what you type (but don't press the Return key). After typing

    several characters, try using CRTL-h to backspace. Most keyboards will

    allow you to backspace by using a "backspace" or "delete" key also.

    4. Screen Scrolling: Issue a command which will send lots of information tothe screen:ls -R / While the information is being displayed, use CTRL-s to stop it and then CTRL-q to restart it. Try CTRL-s and CTRL-q a couple

    times. Then kill the process with CTRL-c.

    5. Return to the tutorial to learn about the next section before proceeding.

    Changing Your PasswordThis exercise will familiarize you with changing your password on a UNIX system.

    1. Each student should have received an initial password from the instructor.If you are not sure of yours, ask the instructor.

    2. Think of a new password which follows the guidelines mentioned in thetutorial. Remember what it is.3. Change your initial password by issuing thepasswdcommand. As your

    are prompted, supply your old password and then your new password. You

    will be asked to type the new password twice for confirmation. Notice that

    nothing appears on the screen as you type.

    4. Now change your password back to the original password. Please don'tforget to do this step!

    5. Return to the tutorial to learn about the next section before proceeding.

  • 8/2/2019 001_what is Unix

    10/34

    Getting InformationThis exercise will familiarize you with several different UNIX utilities for obtaining

    information about the system.

    1. Use theman command to read in depth about some common UNIXutilities:

    man lsman cpman rmman man

    2. Use the following commands to find out about users on the system,including yourself:

    whowhoamiwho am ifingerfingeryour userid

    3. Return to the tutorial to learn about the next section before proceeding.

    Logging Off The SystemThis exercise will familiarize you with logging off a UNIX system - in particular, an

    MHPCC training system. Note that this procedure may differ from system to

    system.

    1. In your open window, type either of the following commands to logout:

    logoutexit

    2. This will cause your window to disappear. In other UNIX systems, without awindows environment, these same commands would terminate your entire

    session.

    3. This concludes the "Getting Started" Exercises. Return to theGettingStarted tutorial or to theTable of Contents.

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/GetStart.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/GetStart.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/GetStart.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/GetStart.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/GetStart.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/GetStart.html
  • 8/2/2019 001_what is Unix

    11/34

    Your Home Directory

    Each user has a unique "home" directory. Your home directory is that part ofthe file system reserved for your files.

    After login, you are "put" into your home directory automatically. This iswhere you start your work.

    You are in control of your home directory and the files which reside there.You are also in control of the file access permissions (discussed later) to thefiles in your home directory. Generally, you alone should be able tocreate/delete/modify files in your home directory. Others may havepermission to read or execute your files as you determine.

    In most UNIX systems, you can "move around" or navigate to other parts ofthe file system outside of your home directory. This depends upon how thefile permissions have been set by others and/or the System Administrator,however.

    Using UNIX Commands

    UNIX commands are executable files and built-in utility programs All UNIX commands are case sensitive. Most commands are in lower case. Commands typically have the syntax:

    command option(s) argument(s)

    Options

    1. Modify the way that a command works2.

    Usually consist of a hyphen followed by a single letter3. Some commands accept multiple options which can usually begrouped together after a single hyphen

    4. A small number of commands require each option to be givenseparately

    5. Should be separated from the command name by a spaceArguments

    6. Most commands are used together with one or more arguments7. Some commands assume a default argument if none is supplied8. Arguments are optional for some commands and required by others

  • 8/2/2019 001_what is Unix

    12/34

    9. In most cases, multiple arguments should be separated from eachother by a space. They should be separated from the command nameand/or options by a space also.

    Examples

    10.To use a command with no argument: the "date" command displaysthe current time and date.

    date

    11.To use a command with a single argument: the "cd" commandchanges to the directory of its argument, newdir

    cd newdir

    12.To use a command with both an option and an argument: the wccommand counts the number of words, characters, and lines in a file.By using a different option you can choose what is counted.

    wc -w file1 counts the words in file1wc -c file1 counts the characters in file1wc -l file1 counts the lines in file1

    13.To use a command with several arguments: the cat command takesthe names of three files as arguments. It prints file1 followed by file2and then file3 on the screen.

    cat file1 file2 file3

    14.To use a command with multiple options and default argument: the lscommand provides a long (l) listing of all (a) files and also shows thefile size (s). Because no argument is specified, the default argument(current directory) will be used.

    ls -als

    Multiple commands can be entered on one line if you separate each with asemicolon. For example: this command line contains two commands. Thefirst, cd newdir changes the current directory to the directory newdir. Thesecond, ls -l produces a long listing of the contents of the newdir directory.

    cd newdir ; ls -l

    Commands can continue beyond one line by using a backslash (\) character.For example: this command copies the file called recipe from kelly's home

  • 8/2/2019 001_what is Unix

    13/34

    directory to the current directory and renames it kelly.recipe. It then sendsthis file to the printer ps3 with the request that 6 copies be printed.

    cp /users/kelly/recipe kelly.recipe ; \

    lpr -Pps3 #6m kelly.recipe

    Begin the "Using UNIX Commands" Exercise

    Special Characters

    The UNIX shell interprets a number of characters in special ways. Thesecharacters are most often used with UNIX commands - as arguments and forother means. The following list contains most of UNIX's special characters

    NEWLINE - initiates command execution; - separates commands on same line( ) - groups commands or identifies a function& - executes a command in the background| - pipe> - redirects standard output>> - appends standard output

    < - redirects standard input

    * - wildcard for any number of characters in afile name? - wildcard for a single character in a file

    name\ - quotes the following character' - quotes a string preventing all substitutions" - quotes a string allowing variable and

    command substitution` - performs command substitution[ ] - denotes a character class in a file name$ - references a variable{ } - command grouping within a function. - executes a command (if at beginning of line)

    # - begins a comment: - null command

    Examples1. Use the * character in file names to match any number of characters.

    The following command:

    ls *.txt

    Will match the following files:

    chapter1.txt doc.txt memo.txt a.txt

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Commandshttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Commandshttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Commands
  • 8/2/2019 001_what is Unix

    14/34

    Will not match the following files:

    doctxt txt.memo

    2. Use the ? character in file names to match any single character. Thefollowing command:

    ls ???.txt

    Will match the following files:

    one.txt doc.txt two.txt

    Will not match the following files:

    chap1.txt doctxt

    3. Use the [ ] characters in file names to match any character within arange of characters. The following command:

    ls chapter[1-3].txt

    Will match the following files:

    chapter1.txt chapter2.txt chapter3.txt

    Will not match the following files:chap1.txt chapter4.txt

    Other uses for special characters and examples will be discussed later. Begin the "Special Characters" Exercise

    Terminal Control Keys

    Several key combinations on your keyboard usually have a special effect onthe terminal.

    These "control" (CTRL) keys are accomplished by holding the CTRL keywhile typing the second key. For example, CTRL-c means to hold the CTRLkey while you type the letter "c".

    The most common control keys are listed below:

    CTRL-u - erase everything you've typed on the commandline

    CTRL-c - stop/kill a command

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#SpecialCharhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#SpecialCharhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#SpecialChar
  • 8/2/2019 001_what is Unix

    15/34

    CTRL-h - backspace (usually)

    CTRL-z - suspend a command

    CTRL-s - stop the screen from scrolling

    CTRL-q - continue scrolling

    CTRL-d - exit from an interactive program (signals endof data)

    Begin the "Terminal Control Keys" Exercise

    Changing Your Password Your password is important; it stops other users from gaining access to your

    account. Never give your password to anyone You should change your initial password very soon after your first login To change your password: enter the command passwd and then respond to

    the prompts by entering your old password followed by your new one. Youare then asked to retype your password for confirmation.

    Note that what you type will not appear on the screen for security reasons.For example:

    passwdOld password: - enter your current password

    New password: - enter your new passwordRetype new password: - re-enter your new password

    If you make a mistake, the message:Mismatch - passwordunchanged. is displayed and your password remains unchanged. Try

    again.

    Guidelines for creating a passwordDon't

    o choose a word from a dictionaryo use personal information such as your name, make of car, pet,

    sweetheart, etc.o tell anyone your passwdo write your password down anywhere

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#TermKeyshttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#TermKeyshttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#TermKeys
  • 8/2/2019 001_what is Unix

    16/34

    o keep the password you were given when you first got your useridDo

    o choose an obscure password preferably between 6 and 8 characters inlength, of mixed case and containing at least one non-alphanumericcharacter such as ! or @

    o change your password at regular intervals Keep in mind that there are people who think it's fun to "crack" passwords

    and get into other people's accounts. There are plenty of easily available"cracking" programs which make guessing easy passwords a cinch.

    Begin the "Changing Your Password" Exercise

    Getting Information

    The "man" commando The "man" command man gives you access to an on-line manual

    which potentially contains a complete description of every commandavailable on the system. In practice, the manual usually contains asubset of all commands.

    o man can also provide you with one line descriptions of commandswhich match a specified keyword

    o The online manual is divided into sections:

    Section Description------- -----------

    1 User Commands2 System Commands3 Subroutines4 Devices5 File Formats6 Games7 Miscellaneous

    8 System Administrationl Local Commandsn New Commands

    o Examples of using the man command:1. To display the manual page for the cp (copy files) command:

    man cp

    --More--23% at the bottom left of the screen means that

    only 23% of the man page is displayed. Press the space bar todisplay more of it or type q to quit.

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Passwordhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Passwordhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#Password
  • 8/2/2019 001_what is Unix

    17/34

    2. By default, the man page in section 1 is displayed if multiplesections exist. You can access a different section by specifyingthe section. For example:

    man 8 telnetd

    3. Keyword searching: use the -k option followed by thekeyword. Two examples appear below.

    man -k mailman -k 'copy files'

    4. To view a one line description of what a command does:whatis more

    will display what the "more" command does:

    more, page (1) - browse or page through atext file

    who - shows who is on the system

    whowho am i

    finger - displays information about users, by name or login name

    finger doefinger userid

    Begin the "Getting Information" Exercise

    Logging Off The System

    To finish using a UNIX system you must go through a process known as"logging out" or "logging off".

    To logout enter the command logout or exit. If this does not, work pressCtrl-d.

    If you have a .logout file in your home directory, the system will executeany commands contained there.

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#GettingInfohttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#GettingInfohttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#GettingInfo
  • 8/2/2019 001_what is Unix

    18/34

    Problems1. If you see the message There are stopped jobs it is a

    warning which tells you that there is a job which you suspendedearlier (Ctrl-z) or a job running in the background (discussed later).

    The simplest way to accomplish the logout is to just issue the logoutcommand again. Your suspended/background jobs will be terminatedand you will be logged off the system.

    2. If you see the messageNot login shell it means you areworking in another "shell" that has been started from within your"login shell" (shells will be discussed later).

    To logout, issue the exit command and then try to logout again.

    Begin the "Logging Off the System" Exercise

    This concludes the tutorial. Return to theTable of Contents

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#LoggingOffhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#LoggingOffhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/UnixIntro.html#GetStarthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/GetStart.Ex.html#LoggingOff
  • 8/2/2019 001_what is Unix

    19/34

    Hierarchical File Structure

    All of the files in the UNIX file system are organized into a multi-leveledhierarchy called a directory tree.

    A family tree is an example of a hierarchical structure that represents howthe UNIX file system is organized. The UNIX file system might also beenvisioned as an inverted tree or the root system of plant.

    At the very top of the file system is single directory called "root" which isrepresented by a / (slash). All other files are "descendents" of root.

    The number of levels is largely arbitrary, although most UNIX systemsshare some organizational similarities. The "standard" UNIX file system isdiscussed later.

    Example:

    / (root)|

    ---------------------| | |

    /bin /usr /tmp||

    -------------------| | |/public /misc /staff| |

    ------------ -------------------| | | | | |

    /software /doc /john /mary /bill /carl

    File Types

    The UNIX filesystem contains several different types of files:

  • 8/2/2019 001_what is Unix

    20/34

    Ordinary Fileso Used to store your information, such as some text you have written or

    an image you have drawn. This is the type of file that you usuallywork with.

    oAlways located within/under a directory file

    o Do not contain other files Directories

    o Branching points in the hierarchical treeo Used to organize groups of fileso May contain ordinary files, special files or other directorieso Never contain "real" information which you would work with (such

    as text). Basically, just used for organizing files.o All files are descendants of the root directory, ( named / ) located at

    the top of the tree. Special Files

    o Used to represent a real physical device such as a printer, tape driveor terminal, used for Input/Ouput (I/O) operations

    o Unix considers any device attached to the system to be a file -including your terminal:

    By default, a command treats your terminal as the standardinput file (stdin) from which to read its input

    Your terminal is also treated as the standard output file (stdout)to which a command's output is sent

    Stdin and stdout will be discussed in more detail latero Two types of I/O: character and blocko Usually only found under directories named /dev

    Pipeso UNIX allows you to link commands together using a pipe. The pipe

    acts a temporary file which only exists to hold data from onecommand until it is read by another

    o For example, to pipe the output from one command into anothercommand:

    who | wc -l

    This command will tell you how many users are currently logged intothe system. The standard output from the who command is a list of allthe users currently logged into the system. This output is piped intothe wc command as its standard input. Used with the -l option thiscommand counts the numbers of lines in the standard input anddisplays the result on its standard output - your terminal.

    File Names

  • 8/2/2019 001_what is Unix

    21/34

    UNIX permits file names to use most characters, but avoid spaces, tabs andcharacters that have a special meaning to the shell, such as:

    & ; ( ) | ? \ ' " ` [ ] { } < > $ - ! /

    Case Sensitivity: uppercase and lowercase are not the same! These are threedifferent files:

    NOVEMBER November november

    Length: can be up to 256 characters Extensions: may be used to identify types of files

    libc.a - archive, library fileprogram.c - C language source filealpha2.f - Fortran source filexwd2ps.o - Object/executable code

    mygames.Z - Compressed file

    Hidden Files: have names that begin with a dot (.) For example:

    .cshrc .login .mailrc .mwmrc

    Uniqueness: as children in a family, no two files with the same parentdirectory can have the same name. Files located in separate directories canhave identical names.

    Reserved Filenames:

    / - the root directory (slash). - current directory (period).. - parent directory (double period)~ - your home directory (tilde)

    Pathnames

    Specify where a file is located in the hierarchically organized file system Must know how to use pathnames to navigate the UNIX file system

  • 8/2/2019 001_what is Unix

    22/34

    Absolute Pathname: tells how to reach a file begining from the root; alwaysbegins with / (slash). For example:

    /usr/local/doc/training/sample.f

    Relative Pathname: tells how to reach a file from the directory you arecurrently in ( current or working directory); never begins with / (slash). Forexample:

    training/sample.f../bin~/projects/report.001

    For example, if your current directory is /usr/home/johnson and you wantedto change to the directory /usr/home/quattro, you could use either of thesecommands:

    cd ../quattro - relative pathnamecd /usr/home/quattro - absolute pathname

    File and Directory CommandsUNIX provides a number of commands for working with files. The more commonones are described in this section. Note that these commands usually have severaloptions and accept wildcard characters as arguments. For details, see the respectiveman pages which are hyperlinked to each command name.

    ls - lists files

    ls - show contents of working directoryls file - list file, if it exists in working directoryls dir - show contents of the directory dirls -a - shows all your files, including hidden onesls -al - give detailed listing of contentsls -F - mark directories with "/" and executable

    files with "*"ls *.doc - show all files with suffix ".doc"

    more - browses/displays files one screen at a time. Use h for help, spacebar topage, b for back, q to quit, /string to search for string

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/man/ls.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/ls.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/more.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/more.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/more.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/ls.txt
  • 8/2/2019 001_what is Unix

    23/34

    more sample.f

    pg - browses/displays files one screen at a time. Similar to the more utility infunction but has different commands and options. See the man page for details.

    pg sample.f

    less - similar to more, but with more features. Not available on every system.

    less sample.f

    head - displays the first n lines of a file

    head sample.f - display first 10 lines (default)head -5 sample.f - display first 5 lineshead -25 sample.f - display first 25 lines

    tail - displays the last n lines or n characters of a file

    less sample.f - display last 10 lines (default)less -5 sample.f - display last 5 lines

    less -5c sample.f - display last 5 charactersless -25 sample.f - display last 25 lines

    cat - dumps the entire file to the screen without paging. This command is moreuseful for concatenating (hence the name "cat") files together than it is forreading files.

    cat myprog.c - diplays entire filecat -b myprog.c - shows line numbers

    cat file1 file2 > file3 - adds file1 and file2 to makefile3

    cp - copies files. Will overwrite unless otherwise specified. Must also havewrite permission in the destination directory.

    cp sample.f sample2.f - copies sample.f to sample2.fcp -R dir1 dir2 - copies contents of directory

    dir1 to dir2cp -i file.1 file.new - prompts if file.new will be

    overwrittencp *.txt chapt1 - copies all files with .txt

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/man/pg.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/pg.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/less.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/less.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/head.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/head.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/tail.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/tail.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/cat.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/cat.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/cp.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/cp.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/cp.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/cat.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/tail.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/head.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/less.htmlhttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/pg.txt
  • 8/2/2019 001_what is Unix

    24/34

    suffix to directory chapt1cp /usr/doc/README ~ - copies file to your home

    directorycp ~betty/index . - copies the file "index" from

    user betty's home directoryto current directory

    mv - moves files. Will overwrite unless otherwise specified. Must also havewrite permission in the destination directory.

    mv sample.f sample2.f - moves sample.f to sample2.fmv dir1 newdir/dir2 - moves contents of directory

    dir1 to newdir/dir2mv -i file.1 file.new - prompts if file.new will be

    overwrittenmv *.txt chapt1 - moves all files with .txt

    suffix to directory chapt1

    rm - deletes/removes files or directories if file permissions permit.

    rm sample.f - deletes sample.frm chap?.txt - deletes all files with chap as the

    first four characters of their nameand with .txt as the last fourcharacters of their name

    rm -i * - deletes all files in current directory

    but asks first for each filerm -r /olddir - recursively removes all files in thedirectory olddir, including thedirectory itself

    Begin the Filesystem exercises - Part 1.

    file - identifies the "type" of file. The command syntax is:

    file filename

    For example:

    file * - reports all files in currentdirectory and their types. The

    output might appear as shown below:

    about.html: ascii text

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/man/mv.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/mv.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/rm.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/rm.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/Filesystem.Ex.html#Part1http://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/Filesystem.Ex.html#Part1http://www.mhpcc.edu/training/vitecbids/UnixIntro/man/file.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/file.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/file.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/exercises/Filesystem.Ex.html#Part1http://www.mhpcc.edu/training/vitecbids/UnixIntro/man/rm.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/mv.txt
  • 8/2/2019 001_what is Unix

    25/34

    bin: directorystaff.directory: English text

    bggen: executable or object module not strippedbmbinc: commands textmachines.sp1: [nt]roff, tbl, or eqn input textman2html: executable or object module not stripped

    man2html.c: ascii text

    find - finds files. The syntax of this command is:

    find pathname -name filename -print

    The pathname defines the directory to start from. Each subdirectory of thisdirectory will be searched.

    The -print option must be used to display results.

    You can define the filename using wildcards. If these are used, the filenamemust be placed in 'quotes'.

    find . -name mtg_jan92 -print - looks for the filemtg_jan92 in currentdirectory

    find ~/ -name README -print - looks for files calledREADME throughout your

    home directoryfind . -name '*.fm' -print - looks for all files with

    .fm suffix in currentdirectory

    find /usr/local -name gnu -type d -print- looks for a directorycalled gnu within the/usr/local directory

    diff- comparing two files or directories. Indicates which lines need be added(a), deleted (d) or changed (c). Lines in file1 are identified with a () symbol

    diff file1 file2 - compares file1 to file2diff -iw file1 file2 - compares two files ignoring

    letter case and spacesdiff dir1 dir2 - compares two directories

    showing files which areunique to each and also,line by line differencesbetween any files in common.

    For example, if file1 and file2 are:

    http://www.mhpcc.edu/training/vitecbids/UnixIntro/man/find.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/find.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/diff.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/diff.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/diff.txthttp://www.mhpcc.edu/training/vitecbids/UnixIntro/man/find.txt
  • 8/2/2019 001_what is Unix

    26/34

    John erpl08@ed John erpl08@edJoe [email protected] Joe [email protected] [email protected] Jean [email protected] keith@festival Jim jim@frolix8

    Kim [email protected]

    Keith keith@festival

    Using the diff command: diff file1 file2Yields the output:

    2a3,4> Jean [email protected]> Jim jim@frolix8

    Which means that to make these files match you need to add (a) lines 3 and

    4 (3,4) of file2 (>) after line 2 in file1.

    sdiff- similar to diff, but displays each line of the two files side by side, makingit easier for you to see the differences between them

    Lines that are different are shown with a | symbol. Lines unique to file1 areidentified by a < symbol; lines unique to file2 with a > symbol. Identicallines appear next to each other. The option -w 80 is used to set the width ofthe output from the command to 80 characters. The default is 130characters.

    sdiff -w 80 file1 file2Mike erpl08@ed | John erpl08@edJoe [email protected] Joe [email protected]

    > Jean [email protected]> Jim jim@frolix8

    Kim [email protected] Kim [email protected] s.wally@aston