3 Linux

3.1

UNIX Linux , . UNIX : . Linux. 95% Linux UNIX-, - , Linux. .

. : ( ) - Linux. , UNIX, UNIX- Linux.

- , MS-DOS. MS-DOS, . UNIX MS-DOS ( - MS-DOS CP/M, , , UNIX). UNIX MS-DOS. , .

, , : . . . UNIX , "" ( ) . , - , , . : , , , "" .

3.2 UNIX

UNIX , . , , . ( MS-DOS, ). UNIX , : (, ) , ( ). , .

UNIX- ( ). , ( ) , ( 3.2.1 ). ``larry''.

, UNIX hostname ( ). . Hostname , , hostname. 4.10.2 hostname . , , - ``mousehouse'' ( ).

( )

, , . , (root) . root , 4.1.

, , root useradd adduser. 4.4.

, , :

    mousehouse login:

Return. larry :

    mousehouse login:  larry
    Password:

(password). , . ,

    Login incorrect
.

, .

- , . ( UNIX , , , ). Linux, UNIX, ( VC), .

( ). alt-F2. login: , , . VC, alt-F1. -! .

Linux VC, alt-F1 alt-F4. 12- VC - . , VC - VC .

, ( , ) UNIX. VC #1, VC #2 - .

Shells

UNIX shell. Shell - , , (.. , ) . COMMAND.COM MS-DOS, . Shell - UNIX. , X Window System, .

, shell . . Larry :

    mousehouse login:  larry
    Password:  larry's password
    Welcome to Mousehouse!
    /home/larry#

