Chapter 2.
Working on the Command
Line
These labs should be performed on the Ubuntu operating system that you
installed in Chapter 1, “Distributions and Key Components.” Before you begin
this lab, log in to the student account that you created during the installation
process.
Lab 2.1 Manage Files
STEP 1. Open a terminal window.
STEP 2. Display your current directory.
STEP 3. Using an absolute pathname, switch to the /etc directory.
STEP 4. Using a relative pathname, move to the /etc/skel directory.
STEP 5. Using a relative pathname, move up one directory.
STEP 6. List the files in the current directory.
STEP 7. Perform a “long display” listing of the files in the current directory.
STEP 8. List all the files in the current directory that begin with the letter s.
STEP 9. Run the command that will determine the type of contents in the
/etc/group file.
STEP 10. Display only the last five lines of the /etc/group file.
STEP 11. Execute the command to return to your home directory.
STEP 12. Make a directory named data in the current directory.
STEP 13. Copy the /etc/passwd file into the data directory.
STEP 14. Copy the /etc/ppp directory into the current directory (and ignore any
“Permission denied” error messages).
STEP 15. Rename the ppp directory that is located in the current directory to
peers.
STEP 16. Update the timestamp of the data/passwd file to the current date and
time.
STEP 17. Create a new empty file named test in the data directory.
STEP 18. Delete the data/passwd file.
STEP 19. Delete the peers directory.
Lab 2.2 Using Shell Features
STEP 1. Open a terminal window.
STEP 2. Display the value of the HOME variable.
STEP 3. Display all the shell variables and values.
STEP 4. Display the value of the TEST variable. (Note that this variable
currently has no value.)
STEP 5. Change the current shell so that an error message will be displayed
when an undefined variable is used.
STEP 6. Modify the PATH variable to include the /opt directory.
STEP 7. Create a new environment variable named EVENT and set it to the
value “now” by using a single command.
STEP 8. Display all the environment variables.
STEP 9. Create an alias in the current shell for the ls command so it will run the
command ls -a.
STEP 10. Display all the aliases for the current shell.
STEP 11. Remove the fgrep alias from the current shell.
STEP 12. Display a list of previously executed commands.
STEP 13. Re-execute the last ls command from the history list.
STEP 14. Change the maximum number of commands stored in the history list
for the current shell to a value of 2000.
STEP 15. Execute the ps -fe command and pipe the output to the less command.
STEP 16. List all filenames in the /etc directory structure (including
subdirectories) that are group owned by the lp group.
STEP 17. Display all the files in the /etc/passwd file that contain at least three
sequential numbers.
STEP 18. Display the /etc/passwd file with all occurrences of root replaced with
XXXX.
Lab 2.3 Compressing Files
STEP 1. Open a terminal window.
STEP 2. While using the verbose feature, create a tar file named ppp.tar that
contains the contents of the /etc/ppp directory. (Ignore any error
messages.)
STEP 3. List the contents of the ppp.tar file.
STEP 4. Create a directory named tar_data in the current directory.
STEP 5. Extract the contents of the ppp.tar file into the tar_data directory.
STEP 6. Compress the ppp.tar file by using the gzip command but don’t
overwrite the existing ppp.tar file; rather, create a new file named
ppp.tar.gz.
STEP 7. Compress the ppp.tar file with the bzip2 command but don’t overwrite
the existing ppp.tar file; rather, create a new file named ppp.tar.bz2.
STEP 8. Compare the size of the ppp.tar.gz and ppp.tar.bz2 files to determine
which one is smaller.
STEP 9. Delete the ppp.tar file.
STEP 10. Unzip the ppp.tar.gz file.
Chapter 3. Getting Help
These labs should be performed on the Ubuntu operating system that you
installed in Chapter 1, “Distributions and Key Components.” Before you begin
this lab, log in to the student account that you created during the installation
process.
Lab 3.1 Getting Help with man
STEP 1. Open a terminal window.
STEP 2. Display the man page for the ls command.
STEP 3. Search for the term sort.
STEP 4. Continue the search until you find the option to sort by file size.
STEP 5. Quit the man page.
STEP 6. Determine which sections the ls command is in.
STEP 7. Search the man pages for the keyword list and pipe the output to the
less command.
STEP 8. Execute the su - command to switch to the root account. (Enter the
root password when prompted.)
STEP 9. Run the command to update the man page databases.
STEP 10. Run the exit command to return to the student account.
STEP 11. Change the MANPATH variable to include the /var/man directory.
STEP 12. Execute the ls command with the option to display help information
for the command.
STEP 13. Use the help command to display information about the umask
command.
Lab 3.2 Getting Help with info
STEP 1. Open a terminal window.
STEP 2. Execute the info command with no arguments.
STEP 3. Go to the File permissions section.
STEP 4. Go to the Mode Structure section.
STEP 5. Enter the command to move to the next node (which should be node
27.2)
STEP 6. Enter the command to return to the previous node (which should be
node 27.1).
STEP 7. Enter the command to return to the parent node (which should be node
27).
STEP 8. Enter the command to return to the node you were last in (which
should be 27.1).
STEP 9. Quit the info pages.
Note
From this point on, you may need to view man or info pages in
order to complete the labs.
Chapter 4. Editing Files
These labs should be performed on the Ubuntu operating system that you
installed in Chapter 1, “Distributions and Key Components.” Before you begin
this lab, log in to the student account that you created during the installation
process.
Answers may vary in this lab, as there are multiple ways to accomplish various
tasks in vim.
Lab 4.1 Editing Files with the vim Editor
STEP 1. Open a terminal window.
STEP 2. Copy the /usr/share/doc/git-doc/user-manual.txt file into your
current directory (This file was chosen because it is on the system by
default and is a rather large file.)
STEP 3. Open the user-manual.txt file in a vim editor.
STEP 4. Move down 12 lines
STEP 5. In insert mode, enter the following: *****
STEP 6. Return to the command mode.
STEP 7. Go to line 43.
STEP 8. Delete the current line.
STEP 9. Move down one line.
STEP 10. Open a new line below the current line.
STEP 11. Enter the following text into the document: Review this data
STEP 12. Return to the command mode.
STEP 13. Go to the top of the file.
STEP 14. Move forward three sentences.
STEP 15. Move forward four words.
STEP 16. Search for the term example.
STEP 17. Continue to the next occurrence of the search term.
STEP 18. Delete the current word.
STEP 19. Go to the end of the document.
STEP 20. Paste the text from the buffer at the end of the current line.
STEP 21. Return to the top of the document.
STEP 22. Replace all occurrences of project with program throughout the
document.
STEP 23. Save and quit the document.
STEP 24. Run the vimtutor program and then read and follow all the steps in
that program.