------------------------ Week 3 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. The course outline is now available under Class Notes. In Week 3 (see also week02notes.txt) you did this: Review Class Notes: acadunix_help.txt Using the ACADUNIX IBM Unix machine arguments_and_options.txt Options and Arguments on Unix Command Lines course_linux_server.txt The Course Linux Server internet_basics.html Internet Networking Basics, URLs, etc. knoppix_booting.txt Using the Knoppix Linux CDROM man_page_RTFM.txt Searching for items in the Unix manual pages terminal.txt Using Telnet/Ssh terminal emulators vi_basics.txt The VI (VIM) Editor - Basics vi_refcard_front.pdf, vi_refcard_back.pdf - VIM reference New Class Notes presented: 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 We reviewed these command names: 1 vi, vim 2 apropos (synonym for: man -k) 2 bash 2 date 2 echo (shell built-in and external) 2 exit (shell built-in) 2 grep (-v) 2 hostname 2 less 2 man (-k) 2 more 2 passwd 2 sleep (10) 2 ssh (-l -p) 2 stty (erase '^H' or '^?') 2 wc 2 who We introduced these commands with examples and simple pipes: 3 cal (9 1752) 3 cat 3 cp 3 du 3 file 3 find 3 head (-5) 3 ls (-l) 3 mv 3 pwd (shell built-in and external) 3 rm 3 script 3 sort (-n) (see numeric sort in miscellaneous.txt) 3 tail (-5) 3 touch - simple pipes: ls /usr/bin | wc ls /usr/bin | wc | wc - using above commands, how do you select just lines 5-10 of the passwd file? - how to show the currently logged in user with the userid that sorts last? - how to display first five and last five lines of /etc/passwd? why is this wrong: head -5 /etc/passwd | tail -5 why is this wrong: head -5 /etc/passwd | tail -5 /etc/passwd this is right (two separate commands are needed, each reading the file): head -5 /etc/passwd ; tail -5 /etc/passwd - Unix line ends are \n characters: see miscellaneous.txt - echo hi | wc # shows 3 characters! - see line end material in: miscellaneous.txt Items from Class Notes file miscellaneous.txt: * Notes on GNU and Linux * Getting Out of Programs X Allowing messages to your Terminal (skip this week) * Unscrambling your Terminal * EOF and Interrupting Processes: ^D and ^C X TELNET to Unix from Windows (skip this week) X Notes on FTP command syntax (skip this week) X Locked Out of Unix/Linux Home (skip this week) * Understanding the different types of "sort": * Using "script" to create a session log * Line endings on Unix, Windows, and Macintosh Other notes: - reminder: no confirmation if things work; not a secretary O/S - test file /etc/passwd - Unix Password File (plain ASCII text) - /etc/passwd involves *TWO* directories: the ROOT and "etc" - searching (e.g. in man pages) with / in MORE and LESS - ssh login limit bug on ACADUNIX means may need to use telnet - see Class Notes file acadunix_help.txt - don't send binary executable files to your terminal screen - check them with "file" first: file /etc/passwd ; file /bin/ls Review: man - review searching in man with / in MORE and LESS - man -k, and apropos (Class Notes file: man_page_RTFM.txt) Showed many examples of . and .. in pathnames. ********************* LAB ********************* 1. create or edit .bash_profile - add a line at the bottom so that the word "Welcome" shows on your screen when you log out and then log back in - you may also want to add the correct "stty" command to this file 2. create or edit .bashrc - add a line at the bottom: alias cd..='cd ..' (note the space) - start up a new shell and type "alias" to verify the new alias - try typing: cd.. - to return to your home directory type: cd 3. create or edit .vimrc - put one line in file: set showcmd showmode confirm ruler - start up vim and verify that you have a ruler display - modify the buffer and try to quit (":q") - vim should ask you for confirmation before quitting 4. copy unix_command_list.txt from the course notes to your directory - use a Unix copy command; do not use a mouse cut/paste! - location of course notes is given in exercise01.txt - edit the file: below each command listed, write a one-line explanation of what the command does *in your own words* (do not copy) - beware of students who cd to my directory and try to edit my read-only file - their vim swap files will collide in /tmp! Submit whatever you have done by lab end (doesn't have to be finished): datsubmit 53 unix_command_list.txt Look for Exercise #2 to appear this weekend. Review: ------ X11 cut and paste with mouse - left mouse button drags and puts in clipboard (no need to "copy") - middle button pastes - right button extends selection Man pages - "man -k" (or "apropos") is very useful to find command names! - section 1 is commands - know how to read man pages (man page syntax meaning) - See Notes file: man_page_RTFM.txt Searching for items in the Unix manual pages (RTFM) Terminal - See Notes file terminal.txt - backspace key should erase one char - command: stty erase ^? - command: stty erase ^H - EOF - End Of File from keyboard: ^D - ASCII EOT: send the current partial line to the process Note: when ^D is typed at the very *start* of a line of input: signal End-Of-File (EOF) to current process - EOF ^D vs. Interrupting Processes ^C - not the same! $ sort - note difference between ^C and ^D $ wc - note difference between ^C and ^D $ cat - less difference - Unix line ends are \n characters (not \r or \r\n) $ echo hi | wc -c # prints 3 not 2 because of \n at end Learn various ways of getting out of programs - See Notes file miscellaneous.txt Important: Most Unix commands that take file names as arguments will read standard input (usually your keyboard) if no file names are given. Unlike the shell, the commands will *not* prompt when reading your keyboard: $ wc # no file given, no pipe; reads your keyboard $ cat # no file given, no pipe; reads your keyboard $ sort # no file given, no pipe; reads your keyboard $ ls # never reads input; never reads your keyboard $ date # never reads input; never reads your keyboard $ who # never reads input; never reads your keyboard Sending binary to your terminal device (bad idea) - don't send binary (executable machine code) files to your screen - check the contents with the "file" command first: e.g. file /etc/passwd ; file /bin/ls ; file /dev/null