This informal quiz is to help review the materials we covered during
the course -
Learning Tree International's
Introduction to UNIX
(course 336).
It is broken up into sections to help jump to the current topics if
you are using this as a review during class week.
Jump to:
Chapters 1-2 |
Chapters 3-4 |
Chapters 5-7 |
Chapter 8 |
Chapters 9-11
The quiz is not "scored". It's intended as a low-pressure way to
review some key topics, and maybe learn some new things. When
you click an answer choice, a box will pop up with an explanation
of why that's the right or wrong choice. Sometimes there may be
one than one "correct" answer.
Please don't worry if there are some things you don't get.
Some of the questions are intentionally more complex than what we
have covered in class. Since this quiz is not part of the class,
by looking at it you've already decided to do some extracurricular
work, so I feel free to occasionally prod you to see if you can
extend the ideas we have talked about a little bit further.
Disclaimer: this is a purely informal quiz of my invention. Learning
Tree is not responsible for the content - and errors are entirely my own!
There is no intentional relationship to the end-of-course examination,
nor is this an "exam prep". Of course, since the topic is basic UNIX,
there will coincidentally be some overlap.
This is still a work in progress, let me know if you find errors.
If you'd like a copy for your own use, you're welcome:
see below for copyright information.
336 Review Questions covering Chapters 1-2
-
(Chapter 1) Which statement is true
about your UNIX login name?
-
(Chapter 1) The shell ...
-
(Chapter 1) Which statement is true?
The Linux operating system ...
-
(Chapter 2) Most of the UNIX documentation is ...
-
(Chapter 2) Which of the following UNIX filenames would not be legal,
and why?
-
(Chapter 2) If you wanted to display detailed information about files,
including index numbers, in subdirectory writings,
which of the following commands would you pick?
-
(Chapter 2) Standard UNIX file access modes:
-
(Chapter 2) Consider three filenames reflecting the current copy of
your resume:
resume.010700 and resume.new are (hard) links.
resume is a symbolic link to resume.new.
Which statement is false? (it may help to draw a picture
of the relationships like in slide 2-22)
-
(Chapter 2) Which of the following commands would make
a hard link from an existing file named resume to a new
filename secret?
-
(Chapter 2) If you execute the command
chmod 123 wknight
on the regular file wknight
what will ls -l show as the permissions for the file?
-
(Chapter 2)
If your username is sam and are a member of the group staff
(hint: run the id command to check on most systems!).
You wish to access a file restaurants so you type
ls -l restaurants and see the following result:
-rw-r----- 2 fred staff 6883 Feb 16 05:30 restaurants
which of the following statements is false?
-
(Chapter 2)
You are the new sysadmin of a server which has crashed. You go into the
machine room for the first time only to find that the console to the
server is an old ASCII terminal without any arrow keys. You bring up
the system in single user mode. The only editor available is vi. How do
you move up and down line by line most efficiently within a file that you
need to edit?
-
(Chapter 2)
In vi, how do you end the insert mode?
-
(Chapter 2)
You bring up the vi editor on file croc and make
some changes. Remember - the changes are only made to the buffer
until you save them. How would you save this new version into a
file named croc.new (i.e. perform a "save-as")?
Jump to:
Chapters 1-2 |
Chapters 3-4 |
Chapters 5-7 |
Chapter 8 |
Chapters 9-11
336 Review Questions covering Chapters 3-4
-
(Chapter 3)
In the Korn shell, how would you repeat the last ls
command you ran?
-
(Chapter 3) You have a file named cal.out.
What does the following command do in the Korn shell?
cal 2002 >> cal.out
-
(Chapter 3) The dash (-) character is legal in filenames, but if you
give a file a name that begins with dash, it turns out to be very
hard to work with: when you give such a file name as arguments to a
command like rm, the command mistakes the name for an
option (remember options generally start with a dash),
not a filename. You should try this out... create a file
-foo:
cal 2001 > -foo
How would you remove this file -foo?
-
(Chapter 3) Filename wildcards follow the same rule as the ls
command in that they don't match "dot files" (files whose name begins
with a period) unless you take special steps. If you want to display
the contents of your "dot files", but omit the the entries "." and ".."
which of the below commands would accomnplish that?
-
(Chapter 3) How can a job be brought up to the foreground after
it has been placed in the background? (Extra material, not in
the course!).
-
(Chapter 4) The /bin directory typically contains:
-
(Chapter 4) On your system, assume home directories are all placed
in /usr/people, so your home directory is
/usr/people/you.
How would you make a hard link to a file
named parts in the tools subdirectory of
Fred's home directory to a file of the same name in
your own tools subdirectory (assume that subdirectory
does not already exist)?
-
(Chapter 4) Assume you are working in the build area for an
application you're developing, and you've just gotten a new
version of the compiler. You need to remove the object files
in the directory tree that comprises the build area, which are
all the files with a suffix .o, so that you can
recompile them and see if the new compiler version works
correctly. You could try:
rm *.o */*.o */*/*.o
but that's cumbersome and might miss some things (wildcards
don't match things beginning with dot, so any directory whose
name began with dot would be skipped by the above!).
find is the right tool for this job. Which command would
do what you want?
-
(Chapter 4) Which command would copy all of the files in the current
directory to a directory save located in the parent directory
(that is, the directory above this one).
Jump to:
Chapters 1-2 |
Chapters 3-4 |
Chapters 5-7 |
Chapter 8 |
Chapters 9-11
336 Review Questions Covering Chapters 5-7
-
(Chapter 5) How would you sort the file data and
save the changes in the same file?
-
(Chapter 5) What is the filter that selects lines from its input that match
a specified pattern?
-
(Chapter 5)
Given a file of expense items such as the one used in class,
where the first field of each line contains a numeric amount
and the second an expense category, how many expenses refer
to tips?
-
(Chapter 5)
Who is logged in on terminal ttyp0 on your system?
Remember that the who command shows who is logged in.
-
(Chapter 5) The following command line will do what?
sed 's/the/da/g' fatherw | sed 's/The/Da/' fatherw
-
(Chapter 5) Given a simple flat-file database named hours
tracking time allocated to a project, which uses a format consisting
of username, project code, date, and time spent in hours, in that
order (see example), select the awk command that would
correctly extract the fields and print a report:
Example:
mats|1307-02|02/02/99|3.5
-
(Chapter 6)
Assuming that mats is a user on the system,
and home directories are in /home
what should the result of the following command be?
echo cp ~mats/croc ~mats/bunyip ~
-
(Chapter 6)
Assume you prepare expense reports on your UNIX system, and
save each one in a file. To keep track, you keep a list of
those which are open (i.e. unpaid) in a file named expenses.open.
How could you look at the contents of each of those expense reports
by typing a single command?
-
(Chapter 6)
To set a shell variable furbie, then make it
available to shell scripts started from this shell,
and finally display the value of furbie,
which command line accomplishes all three
(remember ; is the command separator).
-
(Chapter 6)
If you wanted to run the command ls and save the results in a
variable foo, what would the Bourne shell construct look like?
(Note: if (b) and (c) look really similar, they're not supposed to;
(b) is using forward quotes and (c) is using backward quotes - sometimes
the browser picks a font that makes this hard to see!).
-
(Chapter 6)
In the Korn shell (and related shells), quoting some
text with single quotes turns off the special meaning
of metacharacters (i.e., characters with special meaning).
When the shell reads the command line, as it's turning off
special meaning due to quoting, it removes the quote
characters so they don't appear in the completed command
line. The following metacharacters were covered in the course:
# & * ? [ ] = | ^ ; < > ` $ " ' \
along with spaces, tabs, and newlines.
As discussed, double quotes work almost the same way as single quotes,
except that variable substitution with $ and command
substitution with `` or $() are not quoted,
and backslashes still have a special meaning.
A backslash escapes the meaning of the next single
character. You can use combinations of these to make
sure you get the right effect - and while you're
getting familiar with how it works, use the
echo command to show you what's going on.
Which command would correctly print out the message:
Chicago's #1 draft choice will command a big $$ contract
-
(Chapter 6)
If you wish to set your shell such that typing the command
x will start a new instance of the xterm terminal
emulator, which line will enable that behavior?
The next two questions are about "regular expressions".
These are ways to specify text patterns that you're interested
in finding, and possibly replacing (in the case of editors).
First, a few comments about regular expressions
that may make the concepts easier to think about.
-
When you think about learning a language, you have to worry
about "expressions" - something you can't interpret too
literally, but instead must evaluate first. Consider
Someone let the cat out of the bag. UNIX regular expressions
are a bit like that: you use special characters to specify
sequences of characters, which you can't take literally but
have to evaluate first. They're actually much easier
because they follow well-defined rules, unlike idioms in
human languages!!!
-
Writing regular expressions is pretty similar to writing
a computer program. First you need to work out what you
want to match, which involves understanding how the
patterns appear in the data and how to extract those
patterns - and no others (the "specification" step). Then
you need to write the pattern ("coding") and then you need
to test it out to see if it works ("testing against specification").
These will probably happen iteratively: if testing reveals the
pattern isn't working right, you have to revise your pattern,
and in some cases you may discover that your "specification" is
not complete.
-
Finally, there are three sorts of regular expression
characters. There are anchors, which say where a
search takes place. If you leave out the anchor, the
search is not constrained, any occurrence of the
pattern will do. Second, there are character sets, in other
words what to look for, which may be literal characters,
wildcards (with the . (dot) character), or sets/ranges
(using []). Third, there are modifiers, which
change the behavior of the the character they follow. The
* character is a modifier.
Now on to the questions...
-
(Chapter 7)
Email programs use a simple format consisting of header lines
of the form tag:value where the tag must begin at the beginning
of a line. Once the header lines are complete,
a blank line indicates the beginning of the message body.
UNIX stores email in an ordinary text file. The subject of
a message is indicated by a header line with a tag of Subject.
Which command would find the subject lines of all messages
in a mailbox named mbox, but not other lines that
contain the word Subject?
-
(Chapter 7)
The * modifier means zero or more of a particular character.
Sometimes this is useful, as in checking for (optional)
indentation. Sometimes it's a pain, when you want to be
sure you have at least one of the pattern. Some tools support
+ as a one-or-more operator, but not all do. However,
it's possible to construct the one-or-more meaning with the
basic regular expression set.
How would you find lines beginning with one or more hash
marks (#) in your file farkle and get rid of those
hash marks?
Jump to:
Chapters 1-2 |
Chapters 3-4 |
Chapters 5-7 |
Chapter 8 |
Chapters 9-11
336 Review Questions Covering Chapter 8
-
(Chapter 8)
Which of the following statements is false
when you run a shell script?
-
(Chapter 8)
A shell script is a collection of instructions to the
shell (command interpreter). Assuming that you have
tested a set of instructions and already saved them in
a file, what is necessary make the script usable?
-
(Chapter 8)
Assume that a shell script named bkup is called as follows:
bkup croc fatherw expenses bunyip
How would this script access the expenses argument?
-
(Chapter 8)
Bonus: (just think about this one, then click for the explanation
to see if you thought of the same scheme).
If you have a bunch of files ending in .foo and you want to
rename them all to end in .bar, you can't just do this:
mv *.foo *.bar
How could you accomplish this bulk renaming?
Click here
to show an explanation
-
(Chapter 8)
shell compound commands
(under construction)
-
(Chapter 8)
shell compound commands
(under construction)
-
(Chapter 8)
shell read command
(under construction)
Jump to:
Chapters 1-2 |
Chapters 3-4 |
Chapters 5-7 |
Chapter 8 |
Chapters 9-11
336 Review Questions Covering Chapters 9-11
-
(Chapter 9)
The standard UNIX security model:
-
(Chapter 9)
Superuser has access to all accounts and files with the exception of:
-
(Chapter 9)
If you add an account to a Unix machine with a UID of 0,
but a GID different from the root account,
the account will still have superuser privilges:
-
(Chapter 9)
The directory writings has the following permissions:
drwx-wx--- 2 jmartin user 3223 Oct 6 11:46 writings
This directory contains a file called poem which has the following
permissions:
-rw------- 1 jmartin work 338 Oct 26 16:20 poem
Laura, whose primary group is user, gets into writings and
modifies a copy of poem. How is this possible?
-
(Chapter 9)
Creating a user account manually on a system without shadow
passwords involves:
-
(Chapter 9)
What command do you use to convert a plain password system into
a shadow system?
-
(Chapter 9) Which of the following corresponds to a disk device node?
-
(Chapter 9) The command used to make a new filesystem is:
-
(Chapter 9) Complete this sentence: when a file system is mounted on a
mount point (existing directory),
-
(Chapter 10)
Which command would copy the file named croc in your
current directory to your home directory on machine ltree17?
-
(Chapter 10)
mailx in script
(Chapter 10)
On your server, there is a list of administrators stored in
/etc/local.admins. Here is a shell script,
intended for installation in a cron entry,
which generates a list of other-writable files in
/home. To complete the script, pick the line
Which will email the results to the administrators.
#!/bin/ksh
find /home -perm -002 -print > /tmp/list.$$
if [ ! -s /tmp/list.$$ ]
then
...Pick the line that goes here...
fi
rm /tmp/list.$$
-
(Chapter 11)
Which command would place a new xclock window in the
upper right corner, offset a few pixels from the corner?
-
(Chapter 11)
X Display
Which command would run a command xbill on the
current machine, but send the window for that command
on machine ltree25's first display screen?