Self Paced Lab - Linux Shell Commands
CMSC 104, 0801 - Fall 2002
Due Date: 5:30 pm, Tuesday September 17th.
Objectives:
To become more familiar with
- Linux, command line interaction, and basic shell commands
- the basic use of emacs
- using the internet to download and execute a simple program
Suggestion:
It is highly recommeded that you work on this assignment in a UMBC
computer lab on a GL computer booted into Linux. There are
parts of this assignment that may be difficult to accomplish with a
telnet session.
Background:
In this assignment you will be asked to execute many commands in a Linux
shell (i.e., a telnet or teminal session). To start a terminal, log
into a GL computer computer running Linux, click on the footprint
button on the control bar at the bottom of the screen, and select "Color
Xterm" from the Utilities Menu. Once you start the Xterm, you should
have a window on your desktop with a prompt where you will be able to
enter commands. (NOTE: A telnet session will give you the same prompt.)
You will be asked to execute various commands in this assignment.
As an example, if you are asked to execute the command "ls",
your screen should look like:
linux > ls
where "linux >" is the prompt.
Commands will always be given in quotes to make them clear. Also, there is
always an implied [return] at the end of a command. Other keys will also
be represented this way, such as the control key -- [Ctrl] -- which will be used throughout the assignment.
Remember that you can always use the man command to help figure
out another command's functionality. To determine what the command
cd does, you could type the command "man cd".
Attention to detail is very important in this assignment.
You may either hand write the answers to the questions below, or create a
text file of results that you will print out and *HAND IN* in the next class.
Either choice should include your full name, the date, the course number,
and the last four digits of your social security number. Your answers
should be clear and concise and should only answer the specific questions asked.
HAVE FUN!
Assignment:
1. From you home directory, create a directory called lab1 with the
command "mkdir lab1" at the prompt. To verify the creation
of this directory, executing the command "ls" should result
in a listing that contains the directory lab1. Change directory with
the command "cd lab1". Execute "pwd". What is
the exact output of this command?
2. The rest of the assignment should be completed from inside your
lab1 directory. Execute the command "echo I love cmsc104".
What is the result of this command?
3. The character '>' is used to redirect the output of a command. When
used, it will create a file that contains the output of the command that
preceeds the character '>'. Execute the commands: "echo hello1 >
one",
"echo hello2 > two", and "echo hello3 > three". E
xecuting these three commands should result in three files being
created. An "ls" command will list the files. Execute the
command "more one". Describe the
output of executing the command "more *". (Remember that a * is
used to represent all files and directories.)
4. Execute the command "more ???" and describe the result.
5. Execute the command "more ????*" and describe the result.
6. Execute the command "mkdir a b c". What was the
result of executing this command? Use the command ls
to help describe what happened.
7. Change directories to the directoy called 'a'. Execute the
command "cp ../one ./". You can use ls to determine
the result. Execute "mv one four" and describe the result.
8. Now it gets tricky! Execute the command "cd ../b". Open
emacs with the command "emacs". (Clicking on the emacs window
will ensure that it is active). In emacs type "[Ctrl]-x [Ctrl]-c
" (this means that you should press the control key and the x key at
the same time, release, and then press the control key and the c key at
the same time. If you have trouble, go to the terminal and type
"[Ctrl]-c", and restart emacs!). "[Ctrl]-x [Ctrl]-c" should
have caused emacs to quit. Reopen emacs and use it to create a text
file with the numbers 1-10 in it, where each line of the file contains
one of the numbers and the numbers are in ascending order (1 on th
first line, 2 on the second line, . . . 10 on the tenth line). You can save
the file by using the mouse and the File menu, or you can type
"[Ctrl]-x [Ctrl]-s" and emacs will prompt you for a file name at
the bottom of the window. Type the filename "numbers" and then exit
emacs with "[Ctrl]-x [Ctrl]-c". Once you exit emacs, you should
have a file called 'numbers' in the 'b' directory. Execute the command
"tail -2 numbers > ../c/last2numbers". Use the more,
ls, cd, and man commands to determine and
describe what happened!
9. Change directories back to your lab1 directory. Start netscape by
executing the command "netscape &". Using the '&' symbol will
allow you to continue to use your terminal. Once netscape loads, open
the course webpage. From their, find the self-paced lab assignment.
Download the the program hello by using your mouse.
You will need to right click on the link and select 'Save target as'. Save
the file to your home 'lab1' directory. Once you are sure you have saved
the file 'hello' into your lab1 directory, go back to the xterm (verify
that the hello file is there using ls). You will need to change
the permission on the file by executing "chmod +x hello". Executing
"ls -la" should give a detailed listing of the directory including
file permission. For hello, the permissions should include x.
Now, execute the program hello by typing "./hello". What is
the output?
10. Almost done . . . . Use the cd and ls commands
to help you draw the directory structure below lab1. We reviewed directory
structures in the last lecture!
11. Write a brief paragraph (2-3 sentences) describing your thoughts
on this lab. It was meant to teach you and familiarize you with Linux and get you comfortable
with many of the operations that you will be expected to perform throughout
this course and many more to come. Feedback of any kind will not effect
your grade! Hopefully you will thank me for this someday.
Last Modified: