Reading: The manual pages for the various commands are a great resource (man command-name). They describe the options each command accepts and well as (in some cases) showing examples of how to use the commands. Microsoft Copilot can also be helpful at getting you started, but you should double-check any information it provides by reviewing the manual pages.
In my Unix Overview document read the first five sections in the chapter "Basic Unix Concepts" (through "The File System"). Skim over the chapter "Basic Unix Commands" and read the "Wildcards" section in "The Bourne Shell" chapter.
In this lab you will experiment with some basic file manipulation commands.
For each item below give not only your answer but also show the commands or procedure you used to check your answer. In some cases you will need to create some small text files. Use the editor nano to do this.
What happens if you try to remove a directory that is not empty?
What happens if you try to change the name of a file to a name that is already in use by another file?
What happens if you try to copy a file on top of an existing file?
What happens if you try to copy a file on top of an existing directory?
What happens if you try to remove a file that does not exist?
What happens if you try to remove a directory that is not empty?
Suppose your current working directory is /usr/local. Show a cd command that you could use to change to each of the following directories. Use relative paths (meaning no leading slash character). Assume that you are in /usr/local initially in each case (do not carry over the effects of a command from one part to the next).
/usr/local/bin
/usr/local/lib/python3.12
/usr/share
/usr/share/fonts
/lib/modules
Suppose you had a directory containing a number of text files with names like journal-2025-08-01.txt with different dates for each file. These files represent different entries in your personal journal. Use the ls command with the -l option to list information about the following sets of files. You may want to create a few files to check your commands.
All journal entries for the year 2025 (but not any other files that happen to have "2025" in their names).
All journal entries for the months of August and September in 2025.
List all journal entries with names ending in -bak (i.e., backup files).
Any images associated with journal entries for the month of August 2025. Assume images follow the same naming convention except with a .jpg extension rather than .txt. For testing purposes you can create a text file with a suitable name. The fact that it is not a real image won't impact the shell's globbing function.
As before, list image files but this time assume images might have a .jpg extension or a .png extension. Use only one command to list both kinds of files.
As before, except allow or the possibility that the extension might be upper or lower case, or even mixed case (such as jPg). Hint: Use character class wildcards.
For this lab submit a document that details the steps you took and the commands you used to answer each question. The lab is worth 20 points.
Last Revised: 2025-09-04
© Copyright 2025 by Peter Chapin <peter.chapin@vermontstate.edu>