CS 497C - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

CS 497C

Description:

UNIX obtains the list of directories that has to be searched from of an ... you evaluate the value of PATH, you'll find a directory list separated by colons: ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 17
Provided by: MitchN3
Category:
Tags: 497c | colons

less

Transcript and Presenter's Notes

Title: CS 497C


1
CS 497C Introduction to UNIXLecture 4
Understanding the UNIX Command
  • Chin-Chih Changchang_at_cs.twsu.edu

2
The PATH Locating Commands
  • UNIX obtains the list of directories that has to
    be searched from of an environment variable
    PATH.
  • If you evaluate the value of PATH, youll find a
    directory list separated by colons
  • echo PATH
  • /bin/usr/bin/usr/X11R6/bin/usr/local/bin.

3
The PATH Locating Commands
  • There are five directories in this list, and when
    you issue a command, the system will search this
    list in the sequence specified to locate and
    execute it.
  • . indicates the current directory.
  • To know in which directory the command is
    located, you can use the type command.
  • type ls
  • ls is /bin/ls

4
Internal and External Commands
  • The agency that actually does all this work is
    known as shell a command interpreter.
  • Since ls is a file having an independent
    existence in the /bin directory (or /usr/bin), it
    is called an external command. Most commands are
    external in nature.
  • The commands built in shell are known as internal
    commands.

5
Internal and External Commands
  • The type command itself is a shell built-in.
    Whether or not you are able to execute it depends
    on the shell you use.
  • In some versions of the C shell, the type command
    wont work. In this case, which or whereis can be
    used.
  • The shell uses its internal command even though
    there is an external command of the same name.

6
Command Structure
  • An UNIX command is composed of two parts command
    and argument.
  • Commands and arguments are separated by any
    number of spaces or tabs know as whitespace.
  • ls-l
  • ls-l Command not found.
  • The argument that begins with a symbol is
    called an option.

7
Options and Filenames
  • Every command has a fixed set of options.
  • The command with its arguments and options is
    entered in one line that is referred to as the
    command line.
  • Some commands accept a single filename, some
    accept more than one filenames.
  • Wrong options will be indicated.
  • An option can have its own arguments.
  • pine f mail-may

8
Combining Options
  • Options that begin with a sign can normally be
    combined with only one sign.
  • For instance, this command has three options
  • ls l a -t
  • The -l option provides most details of a files
    attributes. The t option sorts files according
    to the time of modification. The -a option
    lists the hidden files.

9
Combining Options
  • You can combine these options in this way
  • ls lat
  • ls -atl
  • This facility reduces your typing load. The shell
    parses (break up) the option combination into
    separate options.
  • Some commands wont let you combine options in
    the way you did just now.
  • tar cv f /dev/fd0 b 18

10
Combining Options
  • There are four options here, but two of them (-f
    and b) has their own arguments. These arguments
    are called option parameters.
  • We combined the c and v options here. We can
    combine the f and b options, provided that
    their own parameters are placed in the same
    sequence.
  • tar cvfb /dev/fd0 18
  • The following one wont work
  • tar cvfb 18 /dev/fd0

11
Exceptions and Variations
  • All commands dont compulsorily use options and
    arguments.
  • Commands like clear dont accept any argument.
  • The who and date commands may or may not be
    specified with arguments.

12
Exceptions and Variations
  • The ls command permits more variations
  • Without any argument (ls)
  • With only one option (ls l)
  • With only filenames (ls chap01 chap02)
  • Using a combination of both (ls la chap01
    chap02)
  • This text discusses commands that use options.
    The vast majority will conform to the option
    rules that have been discussed but there are some
    exceptions.

13
Flexibility of Command Usage
  • UNIX allows you to specify more than one command
    in the same command line. Each command is
    separated from the other by a (semicolon)
  • who ls -l
  • The is one of special characters that are
    understood by the shell. These special characters
    are known as metacharacters.

14
A Command Line Can Overflow
  • When a command has more characters than the
    terminal width, it simply overflows to the next
    line.
  • You may want to spread the command into multiple
    lines. The shell issues a secondary prompt,
    usually gt (or ?).
  • echo This is a two-line
  • gt text message
  • In C shell you have to enter a \ (backslash).

15
Flexibility of Command Usage
  • Subsequent commands can be entered at the
    keyboard without waiting for the prompt. There is
    a type-ahead buffer (a temporary storage area)
    which stores all these commands and passes them
    on for execution.
  • A command may not behave in the way you want
    because UNIX comes in many flavors.

16
Flexibility of Command Usage
  • The uname can print system information.
  • uname
  • Linux
  • The uname r command shows the version number of
    the kernel.
  • uname r
  • 2.2.19
Write a Comment
User Comments (0)
About PowerShow.com