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!

Intermediate Unix - Day 2

Goals

In this session you will:
  • learn simple scripting
  • use cronjobs
  • use simple utilities
  • learn to back up your files using tar, gz, and ftp
  • use ssh

POST

  1. log into your Solaris workstation
  2. open a terminal/console
  3. what shell are you in?
  4. How is filename completion implemented in bash?
  5. How is command history implemented in bash?
  6. How is filename completion implemented in ksh?
  7. How is command history implemented in ksh?
  8. If there was a make-believe unix application called fakeapp, what would be the likely configuration file for the app?
  9. Where would the config file be found?
  10. How might you find information about how it works?

shell scripting

  • like .bat file programming
  • cross-platform scripting is done in sh
  • invocation of a script: by explicitly name a shell, or use a magicline:
    #!/path/to/shell
  • no required extension
  • executable textfiles require both the R and X bits set (chmod)

cronjobs

  • a cronjob is a regularly scheduled task (cf. Task Manager in windows).
  • can run command[s] or scripts
  • STDOUT mailed to user
  • format: [mins] [hour] [date] [month] [day of week]
  • day of week is sunday=0
  • * = all occurrences
  • crontab -e: invoke an editor to edit your cron table
  • crontab -l > outfile : export crontab to textfile
  • crontab infile: read in crontab from file or STDIN

simple utilities

cat

sort

uniq

The bare essentials: find and grep

A regex is a regular expression, a precise way of describing a particular pattern in a string of characters.

use grep

  • grep regex file[s]
  • ls -l | grep regex
  • grep -i case insensitive
  • grep -v inverse
  • grep -c count lines that match the regex

use find

  • find /
  • find . | grep
  • find -atime +180
  • find /somedir -mtime +7
  • find -name pattern
  • find . -name *.txt -print
  • find . -name *.txt -exec cat {}\;

backup up your files

tar

tar (TapeARchive) is the orthodox way of collecting files into a bundle ("tarball") for storage, transportation, or backups.

Trick of the Trade
Although tar has about a billion switches, you will need only need to remember two things:
  1. tar xvf tarball will "xtract" a tarball
  2. tar cvf tarball target will "create" a tarball
  • man tar
  • tar does not compress natively, although some versions will allow you to do czvf/xzvf to invoke zip compression.

gzip

gzip file

ftp up to a remote server (emperor)

ssh

ssh, for our purposes, is like an encrypted telnet. Important switches:
  • -l: login name
  • -v : verbose
  • -C: enable compression

Homework

  • find out the name of your ISPs news server
  • download and install a news client
  • read news:comp.unix.questions
  • read news:comp.unix.solaris


http://www.mousetrap.net/syllabus/interunix/day2.html
$id$

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.