Download presentation
Presentation is loading. Please wait.
Published byRuth Allen Modified over 9 years ago
1
Day 2 Review of ITSK1601 – Intro Unix.
2
Break up into Cousin groups Each cousin group will work as a team. Each team will need 5 blank sheets of paper. Be sure to write both cousins names at the top of each sheet of paper We will see 10 questions per round. Write your teams answers for all 10 questions on one page. –No late submissions of answers. –Only readable answers will be considered for credit.
3
10 pts extra credit possible. You are working for 10 points of extra credit on the first quiz. –If you get 50/50 questions correct, you would have 10 pts added to your score on the first quiz. –45/50 would get you 9 points. –40/50 would get you 8 points –35/50 would get you 7 points –30/50 would get you 6 points –…… –5/50 would get you 1 point.
4
Rules While discussing your answer with your cousin, be quiet so other teams cannot hear your answer. No partial credit will be given for partially correct answers. You gotta get it right. Answer must be readable You may use any notes/books/computer you want during the game. A correct answer may require the options which would be passed to the command as well as the actual command. Judges (I.e. my) decision is final.
5
Round 1
6
Question 1 What UNIX command will show you help information on a command?
7
Question 2 What UNIX command will show you a list of files in the current directory?
8
Question 3 What UNIX command will show allow you to make a copy of a file?
9
Question 4 What UNIX command will allow you change what directory you are currently in?
10
Question 5 What UNIX command will change your current directory to be one directory back from where you currently are? –e.g. You are currently in homeworks/hw1/answers. What command would take you to homeworks/hw1
11
Question 6 What UNIX command will tell you the current time?
12
Question 7 What UNIX command will show you the contents of a file without stopping at each screen full? –I.e. What command dumps an entire file to the screen.
13
Question 8 What 2 UNIX commands will show you the contents of a file but will stop at each screen full?
14
Question 9 What UNIX command is used to rename a file?
15
Question 10 What UNIX command is used to see the first 10 lines in a file?
16
Round 1 Answers
17
Question 1 What UNIX command will show you help information on a command? man
18
Question 2 What UNIX command will show you a list of files in the current directory? ls
19
Question 3 What UNIX command will show allow you to make a copy of a file? cp
20
Question 4 What UNIX command will allow you change what directory you are currently in? cd
21
Question 5 What UNIX command will change your current directory to be one directory back from where you currently are? –e.g. You are currently in homeworks/hw1/answers. What command would take you to homeworks/hw1 cd..
22
Question 6 What UNIX command will tell you the current time? date
23
Question 7 What UNIX command will show you the contents of a file without stopping at each screen full? –I.e. What command dumps an entire file to the screen. cat
24
Question 8 What 2 UNIX commands will show you the contents of a file but will stop at each screen full? more and less
25
Question 9 What UNIX command is used to rename a file? mv
26
Question 10 What UNIX command is used to see the first 10 lines in a file? head
27
Round 2
28
Question 1 What UNIX command will allow you to make a directory called Enda
29
Question 2 What UNIX command will remove a directory called Enda. You can assume the directory is in the current directory and is already empty
30
Question 3 What UNIX command will delete the file called Bob. You can assume Bob is in the current directory
31
Question 4 What UNIX command will tell you how many words are in a file?
32
Question 5 What UNIX command will allow you to run an interactive chat session with another user on your system?
33
Question 6 What UNIX command will show you what the user enda is currently doing? I.e. what commands they are currently running. Assume you are not enda.
34
Question 7 What UNIX command will show you the differences between the file 1.txt and 2.txt.
35
Question 8 What UNIX command will show you a calendar for the month of May, 2001?
36
Question 9 What UNIX command repeats some text to the screen?
37
Question 10 What UNIX command is used to view electronic email? –There is more than 1 correct answer here.
38
Round 2 Answers
39
Question 1 What UNIX command will allow you to make a directory called Enda mkdir Enda
40
Question 2 What UNIX command will remove a directory called Enda. You can assume the directory is in the current directory and is already empty rmdir Enda
41
Question 3 What UNIX command will delete the file called Bob. You can assume Bob is in the current directory rm Bob
42
Question 4 What UNIX command will tell you how many words are in a file? wc –w I’ll accept just wc
43
Question 5 What UNIX command will allow you to run an interactive chat session with another user on your system? talk
44
Question 6 What UNIX command will show you what the user enda is currently doing? I.e. what commands they are currently running. Assume you are not enda. w enda
45
Question 7 What UNIX command will show you the differences between the file 1.txt and 2.txt. diff 1.txt 2.txt
46
Question 8 What UNIX command will show you a calendar for the month of May, 2001? cal 5 2001
47
Question 9 What UNIX command repeats some text to the screen? echo
48
Question 10 What UNIX command is used to view electronic email? –There is more than 1 correct answer here. pine elm mail
49
Round 3
50
Question 1 What EXACT UNIX command will delete the directory homeworks and all files/subdirectories contained within. –You can assume homeworks is located in your current directory
51
Question 2 What exact UNIX command will move all files in the current directory who’s name begins with tex to the directory tex-files. –You may assume tex-files already exists, and is located in the current directory
52
Question 3 What exact UNIX command would delete any file which has a x in its file name, in this directory or any sub directory?
53
Question 4 What UNIX command will take the first 23 lines of every file in the current directory and put them into a new file called first-lines.
54
Question 5 What UNIX command will make the file public.txt readable to everyone on the system? –You may assume the file is in your current directory
55
Question 6 Assume you have a file (x.txt) which looks like this: 27chocolate 32mint 7orange 99lemon 2coffee What command would return the file showing the items sorted numerically ascending by the number at the front of each line
56
Question 7 2 different people need to be able to edit the same file. The file is currently located in /files/a.txt. Each user should see the file in their home directory. If either user edits their file, they should be editing the actual file /files/a.txt What Unix command would you need to type in each users home directory to make this true?
57
Question 8 What Unix command would allow you to search for all occurances of the text Edna and replace it with the Enda in the file mylife.txt
58
Question 9 What SINGLE Unix command would show you any messages in the logfile which contain either the words kernel or the IP address 10.1.1.1 –The messages file is located in /var/log/message
59
Question 10 What SINGLE Unix command would find only lines in /var/log/messages which contain kernel AND 10.1.1.1
60
Round 3 Answers
61
Question 1 What EXACT UNIX command will delete the directory homeworks and all files/subdirectories contained within. –You can assume homeworks is located in your current directory rm –r homeworks
62
Question 2 What exact UNIX command will move all files in the current directory who’s name begins with tex to the directory tex-files. –You may assume tex-files already exists, and is located in the current directory mv tex* tex-files
63
Question 3 What exact UNIX command would delete any file which has a x in its file name, in this directory or any sub directory? rm –r *x*
64
Question 4 What UNIX command will take the first 23 lines of every file in the current directory and put them into a new file called first-lines. head –23 * > first-lines
65
Question 5 What UNIX command will make the file public.txt readable to everyone on the system? –You may assume the file is in your current directory chmod a+r public.txt
66
Question 6 Assume you have a file (x.txt) which looks like this: 27chocolate 32mint 7orange 99lemon 2coffee What command would return the file showing the items sorted numerically ascending by the number at the front of each line sort –n x.txt
67
Question 7 2 different people need to be able to edit the same file. The file is currently located in /files/a.txt. Each user should see the file in their home directory. If either user edits their file, they should be editing the actual file /files/a.txt What Unix command would you need to type in each users home directory to make this true? ln (-s) /files/a.txt.
68
Question 8 What Unix command would allow you to search for all occurances of the text Edna and replace it with the Enda in the file mylife.txt sed s/Edna/Enda/g mylife.txt
69
Question 9 What SINGLE Unix command would show you any messages in the logfile which contain either the words kernel or the IP address 10.1.1.1 –The messages file is located in /var/log/message egrep ‘kernel|10.1.1.1’ /var/log/messages
70
Question 10 What SINGLE Unix command would find only lines in /var/log/messages which contain kernel AND 10.1.1.1 grep kernel /var/log/messages | grep 10.1.1.1
71
Round 4
72
Question 1 Imagine you have a directory with the following permissions: Can users who are a member of the group managers see a list of all files in that directory? –Why? Why Not? drwx--x--x 2 enda users 4096 Mar 21 13:06 scripts
73
Question 2 If you have a file called important.txt and you want to make sure that you cannot delete it. How can you change its permissions to help prevent this?
74
Question 3 How could you use the command who to find out a list of all users who are currently logged on. –Show no additional information other than username –Ensure that each username is only output once even if they are logged in multiple times
75
Question 4 What UNIX command will look for any the word Enda in the file stuff.txt –Be sure you look for enda, Enda, ENDA etc. –Be sure you do not return words like calENDAr.
76
Question 5 What UNIX command would count how many times the user enda logged in on May 14. –Use the last command to find this information. –Be sure you only look for enda’s information –Be sure you only look for entries on May 14.
77
Question 6 What SINGLE Unix command can you use to make the following directory: –/home/enda/1/2/3/4/5/6/7/8/9 –You may assume you are currently in /home/enda –None of the sub directories exist. I.e. Right now, in /home/enda there is now directory called 1.
78
Question 7 You have a file which contains a bunch of words. –One word per line You want to see all words which begin with the letter c, but you need them in REVERSE alphabetical order. –Thus you should get: czar cyclone cutoff count club cat
79
Question 8 What Unix command would append a copy of the file 2.txt to the end of the file 1.txt?
80
Question 9 Imagine you only have the cat command, and the ability to redirect You start with a file that has 10 lines in it. What is the least number of commands you could use to make a file with 1000+ lines in it? What command would you be running?
81
Question 10 Assume you are in vi in escape [command] mode –How would you do each of the following in a single command: a.Delete the next 100 lines b.Add 10 blank lines beneath the current line c.Find the next occurrence of the word Fido in the document d.Find the matching close } to this open {. You can assume your cursor is on top of the { for this one.
82
Round 4 Answers
83
Question 1 Imagine you have a directory with the following permissions: Can users who are a member of the group managers see a list of all files in that directory? –Why? Why Not? Nope, you require read permission ls in a directory, for Others, no read permission exists. drwxr-x--x 2 enda users 4096 Mar 21 13:06 scripts
84
Question 2 If you have a file called important.txt and you want to make sure that you cannot delete it. How can you change its permissions to help prevent this? chmod u-w file
85
Question 3 How could you use the command who to find out a list of all users who are currently logged on. –Show no additional information other than username –Ensure that each username is only output once even if they are logged in multiple times who | awk ‘{print $1}’ | sort | uniq
86
Question 4 What UNIX command will look for any the word Enda in the file stuff.txt –Be sure you look for enda, Enda, ENDA etc. –Be sure you do not return words like calENDAr. grep –i ^enda$ stuff.txt
87
Question 5 What UNIX command would count how many times the user enda logged in on May 14. –Use the last command to find this information. –Be sure you only look for enda’s information –Be sure you only look for entries on May 14. last | grep “May 14” | grep enda | wc -l
88
Question 6 What SINGLE Unix command can you use to make the following directory: –/home/enda/1/2/3/4/5/6/7/8/9 –You may assume you are currently in /home/enda –None of the sub directories exist. I.e. Right now, in /home/enda there is now directory called 1. mkdir –p /home/enda/1/2/3/4/5/6/7/8/9
89
Question 7 You have a file which contains a bunch of words. –One word per line You want to see all words which begin with the letter c, but you need them in REVERSE alphabetical order. –Thus you should get: czar cyclone cutoff count club cat grep c file | sort –r
90
Question 8 What Unix command would append a copy of the file 2.txt to the end of the file 1.txt? cat 2.txt >> 1.txt
91
Question 9 Imagine you only have the cat command, and the ability to redirect You start with a file that has 10 lines in it. What is the least number of commands you could use to make a file with 1000+ lines in it? What command would you be running? cat file >> file Repeat 7 times, to get 1280 lines
92
Question 10 Assume you are in vi in escape [command] mode –How would you do each of the following in a single command: a.Delete the next 100 lines b.Add 10 blank lines beneath the current line c.Find the next occurrence of the word Fido in the document d.Find the matching close } to this open {. You can assume your cursor is on top of the { for this one. a. 100d b. 10o c. /Fido d. %
93
Round 5
94
Question 1 What single command will send 100 messages with the word “Yo” to the user enda’s screen?
95
Question 2 Write a simple script which will output “Yes” if enda is currently logged in and “No” if he is not.
96
Question 3 What Unix command would give you the answer to the following math problem: (100 * 50) / 5
97
Question 4 Imagine you have a file called users with a list of user names in it. –Write a simple script which one at a time will check if that user is logged on, if they are send them the message “Hey”
98
Question 5 Write a script which when run, decides what season it is. And tells you. –For simplicity lets assume the following: –Winter: Dec, Jan, Feb –Spring: Mar, Apr, May –Summer: Jun, Jul, Aug –Fall: Sep, Oct, Nov
99
Question 6 Write a script which renames the files –1.txt, 2.txt, 3.txt To the new name: –file1.txt, file2.txt, file3.txt The script should do this for all files up to 22.txt Be sure the user never sees any errors even if a given file (17.txt) doesn’t exist. Use a loop.
100
Question 7 Write a script which takes one parameter, a file name. –If the file exists Show us the file using more –Otherwise Give an error “I could not open you file called xxx” Be sure xxx is replaced with the actual file the user typed.
101
Round 5 Answers
102
Question 1 What single command will send 100 messages with the word “Yo” to the user enda’s screen? let x=0 while [ $x –lt 100 ] do echo “Yo” | write enda let x=$x+1 done
103
Question 2 Write a simple script which will output “Yes” if enda is currently logged in and “No” if he is not. if who | grep enda then echo “Yes” else echo “No” fi
104
Question 3 What Unix commands would give you the answer to the following math problem: (100 * 50) / 5 let x=(100*50)/5 echo $x
105
Question 4 Imagine you have a file called users with a list of user names in it. –Write a simple script which one at a time will check if that user is logged on, if they are send them the message “Hey” for name in `cat users` do if who | grep $name then echo “hey” | write $name fi done
106
Question 5 Write a script which when run, decides what season it is. And tells you. –For simplicity lets assume the following: –Winter: Dec, Jan, Feb –Spring: Mar, Apr, May –Summer: Jun, Jul, Aug –Fall: Sep, Oct, Nov if date | grep –i dec –o date | grep –i jan –o date | grep feb then echo “Winter” elif date | grep –i mar –r date | grep –i Apr …
107
Question 6 Write a script which renames the files –1.txt, 2.txt, 3.txt To the new name: –file1.txt, file2.txt, file3.txt The script should do this for all files up to 22.txt Be sure the user never sees any errors even if a given file (17.txt) doesn’t exist. Use a loop. let x=1 while [ $x –lt 22 ] do mv $x.txt file$x.txt 2> /dev/null let x=$x+1 done
108
Question 7 Write a script which takes one parameter, a file name. –If the file exists Show us the file using more –Otherwise Give an error “I could not open your file called xxx” Be sure xxx is replaced with the actual file the user typed. if [ -f $0 ] then more $0 else echo “I could not open your file called $0” fi
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.