squeak!
Syllabus Homepage
Course Overview
Course resources
Day 1
Day 2
Day 3
Day 4
Common errors
Internet Glossary
About Your Instructor
Credits: This site powered by the vi text editor, apache webserver, perl scripting, and Debian linux.
squeak!
find your feet: pwd, ls -l.
man [topic] is your friend.

Intro to Unix - Day 2

Goals

In this session you will:
  • use user and group permissions and ownership
  • use unix text editors
  • learn IO redirection
  • learn how to configure your shell
  • learn how to configure your PATH and other ENVironmental variables

POST

  1. log into the box
  2. start a terminal
  3. where are you?
  4. view a directory listing to see what's there
  5. Create a file called "postfile.txt" (no quotes)
  6. Make a copy of the file called "postcopy.txt"
  7. make a [sub]directory under your home directory called "postdir"
  8. move the postcopy.txt file to the new directory
  9. from your home directory, show a listing of the files in the new directory. Leave the listing on your screen as evidence of your work.
  10. You are victorious; celebrate in the endzone.

Permissions and Ownership

"Relax. Enjoy a homebrew."

  • view a listing of your current dir
  • eyeball the chart on page 384. What can you tell about the files in your dir?
  • Understanding permissions: owners
  • Understanding permissions: groups
  • Understanding permissions: other folks

  • Directory permissions are a bit different: r=list, w=add remove delete rename, x=cd to the dir or execute.
  • Bonus: advanced weirdness: setuid, setgid, sticky bits. p386.

setting permissions

  • symbolic names: u=user, g=group, o=others, a=all others (default).
    + = add to existing, - = delete from existing, "=" = set explicitly to stated value only. pp.391-393
  • octal: 4=read, 2=write, 1=execute

changing groups and owner

  • changing a group ownership: chgrp [group] [target]. Can use -R recursion.
    Can see your groups with groups or id.
  • changing owner: chown [user] [target]. Can use -R recursion.
  • Some systems will allow compound user-group assignment: chown [user].[group] [target.
  • Default file-creation permissions: umask. umask is the complement of octal default chmod permissions, dirs: 777 - 022 = 755. Files 666 - 022 = 644. You can be as lax or paranoid as you want to be. Look ahead: setting umask in your login defaults.

Becoming someone else...

  • The wonders of su (dash) pp.370-71.

    Highlight p. 370

  • The extended wonders of sudo

editing!

A text editor is the unix user's most important tool. Gaining a working proficiency in your chosen text editor is the single most important step toward ease of use and productivity.
  • Pico - easiest to learn, very limited. Bundled with pine MUA. You will outgrow pico very soon.
    1. pico picofile: starts a file called picofile
    2. mary had a little lamb: enters text into the file
    3. [ctrl-o]: writes Out
    4. [ctrl-x]: eXits the program
  • vi - always available, exceedingly powerful, maddening to learn. Most notable characteristic: two-mode operation (insert and command).
    1. vi vifile: starts a file called vifile
    2. i: enters Insert mode
    3. Mary had a little lamb: enters text into the file
    4. [esc]: toggles mode (now in command mode)
    5. :wq: Writes and Quits the file
  • emacs - Byzantine complexity, easily and frequently extended for complex apps like news readers, programming IDEs, etc. Most notable characteristic: large size and extensive use of multi-key sequences. p.627+
    1. emacs emacsfile: starts a file called emacsfile
    2. mary had a little lamb: inserts text into the file
    3. [ctrl-x][ctrl-s]: Saves file
    4. [ctrl-x][ctrl-c]: Closes the file and quits

Introduction to unix utilities

  • echo: spray out some text from the command line
  • cat: spray out some text from a file (cf. DOS type)
  • more: a "paging" utility (cf. less)
  • grep: find strings in text
  • find: find strings in text (needs a default action like -print) p187-97

redirection

STDOUT, STDIN, STDERR

  • a quick example: ls -l > ls_output.txt
  • | : pipe; run output of one util into the input of another
  • >: redirect output to a file (overwrite)
  • >>: redirect output to a file (append)
  • <: redirect input from a file
  • /dev/null
  • find . -name txt 2> /dev/null

shell configuration

.dotfiles control behavior of your shell upon login: umask, w, etc.
  • .profile Bourne and variants (sh, bash, ksh, etc)
  • .cshrc C shell
  • .login C shell
  • .logout C shell
  • .forward forwards your mail
  • .plan/.project finger information
  • .signature email and other sigs
  • .exrc controls default vi behavior (ex for historical reasons)
  • .login C shell

altering the ENVironment

  • Bourne-like: export [variable]=[value]
  • Cshell: setenv [variable] [value]
  • EDITOR editor definition (also VISUAL), will be read by apps that require invocation of a text editor.
  • PATH search path for executables
  • TERM terminal emulation: VT100 and ANSI are safe, boring examples

Homework

  • read news:comp.unix.questions
  • read news:comp.unix.shell
  • elementary job control p423-25
  • other unixy utilities p494-5, 505-07, 520-22, 526-27.


http://www.mousetrap.net/syllabus/introunix/day2.html
$Id: day2.orb,v 1.20 2002/07/17 02:48:03 mouse Exp $

Remember, your login is based on your machine's hostname, not on any other number.
~/[initials] refers to the subdirectory under your homedir, named after your initials. Everything except for .dotfiles will be stored in your ~/[initials] directory.


© 1995-2001 jason carr
Distributed under the terms of the GNU Free Documentation License.