------------------------ Week 4 Notes for DAT2330 ------------------------ -Ian! D. Allen - idallen@idallen.ca *** Keep up on your readings (Course Outline: average 5 hours/week homework) Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) Reminder: Midterm Test #1 is in Week #5 (see the Course Home Page). - You all were sent email about this test on Sunday January 22. - See Notes file termtest1directions.txt for the test format. In Week 4 (see also week03notes.txt) you did this: Review Class Notes: arguments_and_options.txt Options and Arguments on Unix Command Lines datsubmit.txt Using the datsubmit command file_transfer.txt File transfer between machines home_and_HOME.txt Directories: current, HOME, and /home miscellaneous.txt Miscellaneous Unix Facts pathnames.txt Unix/Linux Pathnames shell_basics.txt The Unix Shell shell_prompt.txt Setting the BASH shell prompt startup_files.txt Setting up Startup Files: .profile and .bashrc Readings in "Practical Guide to Linux (2005 edition) [PGL]": - chapter 1 - welcome to Linux - chapter 2 - getting started - correcting Mistakes - getting help (man) - consoles - password - chapter 3 - command line utilities (read up on the ones we use) ls cat rm cp less hostname mv grep head tail sort uniq diff file echo date script unix2dos bzip2 bunzip2 bzcat bzip2recover gzip gunzip zcat compress tar which whereis apropos slocate who finger w write mesg - chapter 4 - the linux filesystem - chapter 5 - the shell - chapter 6 - the vim editor - read up on file locks and aborted sessions p.152 - concentrate on learning the commands covered in the online vim tutorial Shell - see Notes files: shell_basics.txt, arguments_and_options.txt - arguments_and_options.txt Options and Arguments on Unix Command Lines - shell splits line into separate commands, perhaps joined by pipes - pipes separate commands but join output: grep foo /etc/passwd | wc - you can also use ';' to fully separate commands: sleep 4 ; echo BOO - next, shell splits each separate command into options and arguments More on Pathnames: see Notes file: pathnames.txt - New: hidden files, ls -a to see them - empty dir ; ls and hidden pathnames (define what is a hidden pathname) - making and removing directories (chapter 4) - rm -r to remove a whole directory (not rmdir!) - show simple directory traversal - absolute path ; relative path (pathnames.txt) - mkdir foo ; cp /etc/passwd foo/bar ; ls mkdir bar ; cp /etc/passwd . ; mv passwd bar ; ls mkdir xxx ; cp /etc/passwd . ; mv passwd xxx/../yyy ; ls Review: cp pwd rm mv Review: dot and dot dot New: cd, mkdir, rmdir, rm -r New commands and/or command options (read text chapter 3): grep -v -w sort -n -u -r uniq -c diff -u which whereis slocate w New Class Notes presented: finding_files.txt Searching for and finding files by name glob_patterns.txt GLOB patterns (wildcard pathname matching) Finding Files - see Notes file finding_files.txt The shell can expand file GLOB patterns - see Notes file glob_patterns.txt - similar to DOS wildcard; but, the shell does it, not the command - shell helps with wildcards (GLOB) (see shell_basics.txt) - See Notes: glob_patterns.txt - GLOB patterns (wildcard pathname matching) - Hidden files as (not) seen by ls and glob wildcard * - GLOB patterns do not match hidden files unless you explicitly include the leading period: echo .* - * matches zero or more characters - ? matches a single character (any character, even a space) - [abc] matches a single character from the list abc - GLOB patterns do not match names that start with a period (hidden pathnames), unless you explicitly put the period at the start of the pathname component $ echo * a b c $ echo .* . .. .bashrc $ echo /var/www/html/.* /var/www/html/. /var/www/html/.. /var/www/html/.htaccess $ echo * a* *b *b* a*a ? ?? ??? a? ???* - like ls, GLOB patterns do not match hidden pathnames - you can see hidden names using: ls -a - echo * - does not match hidden pathnames - creating command line arguments using quotes and backslashes - wildcards (GLOB) - mention that, like ls, GLOB patterns do not match hidden names Hiding GLOB characters from the shell: - use single or double quotes to hide GLOB characters: $ echo "*** warning ***" Reminder: Midterm Test #1 is in Week #5 (see the Course Home Page). - You all were sent email about this test on Sunday January 22. - See Notes file termtest1directions.txt for the test format.