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
- log into the box
- start a terminal
- where are you?
- view a directory listing to see what's there
- Create a file called "postfile.txt" (no quotes)
- Make a copy of the file called "postcopy.txt"
- make a [sub]directory under your home directory called "postdir"
- move the postcopy.txt file to the new directory
- 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.
- 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.
pico picofile: starts a file called picofile
mary had a little lamb: enters text into the file
[ctrl-o]: writes Out
[ctrl-x]: eXits the program
- vi - always available, exceedingly powerful, maddening to learn. Most notable characteristic: two-mode operation (insert and command).
vi vifile: starts a file called vifile
i: enters Insert mode
Mary had a little lamb: enters text into the file
[esc]: toggles mode (now in command mode)
: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+
emacs emacsfile: starts a file called emacsfile
mary had a little lamb: inserts text into the file
[ctrl-x][ctrl-s]: Saves file
[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.