Networking I Fall '97 UNIX worksheet 1 20 points 1. Log onto your Binx account, execute each of the command lines below, and determine the purpose of the command. Use 'man command' to help you understand the command. a) who (1 pt) displays the username of each user, followed by their port, the date and time logged in, and location from which they are connected b) who | wc -l (2 pts) print the number of users logged in c) who > whofile (1 pt) puts the output of who in a file called whofile in the current directory d) who >> whofile (1 pt) appends the output of who to the end of the file whofile in the current directory 2. For the commands below, use the file you created and placed in your netclass directory (your_user_name.txt) wherever you see the word "file". Describe what each part of the command does. e) cat file | tr -cs A-Za-z '\n' > new_filename (2 pts) lists the file, pipes it into tr, translates anything that isn't a letter (upper or lower case) into a newline character, and prints the output to a file--the practical purpose is to put each word on a different line f) cat file | tr -cs A-Za-z '\n' | tr A-Z a-z | sort | uniq (5 pts) lists the file, piping the output to tr, which separates words onto different lines (as in the previous question), translates all upper case letters to lower case letters, sorts the list of words, gets rid of the repeated words, and prints the result to stdout g) grep 'hello there' file (1 pt) prints all lines in "file" which have the string 'hello there' in them 3. Describe what each of these two commands does. h) find /usr/local/httpd/logs -name "a*" -print > afiles (1 pt) finds all files in the /usr/local/httpd/logs directory (or any subdirectory thereof) with a name which begins with the letter "a", prints the resulting list of filenames and redirects the output to a file called "afiles" in the current directory i) ps (1 pt) shows a list of your processes from this session 4. Write the command line which will perform each of the following tasks. a) Display the first 5 lines of a file. (1 pt) head -5 filename b) Display the last 8 lines of a file. (1 pt) tail -8 filename c) Search for all lines in a file which contain the expression 'spring break'. (1 pt) grep 'spring break' filename d) Put a process in the background. (1 pt) bg or put "&" on the command line e) Bring a suspended process to the foreground. (1 pt) fg