CT320 HW1: Playing with Linux
This homework assignment needs to be performed individually on the Linux
boxes in the Linux Lab, not on the machines in CSB 315.
The purpose of this assignment is to introduce you to (or remind you of)
Linux commands that you may use on the Linux boxes.
Some of these questions may require commands or options that were not
covered in lecture. To find out more about a command, use
To find out which manual pages mention a given topic:
man -k topic
Some of the questions may require a pipeline:
Don’t use command substitution:
You will turn in a plain text
hw1.txt, formatted thus:
this is where the answer for question #2 goes
if question #2 needs another line, it goes here
and so on
Creativity is a wonderful thing, in its place. Creative formatting
will not be appreciated. Follow the format, above. Create the file
however you like. I’d use an editor.
For all of these tasks, I do not want you to do the computing
yourself. For example, if I ask how many files are in a given
directory, I don’t want you to stare at the screen and count the files
yourself, on your fingers. I want the computer to do the counting.
For these questions, I define items to be plain files, directories,
symlinks, etc. It means things in a directory, no matter their type.
The special directories
.. are not included.
- Log on to any of the computers in the Linux Lab.
What is the command to show the current time & date?
Note that I am not asking for the current time & date
in the answer file. Instead, I’m asking for the command.
- What is the command to show the name of this system?
- What is the name of this system?
What command would show the lines in
contain the letters “b”, “e”, “a”, “g”, “l”, “e”, in that order,
possibly with other things between them?
- What command(s) would you use to count how many items
/bin? Think of it in steps:
- Generate a list of items in
/bin. (Remember what items means.)
- Now, count the number of lines in that listing.
- How many items are in
How many items are in
- Explain the relationship between the previous two numbers.
Don’t just state the relationship—tell me why it is so.
- What command would show the home directory of user
I’m not interested in the items it contains—I want the path of the
home directory itself.
- What command would produce a listing of all forty-five of the items in
bin directory inside ct320's home directory, in reverse
alphabetical order? I want the command to show 45 items,
none of which should be the
- Show a complete
bash script, using only shell variables and
built-in shell constructs (no other programs such as
bc) to display the final sum of the numbers 1 through 789, inclusive.
Do not use algebra to figure out the sum. Make the computer actually
do all seven hundred eighty-nine additions. You must follow the
recommendations in the Bash scripts lecture.
If you encounter “STACK FRAME LINK OVERFLOW”, then try this:
How to Submit
Use web checkin, or use Linux checkin to submit your
~ct320/bin/checkin HW1 hw1.txt
How to Receive Negative Points
Turn in someone else’s work