``/home/larry#'' shell, , . ( y ). - :

    /home/larry# make love
    make:  *** No way to make target `love'.  Stop.
    /home/larry#

, , "make" - shell . (, ).

: ? , ``make love''? ``make'' , . .

:

    /home/larry# cp foo bar

``cp'', ``foo'' ``bar''.

, shell . -, , () shell . (, , shell . , ). Shell , . , shell . shell , , .

shell make love. make - , , "" . ``make love'' make love. make , ( ) .

, , shell ? :

    /home/larry# eat dirt
    eat:  command not found
    /home/larry#

, shell ( ``eat''), , ' . , . (, ``mkae love'' ``make love'').

, , , . shell

    /home/larry# exit
. , .

, . "passwd" . : . . ! , ( , 4.4).

( UNIX) , , , . : , , , , . , , , .

. , , my-paper. - . , MS-DOS ; ( / - "") 256 .

. - . "", . , . , .. .

(pathname), , , , , Larry , papers, : history-final, english-lit, masters-thesis. ( Larry ). , english-lit, Larry :

    papers/english-lit

, (/). . MS-DOS - , MS-DOS (\).

, . , Larry papers notes. math-notes cheat-sheet. cheat-sheet

    papers/notes/cheat-sheet

- , , . () . papers notes.

UNIX , . , ``/'', " ". / : /bin, /etc, /dev, /usr. , , ..

, , . Larry ( cheat-sheet history-final) Larry. /home . Larry /home/larry.

. 3.2.8 . , .

, shell, . , . ( /home/larry). , , .

/_____bin
    |_dev
    |_etc
    |_home_____larry
    |        |_sam
    |_lib
    |_proc
    |_tmp
    |_usr__X386
         |_bin
         |_emacs
         |_etc
         |_g++-include
         |_include
         |_lib
         |_local_____bin
         |         |_emacs
         |         |_etc
         |         |_lib
         |_man
         |_spool
         |_src_____linux
         |_tmp



      3.1:  ()   Unix

, Larry papers, papers history-final. Larry ,

    /home/larry# more /home/larry/papers/history-final

more . Larry /home/larry, .

    /home/larry# more papers/history-final

( papers/final) , ``/'', , . ( - () - .. ).

(shell), .. , , ( ) . Linux tcsh bash . tcsh bash , (``~''). ,

    /home/larry# more ~/papers/history-final

    /home/larry# more /home/larry/papers/history-final

``~'' .

. ``~karl/letters'' shell, ``/home/karl/letters'' ( /home/karl - karl). ; ``~'' - " ", shell.

3.3 UNIX

, , , ( MS-DOS). , make Make MAKE. .

, , . - cd, (``change directory''). , Unix - . cd:

    cd <directory>
<directory> - , . , , . Larry ,

    /home/larry# cd papers
    /home/larry/papers#

, , ( ). papers history-final

    /home/larry/papers# more history-final

papers,

    /home/larry/papers# cd ..
    /home/larry#

( ``cd'' ``..''). ``..'' , ( ) . ``.'', .

    /home/larry/papers# cd .

.

cd . ,

    /home/larry/papers# cd /home/karl
    /home/karl#

cd .

    /home/karl# cd
    /home/larry#

, - , :" ?" , ls. ls (LiSt) ( ). ,

    /home/larry# ls
    Mail
    letters
    papers
    /home/larry#

, Larry " " : Mail, letters papers. , : ? (. : UNIX "") -F ls, .

    /home/larry# ls -F
    Mail/
    letters/
    papers/
    /home/larry#

/ , ().

ls -F ( "-F" ) ``*'' . , . , ls -F, , "" , .. .

, UNIX . ``-'', ls -F. -F ls, .

ls , .

    /home/larry# ls -F papers
    english-lit
    history-final
    masters-thesis
    notes/
    /home/larry#

, , , /etc/.

    /home/larry# ls /etc

Images       ftpusers     lpc          rc.new     shells
adm          getty        magic        rc0.d      startcons
bcheckrc     gettydefs    motd         rc1.d      swapoff
brc          group        mount        rc2.d      swapon
brc~         inet         mtab         rc3.d      syslog.conf
csh.cshrc    init         mtools       rc4.d      syslog.pid
csh.login    init.d       pac          rc5.d      syslogd.reload
default      initrunlvl   passwd       rmt        termcap
disktab      inittab      printcap     rpc        umount
fdprm        inittab.old  profile      rpcinfo    update
fstab        issue        psdatabase   securetty  utmp
ftpaccess    lilo         rc           services   wtmp
/home/larry#

( MS-DOS , 8 . ).

(. : , UNIX " (root)") , ``cd ..'', (/usr/bin ).

    /home/larry# cd ..
    /home# cd ..
    /# cd usr
    /usr# cd bin
    /usr/bin#

, , , , cd /usr/bin.

, ls cd. ``Permission denied''( ). UNIX, . 3.9.

, . mkdir. :

    /home/larry# mkdir foo
    /home/larry# ls -F
    Mail/
    foo/
    letters/
    papers/
    /home/larry# cd foo
    /home/larry/foo# ls
    /home/larry/foo#

! . , , .

cp (CoPy):

       /home/larry/foo# cp /etc/termcap  .
       /home/larry/foo# cp /etc/shells  .
       /home/larry/foo# ls -F
       shells     termcap
       /home/larry/foo# cp shells bells
       /home/larry/foo# ls -F
       bells     shells     termcap
       /home/larry/foo#

cp , , , . (. : cp ; ). , ``.'' .

mv (MoVe) . .

       /home/larry/foo# mv termcap sells
       /home/larry/foo# ls -F
       bells     sells     shells
       /home/larry/foo#

, termcap , sells. , . .

! mv cp ( ), . , : .

"" , ls. rm (ReMove).

    /home/larry/foo# rm bells sells
    /home/larry/foo# ls -F
    shells
    /home/larry/foo#

, shells, . , rm , .

rm rmdir. , . - , .

more cat . more "", , cat . (. : , , cat ).

shells,

    /home/larry/foo# more shells

more b . q, more.

cat etc/termcap/. , . ``cat'' (conCATenate) , . .

UNIX , "" - man ( ``manual pages''). man , , . , ls,

    /home/larry# man ls

.

, , . , .

, . , .

, , . , . . - (the Linux Documentation Project - Linux . ). -, shell (alias), 3.2.4, . cd, shell. Shell , .

3.4

UNIX, , .

, ``-'' , . , ls -l -F, ls -lF.

, , . , ( ). man .

, , , ``<file1> ... <fileN>''. , cp , , . .

cd

.
: cd <directory>;
<directory> - , (``.'' , ``..'' - ).
: cd ../foo ../foo.

ls

.
: ls <file1> ... <fileN>
<file1> ... <fileN> , .
: , . : -F ( ), -l ( (``long'') , , .. ).
: ls -lF /home/larry /home/larry.

cp

() .
: cp <file1> ... <fileN> <destination>
<file1> ... <fileN> , <destination> , .
: cp ../frog joe ../frog joe.

mv

() . . , RENAME MS-DOS.
: mv <file1> ... <fileN> <destination>
<file1> ... <fileN> , <destination> , .
: mv ../frog joe ../frog joe.

rm

. , UNIX , ( MS-DOS, "" ).
: rm <file1> ... <fileN>
<file1> ... <fileN> .
: -i .
: rm -i /home/larry/joe /home/larry/frog joe frog /home/larry.

mkdir

.
: mkdir <dir1> ... <dirN>
<dir1> ... <dirN> .
: mkdir /home/larry/test test /home/larry.

rmdir

. rmdir .
: rmdir <dir1> ... <dirN>
<dir1> ... <dirN> .
: rmdir /home/larry/papers /home/larry/papers, .

man

. ( "" - , , ).
: man <command>
<command> , .
: man ls - ls.

more

.
: more <file1> ... <fileN>
<file1> ... <fileN> .
: more papers/history-final papers/history-final.

cat

. cat
: cat <file1> ... <fileN>
<file1> ... <fileN> .
: cat letters/from-mdw letters/from-mdw.

echo

.
: echo <arg1> ... <argN>
<arg1> ... <argN> "" .
: echo "Hello world" ``Hello world''.

grep

(), .
: grep <pattern> <file1> ... <fileN>
<pattern> - ( ) <file1> ... <fileN> - , .
: grep loomer /etc/hosts , /etc/hosts, ``loomer''.

3.5

. - . , . ( . 3.2.8).

- (cd /) ls -F. , , : bin, dev, etc, home, install, lib, mnt, proc, root, tmp, user, usr var. ( - , Linux ).

.

/bin

bin - ``binaries'' (.. ). . ``ls -F/bin'' . , cp, ls mv. . , , cp, /bin/cp.

ls -F, , ( ) /bin (``*''). , , 3.3.2.

/dev

- dev. ls -F.

"" /dev - , , , .. , , , /dev/mouse. , fd - . fd0 - , fd1 - . , , , : . , fd1H1440 high-density, 3.5" 1.

.

  • /dev/console/ , .. , .
  • /dev/ttyS /dev/cua . , /dev/ttyS0 ``COM1'' MS-DOS. /dev/cua "" (``callout'') , .
  • , hd, . /dev/hda , hda1 /dev/hda.
  • , sd - SCSI-. SCSI , /dev/hda, /dev/sda. SCSI st, SCSI CD-ROM sr.
  • lp . /dev/lp0 ``LPT1'' MS-DOS.
  • /dev/null " " - , , . , /dev/null. .
  • /dev/tty " " ( alt-F1, alt-F2 ..). /dev/tty1 VC, /dev/tty2 ..
  • , /dev/pty, "". "". , , telnet /dev/pty.

/etc

/etc . /etc/passwd ( ), /etc/rc ( ) ..

/sbin

/sbin , .

/home

home . , /home/larry - ``larry''. .

/lib

/lib (shared library images). , . , , - /lib. .

/proc

/proc - " ", , . , , , . 3.11.1.

/tmp

, . /tmp ( ).

/usr

/usr - . , , .

, , , , /usr . , . /usr , , cp ls. /usr , .

/usr/X386

/usr/X386 The X Window System, . The X Window System - , , "" . Microsoft Windows Macintosh environments, X Windows . /usr/X386 X Window, . 5.1.

/usr/bin

/usr/bin UNIX. , , , /bin .

/usr/etc

, /etc, . /usr/etc . , , /usr/etc , , /etc, .

/usr/include

/usr/include include- . ( .h ( ``header'') ' , , . , /usr/include/sys UNIX. , ( , ), stdio.h, , printf().

/usr/g++-include

/usr/g++-include include- C++ ( /usr/include).

/usr/lib

/usr/lib -"" "" , /lib. "" , /usr/lib, /lib, . , /usr/lib .

/usr/local

/usr/local /usr - , , . , , /usr/local , .. /usr/local UNIX. , TeX ( ) Emacs ( ), .

/usr/man

. "" . ( "man man" ). , /usr/man/man1 ( ) 1 /usr/man/cat1 1.

/usr/src

/usr/src ( ) . , /usr/src/linux, Linux.

/var

/var , . "" /usr, , , /var. :

/var/adm

/var/adm , , , , . , . 4.

/var/spool

/var/spool , . , , /var/spool/mail , . /var/spool/news ..

3.6

, UNIX - , . - , . , , ' , .

, , (shell). , UNIX ( ) - , . UNIX.

- , , ( ). , (shell-scripts), ' . MS-DOS ``batch-''. (shell) - , UNIX. 3.13.1.

UNIX. - ``Bourne shell''(shell ) ``C shell'. Shell ( shell) , UNIX ( UNIX System III). UNIX- shell /bin/sh ( sh ``shell''). C shell , - . UNIX- /bin/csh.

Linux . , Shell (Bourne Again Shell) ``Bash'' (/bin/bash) Tcsh (/bin/tcsh). Bash - shell , C shell. Bash shell, , shell Bash. , C shell, Linux Tcsh, C shell.

, - . shell , Bash, - C shell. "" , cp ls, shell . , .

shell C shell. ( , bash tcsh).

3.7 "" - " "

Unix - , , . , " " (wildcards), , , , "n". (. : (wildcards), "" "" - . - "". , shell, , ).

``*'' . , ``*'' shell , . . , Larry frog, joe stuff :

    /home/larry# ls
    frog     joe     stuff
    /home/larry#

``o'' ,

    /home/larry# ls *o*
    frog     joe
    /home/larry#

, ``*'' .

``*'' , .

    /home/larry# ls *
    frog     joe     stuff
    /home/larry#

.

    /home/larry# ls f*
    frog
    /home/larry# ls *ff
    stuff
    /home/larry# ls *f*
    frog     stuff
    /home/larry# ls s*f
    stuff
    /home/larry#

``*'' shell. : , ls, ``*'' . Shell, , , .

    /home/larry# ls *o*

      shell  

    /home/larry# ls frog joe

``*'' . , (``.''). "", . , ls ``*'' .

. , : ``.'' - ``..'' - . , ls, .

    /home/larry# ls
    frog     joe     stuff
    /home/larry#

-a ls, , ``.'':

    /home/larry# ls -a
    .      ..      .bash_profile      .bashrc      frog        joe
    stuff
    /home/larry#

, ``.'' ``..'', , "" - .bash_profile .bashrc. larry . 3.13.3.

, ``*'' , , , ``.'' .

    /home/larry# ls *
    frog     joe     stuff
    /home/larry#

: ``*'' , ``.'', ``.'' ``..''. .

``?''. ``?'' . ``ls ?'' , , ``ls termca?'' ``termcap'', ``termcap.backup''. :

    /home/larry# ls j?e
    joe
    /home/larry# ls f??g
    frog
    /home/larry# ls ????f
    stuff
    /home/larry#

, . 3.4 , cp mv . ,

    /home/larry# cp /etc/s* /home/larry

/etc , ``s'' /home/larry. cp

    cp <file1> ... <fileN> <destination>

<file1> ... <fileN> - , <destination> , . mv .

, , , <destination> . .

3.8 UNIX

UNIX ( ) . ( ``stdin'' ``stdout'' ). shell , , - .

cat. cat , stdout.

    /home/larry/papers# cat history-final masters-thesis

history-final, masters-thesis.

cat , stdin stdout. .

    /home/larry/papers# cat
    Hello there.
    Hello there.
    Bye.
    Bye.
    [ctrl-D]
    /home/larry/papers#

, , , cat . , , - EOT (End-Of-Text). ctrl-D.

. sort ( stdin, , stdout. .

    /home/larry/papers# sort
    bananas
    carrots
    apples
    [ctrl-D]
    apples
    bananas
    carrots
    /home/larry/papers#

, , ... UNIX ?

, , , - . Shell , ``>''. .

    /home/larry/papers# sort > shopping-list
    bananas
    carrots
    apples
    [ctrl-D]
    /home/larry/papers#

, sort , shopping-list ( ). .

    /home/larry/papers# cat shopping-list
    apples
    bananas
    carrots
    /home/larry/papers#

() , ! , items. , , , .

    /home/larry/papers# sort items > shopping-list
    /home/larry/papers# cat shopping-list
    apples
    bananas
    carrots
    /home/larry/papers#

-. , , ``<''.

    /home/larry/papers# sort < items
    apples
    bananas
    carrots
    /home/larry/papers#

, sort < items sort items, : sort < items , items . shell . sort (items) , .

. , , , - . . sort - : . cat - : , , , .

, sort . , - , . , , , , , ls? -r, , . , :

    /home/larry/papers# ls
    english-list
    history-final
    masters-thesis
    notes
    /home/larry/papers# ls > file-list
    /home/larry/papers# sort -r file-list
    notes
    masters-thesis
    history-final
    english-list
    /home/larry/papers#

ls , sort -r . ls.

(pipeline) (. : "", "pipeline"). - shell, , stdout stdin . stdout ls stdin sort. ``|'' :

    /home/larry/papers# ls | sort -r
    notes
    masters-thesis
    history-final
    english-list
    /home/larry/papers#

, , . .

    /home/larry/papers# ls /usr/bin

, , . /usr/bin more.

    /home/larry/papers# ls /usr/bin | more

.

! , . head , (, ). , , :

    /home/larry/papers# ls | sort -r | head -1
    notes
    /home/larry/papers#

head -1 ( , ls).

``>'' , ( , ),

    /home/larry/papers# ls > file-list

file-list. ``>>'', ( , ).

    /home/larry/papers# ls >> file-list

ls file-list.

, , , shell, shell ``>'', ``>>'' ``|'' , .

3.9

UNIX - , , UNIX , , . . , Larry , Larry .

UNIX . Larry , , . , .

' , . , , , . . , .

. , UNIX , , , . (. : , ""...).

- ( bin admin), . .

: (read), (write) (execute). : , , , () .

, - (, , ls). . , . , ( , ). cd.

, . ls -l "" , .


    /home/larry/foo# ls -l stuff

    -rw-r--r--   1 larry    users         505 Mar 13 19:05 stuff

    /home/larry/foo#

. - (larry) - (users). , (stuff), .

larry, users. . -rw-r--r-- , .

(``-'') . ``-'' , ( - ). (``rw-'') , larry. ``r'' ``read''(), ``w'' - ``write''(). larry stuff .

, ``execute'' - ``x''. ``-'', Larry . , stuff . , Larry , , . .

r-- . users. ``r'', .

r--, .

.

-rwxr-xr-x

, . .

-rw-------

. .

-rwxrwxrwx

.

, , , . , -rwxrwxrwx, , , . , Larry , /home/larry drwx------. , , . Larry .

, , , , .

UNIX . -rw-r--r--, , . drwxr-xr-x, . .

. , -rw------- . drwx------ .

chmod () . .

:

    chmod {a,u,g,o}{+,-}{r,w,x} <filenames>

, all (), user (), group () other (). , (+), (-). , : read, write execute. :

chmod a+r stuff

stuff.

chmod +r stuff

, (a - ).

chmod og-x stuff

, .

chmod u+rwx stuff

(read, write execute).

chmod o-rwx stuff

(read, write execute) (other).

3.10

. , . ls -i . - . .

ln . , , foo. ls -i .

    # ls -i foo
    22192 foo
    #

foo 22192. bar:

    # ln foo bar

ls -i , .

    # ls -i foo bar
    22192 bar   22192 foo
    #

, foo bar . , - foo, bar.

, (hard links), . , ; ( ) .

rm, .

    # rm foo

, foo; bar . , . , rm . , , rm ; , , .

ls -l ( )

    # ls -l foo bar
    -rw-r--r--   2 root     root          12 Aug  5 16:51 bar
    -rw-r--r--   2 root     root          12 Aug  5 16:50 foo
    #

``2'' .

, "-". , : ``.'' (, ) ``..'' (, ). (/) ``..'' /.

, , . , .

ln -s . ,

    # ln -s foo bar

bar, foo. ls -i, , .

    # ls -i foo bar
    22195 bar   22192 foo
    #

, ls -l, , bar foo.

    # ls -l foo bar
    lrwxrwxrwx   1 root     root           3 Aug  5 16:51  bar -> foo
    -rw-r--r--   1 root     root          12 Aug  5 16:50 foo
    #

( , rwxrwxrwx). , , , , ( foo).

, , . , , ; . , . , . , , ; , .

Linux. /lib. 4.7.2.

3.11

(job control) , , (Bash Tcsh). (. : job - IBM/360 "", ) . , , .

, , , , . - . ps . :

    /home/larry# ps

      PID TT STAT  TIME COMMAND
       24  3 S     0:03 (bash)
      161  3 R     0:00 ps

    /home/larry#

PID (Process IDentificator), , .

(COMMAND) . , Larry. ( . ``ps -aux'' ).

bash ( , Larry) ps. , bash ps. bash ps, Larry . ps ( , ), bash, .

shell . . , "", (job control)- shell, .

, shell . , , , . ? , - . , shell, - . , , . . .

, . . , , , . (, , , , 3.8). , , ( - ) , .

. - , . , , . . , .

. - , . , , , . - , .

, , . ( , ctrl-C), . ( stty. ctrl-C, ). , , , , . , , ctrl-C . . .

. yes - , "y" . ( . "y" , yes "no" , "y" ). .

    /home/larry# yes
    y
    y
    y
    y
    y

. , ; ctrl-C. "y", /dev/null. , /dev/null " " . .

    /home/larry# yes > /dev/null

, . , shell . , , "y" /dev/null. , .

, , yes , shell, . yes , , .

, ``&''.

    /home/larry# yes > /dev/null &;
    [1] 164
    /home/larry#

, . ``1 164''? yes ?

``1'' yes. Shell . "yes" - , , 1. ``164'' - (PID); , . , .

yes , "y"- /dev/null. , shell - jobs.

    /home/larry# jobs
    [1]+  Running                 yes >/dev/null  &
    /home/larry#

, . ps, , .

kill. , . 1,

    /home/larry# kill %1

. (``%'').

, , jobs :

    /home/larry# jobs

    [1]+  Terminated              yes >/dev/null

    /home/larry#

, jobs, .

, (PID), , ( ). PID 164,

    /home/larry# kill 164

     

    /home/larry# kill %1

``%'', .

. ( ), .

"":

    /home/larry# yes > /dev/null

, shell.

, , ctrl-C, . . , , ctrl-Z.

    /home/larry# yes > /dev/null
    [ctrl-Z]
    [1]+  Stopped                 yes >/dev/null
    /home/larry#

, . . , .

fg (``foreground'' - ).

    /home/larry# fg
    yes >/dev/null

Shell , , . ctrl-Z. bg (``background'' - , ), . , ``&''.

    /home/larry# bg
    [1]+ yes >/dev/null &
    /home/larry#

. jobs , yes , kill, .

? ctrl-Z , . - , . fg , , .

. , , , ( , ). , . - , , - . , :

    /home/larry# yes &

stdout /dev/null, "y" ( ctrl-C ). , fg , ctrl-C, .

. fg bg , ( ``+'' , jobs). , , , fg bg,

    /home/larry# fg %2

( 2)

    /home/larry# bg %3

( 3).

. , ,

    /home/larry# %2

     

    /home/larry# fg %2

, , shell. fg, bg jobs - shell. - shell, , .

, , Bash Tcsh. , Linux .

3.12 vi

, , , , , - . Linux , , UNIX - vi (``visual editor''). vi - . UNIX , - .

, . Emacs - , UNIX. , Emacs LISP ( ``Eliza''- ). , Emacs , . vi, , , , , . , , . .

- vi. , , , . , .

vi . , .

vi - . . , ``x'' , , . . , , .

. vi , , . ``i'' (``insert'' - ) . , . esc.

- , . . , ``:'' , , ``wq'' ( (write) (quit) vi), ``q!'' ( vi ). vi, . enter .

vi

, vi . ``screens'', , , ( ).

      vi

     vi <filename>

<filename> - .

vi,

     /home/larry# vi test

test.

____________________________________________________________________
|~_                                                                 |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|"test"_[New_file]__________________________________________________|

``~'' , .

; , , i ( ) .

 ____________________________________________________________________
|Now is the time for all good men to come to the aid of the party._ |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, ( return ), (backspace).

esc.

. , , "" "" , vi .

, i. , a , , . ``good'' ``men''.

 ____________________________________________________________________
|Now is the time for all good_men to come to the aid of the party.  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

a, , ``wo'', esc .

____________________________________________________________________
|Now is the time for all good women to come to the aid of the party.|
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, , ``''. , o

 ____________________________________________________________________
|Now is the time for all good women to come to the aid of the party.|
|Afterwards, we'll go out for pizza and beer._                      |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, ( , i, a o ) ( , esc ) ( , ).

"x" . x , :

 ____________________________________________________________________
|Now is the time for all good women to come to the aid of the party.|
|Afterwards, we'll go out for pizza and _                           |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

a, , esc:

 ____________________________________________________________________
|Now is the time for all good women to come to the aid of the party.|
|Afterwards, we'll go out for pizza and Diet Coke._                 |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, dd (.. d ). , dd,

 ____________________________________________________________________
|Now is the time for all good women to come to the aid of the party.|
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, , dw. ``good'' dw.

 ____________________________________________________________________
|Now is the time for all women to come to the aid of the party.     |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, R. ``party'', R ``hungry''.

 ____________________________________________________________________
|Now is the time for all women to come to the aid of the hungry._   |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

R i a, R . r , . , ``Now'' r, C, :

 ____________________________________________________________________
|Cow is the time for all women to come to the aid of the hungry._   |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

``˜'' , : . , ``o'' ``Cow'' ~, :

 ____________________________________________________________________
|COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY.    |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~__________________________________________________________________|

, . h, j, k, l , , . , ( - ) .

w ; b - .

0 ( ) , $ .

. ctrl-F , ctrl-B - .

, , G. , 10G . , ( ), 1G.

, . , d$ ; dG ..

vi

vi :q!.

``:'', , .

 ____________________________________________________________________
|COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY.    |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|:__________________________________________________________________|

. - q!, vi . :wq () , vi. ZZ ( , `:'') :wq. , enter . /vi, :w.

