Week 5 Lesson 5 02/28/18 Important Announcements Extra Credits If you haven t done so, send your pictures to risimms@cabrillo.edu for 3 points EXTRA CREDIT. Join LinkedIn for 3 points Perkins/VTEA Survey (check forum) for 3 point extra credit Class Attendance Attending class by watching the recording in the archives? Make sure you email the instructor for attendance First minute quizzes: 9AM Log in credentials are your usernames and passwords. See instructor s welcome announcement on CANVAS Text Book Text book is optional: Harley Hahn s Guide to Unix and Linux by Harley Hahn, McGraw- Hill ISBN: 0073133612 Exams (see calendar) FINAL EXAM WILL BE ON WEDNESDAY, MAY 23 FROM 7:00 AM-9:50 Forum USE FORUM if needed help (remember extra posts in one quarter do not carry over to the next quarter) Time zone Class uses Opus-ii time. For more info, ask on forum. Grade Keep track of your grade Networking Subscribe to Cabrillo Networking Program Mailing list. Send email to networkerssubscribe@cabrillo.edu Review for Test 1 PRACTICE TEST #1 IS AVAILABLE ON CANVAS (SEE SLIDE 205) Tips to study/taking open book test - Create your own reference sheet - For each subject include a small example. Six Steps of the Shell Review - Which shell are you using? Try these commands (slide 27)
o ls /bin/ {?,??}sh o grep [username] /etc/passwd o ps o echo $SHELL - There are many shells on Opus-II. They can be found in the /bin directory. Your account entry in /etc/passwd determines which shell you will use. - Prompt, Parse, Search, Execute, Nap, Repeat are the six steps of the Shell (slide 28) o See slide 29 for an example of the shell and a command working together as a team and a table indicating each step the command is running 1. Prompt a. The shell prompts user for a command i. Every time you his the enter key, the shell will prompt you for another command (see slide 30 for example) b. The shell uses the value of PS1 variable to make the prompt. i. echo $PS1 c. You can manually do the same thing by echoing the value of the PS1 variable i. Echo $PWD $ (see slide 31 for example) ii. Your PS1 variable on Opus-II gets set when you login via a login script containing this command: PS1= $PWD $ 2. Parse a. The shell parses what you entered and identifies the command, the options, the arguments and any redirection. (see slides 32-35 for examples) b. Use the echo * to out how many arguments 3. Search a. The shell searches the path for the command you entered (see slide 36) b. To see where the shell finds the command, type this command: type [command] or echo $PATH (grep add color to semicolons) 4. Execute a. The shell executes the command program (see slides 37-38) b. The program on the hard drive becomes a process in memory with a unique PID (Process ID). Each new process is given three file descriptors stdin, stdout and stderr for input and output purposes. Theses are sometimes referred as the three standard IO (Input/Output) streams. 5. Nap a. The shell sleeps while the command runs. The nap ends when the file command has finished 6. Repeat a. The shell does it again for the next command Directories on your Path (see slides 44-53) - /bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin (MEMORIZE these directories. You should have them on your path for this course). o If one of these directories missing from your path look for before - How to fix/reset a broken PATH:
o PATH=[the missing directories]:$path (see slide 49) Everything is a file in Unix and you can write to them. Even a terminal (see slides 74-84 for example and slide 76 for file types) File Name Expansion. Also known as globbing - Filename expansion Metacharacters o * matches all non-hidden fienames in the current directory when used alone or zero or more characters when used as a prefix, infix or postfix. o? matches any single character in any of your current directory s filenames. o [ ] matches any single character contained within the brackets. Shell Parse Step - Filename expansion happens during the shell parsing step, before the command is even located or executed. The commands never see *,?, and [ ] characters. They get replaced by the shell before the command is even located and executed The *Filename Expansion Metacharacter (see slides 88-91) - Example: text.* will be expanded by the shell to match any files that start with text. - Example: * is expanded to match all directories in /home/cis90 and ti* to match all files starting with ti : ls -l../*/poems/blake/ti* - *.* is expanded to match all files in the current directory containing. - The * by itself does not match any hidden files in your current working directory The? Filename Expansion Metacharacter (see slide 92) - Example??? will be matching any three characters file name The [ ] Filename Expansion Metacharacter (see slide 93) - Example: [12] will be match a 1 or a 2 For practice questions on all three filenames see slides 94-104 Command Review Lesson 1 commands: - cal show calendar - cat /etc/issue usually shows distro (distribution) name - cat /etc/*-release usually shows distro (distribution) name - clear clear the terminal screen - date show current time and date - exit terminate your shell and log off - history show previous commands - hostname show the name of the computer being accessed - id show user and group id information - ps show processes (loaded programs) being run - ssh secure login to a remote system - uname show kernel name
o use -r to see which release of the kernel is running on your system - tty show terminal device - who show everyone logged in - who am i identifies which login session you are using Lesson 2 commands: - echo Prints text and variables - banner Make a banner - ls list directory contents - cat View file (name comes from concatenate) - file Show additional information about a file - type Shows where a command resides on the path - apropos Searches the whatis database for strings - whatis Searches the whatis database for commands - man Show the manual page for a command - info Alternate online documentation tool - bc Binary calculator - passwd Change password - set List all shell variables - env List all environment variables New Files and Directories: - /etc/passwd user accounts - /etc/shadow encrypted passwords - /bin directory of commands - /sbin directory of superuser commands - /usr/bin directory of commands, tools and utilities - /usr/local/bin custom local commands Lesson 3 commands: - mail UNIX mail o <integer> print specific message specified by <integer> o [Enter key] print next message o p <message list> print messages o d <message list> delete messages o s <message list> file save (append) messages to file o u <message list> undelete messages o R <message list> reply to sender o r <message list> reply to all o m <user list> mail to specific users o q quit saving changes o x exit without saving changes o h print message headers o z or z- scroll forward or backward through headers
- mesg enable or disable writes to your terminal - write write message to another user - irssi IRC chat client New Files and Directories: - /var/mail Message store for mail - /var/mail/username Incoming mailbox for username - mbox File in users home directory where read messages are archived to Lesson 4 commands: - cat view a text file - more view a large text file by scrolling down - less view a large text file by scrolling down and up - head view the beginning lines of a text file o use the -n <number> option to control the number of lines printed - tail view the last lines of a text file o use the -n <number> option to control the number of lines printed - wc count the lines, words and characters in a text file o e.g /home/cis90/simben $ wc letter 28 # lines; 182 # words; 1044 # bytes o Use -l option to count just the number of line o Use -w option to count just the number of words - xxd view a binary data file as a hex dump - cd change to a different directory - ls list files - pwd show name of current/working directory - file show additional file information - type show location of a command on path New File and Directories: - / slash directory, the root of the file tree - /home User home directories - /home/cis90 CIS 90 class home directories - /home/cis90/username The home directory for CIS 90 student username - /etc/passwd The absolute pathname of the passwd file in the /etc/ directory Command Syntax: - -Prompt -Command -Options -Arguments -Redirection (slides 112-123) See slide 125 for Metacharacters review. Environment Variables (see slides 134-141) - HOME Users home directory - LOGNAME User s username for logging in with
- PATH List of directories, separated by : s, for the shell to search for commands - PS1 The prompt string - PWD Current working directory - SHELL Name of the Shell program being used. - TERM Type of terminal device, e.g. dumb, vt100, xterm, ansi, etc. See slides 142 149 for example on life of the shell step 4, Execute. File Systems (see slides 154-160) - The three elements of a UNIX file o -filename -inode -data Absolute Pathnames starts with from / Relative Pathnames starts from your current location in the tree See slide 163 for the Top Level Directories list. Flash cards are available on the website. You will need to create an account: username and password (see slides 172-173) See slides 175-201 for test tips and practice questions DO THE PRACTICE TEST (Slide 203)