CSCI 3194 (Seminar (UNIX Power Tools)), Fall 2014:
Homework 1
- Credit:
- 60 points.
Be sure you have read the assigned readings for classes through 9/24.
Answer the following questions. You may write out your answers by
hand or using a word processor or other program, but please submit
hard copy, either in class or in my mailbox in the department office.
Answers to most questions will involve experimentation on
a UNIX or Linux system.
You are free to use any appropriate system
(unless a specific problem says otherwise);
if you use something other than one of our classroom/lab machines
please tell me what.
(You will learn more about this topic if you use the man
and info commands rather than Google.)
- (5 points)
When you are reading a man page, is there a way to
search for particular text? What is it?
(Hint: Look in the man page for man
for mentions of a pager, and then read the man page for
the appropriate other program.)
- (5 points)
The Linux date command will, among other things,
print today's date or a specified other date.
How would you use this command to find out
what day of the week you were born? (I.e., tell me the line or
lines you would type in a terminal window to accomplish this.)
(Hint: The info page for date may be more helpful
than the man page.)
(To observe how UNIX systems are sometimes not alike,
try the same command on one of the department's OS X
machines.)
- (5 points)
On one of the lab machines, the command
ls -l /bin/vi produces the following output:
-rwxr-xr-x 1 root root 770248 Apr 5 2012 /bin/vi
What does all of this mean?
(I.e., what does the string of dashes and letters mean?
The 1? The 770248? and so on.)
(Hint: man ls and info ls may be helpful.)
- (5 points)
What command(s) would you use to create a directory in your
home directory called KeepOut to which you have
full access (read, write, and execute), but no one else
has any access?
- (5 points)
Suppose you have started a GUI application called
bigpig that for some reason doesn't seem to be
responding to any input. How do you terminate it
without logging out or rebooting the machine? Describe
as many ways as you can think of.
(Hint: man ps and man kill.)
(Answer the following questions for the bash shell.)
- (5 points)
When you type a command (e.g., ls), the shell has to
find an executable (program) to run. Where does it look?
How could you make it also look in your directory
MyPrograms (in addition to wherever it looks now)?
How could you make it look only in your directory
MyPrograms?
- (5 points)
Give the command(s) you would use to
define two aliases or shell functions:
delete to move a file to be
``deleted'' to a temporary directory such as
$HOME/.trash, and undelete to move a
``deleted'' file from the temporary directory to the
current directory. (Examples of use:
delete myfile, undelete otherfile.)
(It's up to you to decide whether these should be aliases
or shell functions. You might be constrained by the
capabilities of aliases versus functions.)
Notice that commands to define aliases or functions can be
entered from the command line, in which case they apply to
the current session only, or can be included in an appropriate
initialization file.
- (5 points)
The find command is somewhat intimidating but
also very powerful. How could you use it to
find all files
in your home directory (and all subdirectories)
that are less than a day old and end with .c?
- (5 points)
How would you invoke the gcc compiler if you want
to be able to page through its output (both standard output
and standard error) with less?
How would you capture the error output only in a file
called gcc-ERRORS?
- (5 points)
How could you make a one-line text file without using a text
editor? Could you extend this idea to make a multiline
text file? Tell me about as many ways to do this as you
can think of.
- (5 points)
What would you type at the command line to get a sorted
list, with no duplicates, of all the users running processes
on the machine you're using?
- (5 points)
Answer/do one of the following:
- What would you type at the command line to find out
how many processes are being run by user root?
- Describe something you actually want to do (e.g., archive
all files that have been changed in the last 24 hours,
find a Janus machine that's up and connect to it with
ssh) and a solution involving a pipe and at least
one of the commands mentioned in the reading for this
assignment.
Berna Massingill
2014-10-01