Due Date
Due: Tuesday, January 14, 2014 at 11 PM.
Objectives
The purpose of this assignment is for you to
become familiar with:
- the basics of the Linux shell, and
- the range of commands that are included in most Linux
distributions.
This assignment very definitely does not include all of the
commands you will need for this course. Instead, it is aimed to
help you learn about some basic commands as well as how to
discover more on your own.
References
You should use the Linux Pocket Guide and the
Linux man
command to find specific commands needed
to answer these questions, and use the Pocket Guide to read about
related commands and topics. Yes, Google is also useful, but you
should learn your way around the Guide and the standard Linux
documentation, which is the primary source.
Assignment
There are two parts of the assignment. In Part
I you are asked to run several commands and capture the terminal
session in a script file to hand in (recall that you used the
script
command in HW0). Part II consists of several
questions to be answered in a separate text file. You should turn
in both files when you are done.
Part I
Use the command script hw1.part1
to
start a shell and save the input and output into a file
hw1.part1
. Then run the commands needed to answer
the following questions.
- If you make a few small mistakes you don't need to start
over, but
-
- either edit the file to remove any substantial errors,
or
- include comments (input lines starting with #) next to
short goofs so we can follow your output easily.
- Also don't worry about "invisible" control characters like
tabs and backspaces that are captured in the script file. That
is normal and not something that needs to be fixed.
- It would also be helpful if you included some comments to
identify answers to the different sets of questions to make it
easier for the graders to navigate through the output.
Getting started
- Enter a command to print "Hello world" on the screen.
- Change your password. (You can change it back later if you
want - don't forget it, though, you'll need it to log in next
time.)
- Display the current date and time on the screen.
File paths and directory navigation
- Display the full path of your home
directory.
- Go to your home directory.
- List all the files in your current directory.
- Now, create a new folder called ‘temp’.
- Rename this folder to ‘files’.
- Go to the ‘files’ folder.
- Run a command to get the current date and time and save the
output to a file called 'now'
- Copy ‘now’ to a file called 'before'
- List all the files in this directory. Use a more detailed
listing where you can see the files' permissions, date written,
etc.
- Create a file called 'temp' without using a text editor.
(There are at least three easy ways to do this.)
- Rename 'temp' to 'test'
- Go up one directory.
- Delete the ‘files’ folder with a single
command. (The command you use should also delete all of the
files inside of the folder.)
Permissions
- Create a file called 'secretfile' containing the
text “It's a secret!” using the
echo
command.
- Change the permission of this file in such a way so that no
one can write to it. Use the
ls
command to show
the file name and permissions.
- Try to add more text to 'secretfile' using the
cat
command.
- Change permission of this file so that no one can read it.
Use the
ls
command again to show the file name and
permissions.
- Try to read the file using
cat
.
Process Information
- Enter a command to display the version of the
Linux kernel that you are you using.
- List all of the processes that are currently running.
Searching
- Use grep to display the entry with your username
in the file '/etc/passwd'.
Part II
Use a text editor (emacs suggested - you should
learn how to use it at some point, even if you later use
something else) to create a plain text file named
hw1.part2
containing answers to the following
questions:
- Use the man pages to find out what wc does. Give a brief
description of it here. What does the -l option for wc do?
- Run wc on the directory '/etc/passwd' and copy and paste
your findings.
- What command would you use to a terminate (stop) a
process?
- What information does the environment variable $HOME store?
(Hint: use 'echo $HOME' to investigate.)
- List two other important environment variables on your
computer and what they store. Why are these variables
important?
- If you created a file 'bigredbutton' somewhere on your
computer and couldn't remember what folder it was in, what
command could you use to find it? Just give the name of the
command. You do not need to describe all of the necessary
arguments.
- How is the command in the answer to the previous question
different from the 'which' command?
- How does the command “echo Hello World! >
something” differ from “echo Hello
World!”?
- Assume we have run the first echo command from the previous
question and now we execute “echo more text >
something”. Describe what this does.
- Now assume we have run the commands in the previous two
questions and now we execute “echo yet more text >>
something”. Describe what this does.
Assessment
Your solutions will be evaluated on how well
they follow the instructions and produce the desired results in
part I, and on the correctness and conciseness of your answers in
part II. Different Linux variants may behave slightly differently, so we will be using the Linux Fedora version of bash provided on klaatu
and the CSE VM when evaluating your answers.
Turn-in Instructions
Use the turn-in drop box link on the
main course web page to turn the hw1.part1
file
created in part I and the hw1.part2
file with your
answers to the questions from part II. (The drop box will allow
you to turn in your homework up to two days late, if you choose
to use one or two of your late days, but you are
strongly advised to save your late days
for later in the quarter when they may be much more useful.)