, , :e. , test foo,

 ____________________________________________________________________
|COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY.    |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|:e foo_____________________________________________________________|

:e , .

 ____________________________________________________________________
 |No_write_since_last_change_(":edit!"_overrides)____________________|

, vi , . :w, , :e

 ____________________________________________________________________
|COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY.    |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|~                                                                  |
|:e! foo_____________________________________________________________|

``!'' vi, - , .

:r, . ,

    :r foo.txt

foo.txt .

Shell

vi. :r! :r, , , . ,

    :r!  ls -F

 ____________________________________________________________________
|COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY.    |
|letters/                                                           |
|misc/                                                              |
|papers/_                                                           |
|~                                                                  |
|~__________________________________________________________________|

a, vi ,

    :!  ls -F

ls -F, , .

    :shell

vi shell, "" vi . shell ( exit) vi.

vi ( UNIX- ), vi. vi - " " ex; ex vi. vi ex.

3.13

Shell . , shell , - . shell , UNIX shell.

, . , Tcsh , , shell . , , shell (. f: ).

shell

. : script - "", , "" " shell" " "

, ' . ,

    /home/larry# cat chapter1 chapter2 chapter3 > book
    /home/larry# wc -l book
    /home/larry# lp book

' , : chapter1, chapter2, chapter3 book. ( book) , , lp.

