Week 6 Notes for DAT2330 - Ian Allen Supplement to Text, outlining the material done in class and lab. Remember - knowing how to find out the answer is more important than memorizing the answer. Learn to fish! RTFM![*] ([*] Read The Fine Manual) ------------------------------ Review to prepare for Lab Test ------------------------------ Don't just read the book! Type in the examples and do them to develop "muscle memory" about what the commands do. If you never type in the "finger" command, you won't realize that you mis-spell it until the test, and then it's too late. Type in the sample commands given in the book as you review the posted chapter review questions. Many Unix commands need both a VERB and and OBJECT. The following incorrect attempts at commands are wrong: $ /etc/passwd (missing VERB; what are you trying to DO?) $ chmod 000 (missing OBJECT; change the mode of WHAT?) Watch your prompts! This is not a shell prompt: ftp> date ?Invalid command Invalid command: You can't type Unix commands into the FTP program. The syntax of FTP commands is not the same as the syntax of Unix commands. This doesn't do what you think it does: ftp> ls -lid 932756373abcde output to local-file: 932756373abcde? If you answer "yes" to this prompt, you will copy the output of "ls -lid" into the file "932756373abcde" in your current directory, erasing what was there before. This is probably not what you want. Watch your prompts! This is not an FTP prompt: $ put 038563473265abce sh: put: not found Not found: You can't type FTP commands into Unix shells. Pay attention. ------------------ Practice questions ------------------ You are in your home directory. Create a file here that contains the last 10 lines of the Unix password file. You are in the /home directory (owned by root). Without changing directories, create a file in your home directory that contains the last 10 lines of the Unix password file. (Hint: use the $HOME variable.) Which program issues the error message in each case below? $ date >/etc/passwd permission denied $ cp foo /etc/passwd permission denied How many arguments are passed to the command given here: $ tr a b bar What is the output of each of these command lines, and what is in the file "foo" when the command finishes? $ cat foo >foo $ sort foo >foo $ more foo >foo $ grep "pattern" foo >foo $ head foo >foo $ tail foo >foo $ tr a b foo $ cat foo | tr 'a' 'b' | grep "lala" | sort | head >foo Hint: The answer is the same for all the command lines. Does this work to give a file a link count of four? $ date >foo $ ln foo new $ ln foo new $ ln foo new Create a file, then do some commands to give it a link count of five. Remove all (ALL) permissions from the above files. How many commands are necessary to remove all permissions from a file that has a link count of 5? After removing all permissions, try to copy one of the above files to another file. Which program issues the error message, and why? What permissions do you need on a file to make a link to it? Compare these two command sequences and explain how they differ, if they do differ: $ date >a $ date >a $ ln a b $ ln a b $ ln a c $ ln b c $ ln a d $ ln c d What information is stored with a file name in the directory? What information is stored in the inode of the file? What command shows the permissions of the CURRENT DIRECTORY ONLY? What command shows the inode numbers associated with names in a directory? What does this do? $ mkdir my dir How do you append to a file, so that you can put the output of several commands into the same file without losing what was there before? What is wrong with this command to mail the contents of existing file abcd.txt to user alleni? $ cat abcd.txt > mail alleni@algonquincollege.com What does the above command actually do? What error message will you see? How many arguments are passed to the "cat" command? What is wrong with this command for copying abcd.txt into file foo? $ cat abcd.txt | foo What is wrong with this command for copying file foo to file bar? What will be the output on the screen? What will be in file "bar"? $ cp foo >bar (Hint: How many arguments are passed to cp? How many are required? RTFM) The following command line actually works, but the programmer who wrote it didn't really understand how piping operates, given the two commands involved: $ tr a b bar | mv bar foo What is the actual output (on standard output) of the part of the command line before the pipe? What does the "mv" command do with information coming in on standard input (after the pipe symbol) (RTFM)? -------------------------------------------------- FTP to/from Floppix to/from acadaix (or anywhere!) -------------------------------------------------- $ ftp acadaix Name: abcd0001 (your acadaix userid) Password: 10825463 (your acadaix password) ftp> ls ...see all your acadaix files here... ftp> put something (upload to acadaix) ...etc... ftp> get something_else (download to floppix) ...etc... ftp> quit