, ( ). shell 3.13.1. , ,

    #!/bin/sh
    # A shell script to create and print the book

    cat chapter1 chapter2 chapter3 > book
    wc -l book
    lp book

makebook,

    /home/larry# makebook

. shell - , emacs vi. (vi 3.12)

. ``#!bin/sh/'' , shell, . bin/sh/, bin/sh/ - shell. ? UNIX bin/sh/ - shell , bash. shell , bin/sh/, , shell ( , , C shell). shell , Tcsh ( - C shell) .

. ``#'' - shell .

- , . Shell , shell.

. , , . , () .

       /home/larry# chmod u+x makebook

shell- makebook.

shell

Shell , . - , . (. : shell ( ), - "", : ).

! , Tcsh, , C shell, , . shell . ( ``='' ), , ``$'',

       /home/larry# foo=``hello there''

foo ``hello there''. , ``$''.

       /home/larry# echo $foo
       hello there
       /home/larry#

,

       /home/larry# echo ``hello there''
       hello there
       /home/larry#

shell. , shell . ; , , , . set shell.

Shell . - , . shell (. : - " "), export .

! Bash Tcsh. Tcsh ( setenv). Tcsh.

UNIX. , .

. PAGER man. , man . PAGER , more ( ).

PAGER ``cat''. , , more.

       /home/larry# PAGER=cat

PAGER .

       /home/larry# export PAGER

man ls. () .

, PAGER ``more'', more.

       /home/larry# PAGER=more

, export PAGER. ; , , .

, - . , man , PAGER. , , EDITOR .

. HOME .

    /home/larry/papers# echo $HOME
    /home/larry

- PS1, shell. ,

    /home/larry# PS1=``Your command, please:  ''
    Your command, please:

( , ``#''), :

    Your command, please:  PS1=``\w# ''
    /home/larry#

bash , .

PATH

ls, shell () ls? ls /bin/ls. shell PATH ("") .

, PATH

    /bin:/usr/bin:/usr/local/bin:.

( shell ), ``:''. ls, shell /bin/ls, /usr/bin/ls ..

, PATH . ,

    /home/larry# cp foo bar

shell PATH foo bar - , . shell PATH cp.

; , , . , /usr/bin, /bin /usr/local/bin. , ( /usr/bin/cp), PATH , , shell .

, PATH ``.'', " ". shell- , ( ./makebook). PATH, shell , .

Shell-

shell-, , , shell . , shell .

- , . . , mail , .

Bash, Tcsh shell ( ) shell. shell ; shell, . shell , vi, () shell. , shell-, shell.

, Bash: /etc/profile ( , bash, ), $HOME/.bash_profile ( ) $HOME/.bashrc ( bash). .bash_profile , .profile.

Tcsh : /etc/csh.login ( tcsh ), $HOME/.tcshrc ( tcsh) $HOME/.login ( .tcshrc). .tcshrc , .cshrc.

, , shell. shell , . bash tcsh.

3.14

, , . , Linux - . . , - Linux , . - . , , .

- UNIX. UNIX , - , . UNIX A.

. , .

,

,