Performance Checklist
In this lab, you will create, move, and remove files and folders using a variety of file name matching shortcuts.
Outcomes
Familiarity and practice with many forms of wildcards for locating and using files.
Perform the following steps on serverX unless directed otherwise.
Log in as student and begin the lab in the home
directory.
To begin, create sets of empty practice files to use in this lab. If an intended shell expansion shortcut is not immediately recognized, students are expected to use the solution to learn and practice. Use shell tab completion to locate file path names easily.
Create a total of 12 files with names tv_seasonX_episodeY.ogg.
Replace X with the season number and Y
with that season's episode, for two seasons of six episodes each.
[student@serverX ~]$touch tv_season{1..2}_episode{1..6}.ogg[student@serverX ~]$ls -l
As the author of a successful series of mystery novels, your next
bestseller's chapters are being edited for publishing.
Create a total of eight files with names mystery_chapterX.odf.
Replace X with the numbers 1 through 8.
[student@serverX ~]$touch mystery_chapter{1..8}.odf[student@serverX ~]$ls -l
To organize the TV episodes, create two subdirectories named
season1 and season2
under the existing Videos directory. Use one command.
[student@serverX ~]$mkdir Videos/season{1..2}[student@serverX ~]$ls -lR
Move the appropriate TV episodes into the season subdirectories. Use only two commands, specifying destinations using relative syntax.
[student@serverX ~]$mv tv_season1* Videos/season1[student@serverX ~]$mv tv_season2* Videos/season2[student@serverX ~]$ls -lR
To organize the mystery book chapters,
create a two-level directory hierarchy with one command.
Create my_bestseller under the existing
Documents directory, and chapters
beneath the new my_bestseller directory.
[student@serverX ~]$mkdir -p Documents/my_bestseller/chapters[student@serverX ~]$ls -lR
Using one command, create three more subdirectories directly
under the my_bestseller directory.
Name these subdirectories editor,
plot_change, and vacation.
The create parent option is not needed since the
my_bestseller parent directory already exists.
[student@serverX ~]$mkdir Documents/my_bestseller/{editor,plot_change,vacation}[student@serverX ~]$ls -lR
Change to the chapters directory. Using the home directory
shortcut to specify the source files, move all book chapters into
the chapters directory, which is now your current directory.
What is the simplest syntax to specify the destination directory?
[student@serverX ~]$cd Documents/my_bestseller/chapters[student@serverX chapters]$mv ~/mystery_chapter* .[student@serverX chapters]$ls -l
The first two chapters are sent to the editor for review.
To remember to not modify these chapters during the review,
move those two chapters only to the editor directory.
Use relative syntax starting from the chapters subdirectory.
[student@serverX chapters]$mv mystery_chapter1.odf mystery_chapter2.odf ../editor[student@serverX chapters]$ls -l[student@serverX chapters]$ls -l ../editor
Chapters 7 and 8 will be written while on vacation.
Move the files from chapters to
vacation. Use one command without wildcard
characters.
[student@serverX chapters]$mv mystery_chapter7.odf mystery_chapter8.odf ../vacation[student@serverX chapters]$ls -l[student@serverX chapters]$ls -l ../vacation
With one command, change the working directory to the
season 2 TV episodes location, then copy the first
episode of the season to the vacation directory.
[student@serverX chapters]$cd ~/Videos/season2[student@serverX season2]$cp tv_season2_episode1.ogg ~/Documents/my_bestseller/vacation
With one command, change the working directory to
vacation, then list its files. Episode 2 is also
needed. Return to the season2 directory using
the previous working directory shortcut. This
will succeed if the last directory change was accomplished with one
command. Copy the episode 2 file into vacation.
Return to vacation using the shortcut again.
[student@serverX season2]$cd ~/Documents/my_bestseller/vacation[student@serverX vacation]$ls -l[student@serverX vacation]$cd -[student@serverX season2]$cp tv_season2_episode2.ogg ~/Documents/my_bestseller/vacation[student@serverX vacation]$cd -[student@serverX vacation]$ls -l
Chapters 5 and 6 may need a plot change. To prevent these changes
from modifying original files, copy both files into
plot_change. Move up one directory to
vacation's parent directory, then use one
command from there.
[student@serverX vacation]$cd ..[student@serverX my_bestseller]$cp chapters/mystery_chapter[56].odf plot_change[student@serverX my_bestseller]$ls -l chapters[student@serverX my_bestseller]$ls -l plot_change
To track changes, make three backups of chapter 5.
Change to the plot_change directory.
Copy mystery_chapter5.odf as a new file name
to include the full date (Year-Mo-Da).
Make another copy appending the current timestamp (as the number
of seconds since the epoch) to ensure
a unique file name.
Also make a copy appending the current user
($USER) to the file name.
See the solution for the syntax of any you are unsure of (like
what arguments to pass to the date command).
[student@serverX my_bestseller]$cd plot_change[student@serverX plot_change]$cp mystery_chapter5.odf mystery_chapter5_$(date +%F).odf[student@serverX plot_change]$cp mystery_chapter5.odf mystery_chapter5_$(date +%s).odf[student@serverX plot_change]$cp mystery_chapter5.odf mystery_chapter5_$USER.odf[student@serverX plot_change]$ls -l
Note, we could also make the same backups of the chapter 6 files too.
The plot changes were not successful. Delete the
plot_change directory. First, delete
all of the files in the plot_change
directory. Change directory up one level because the directory
cannot be deleted while it is the working directory. Try to
delete the directory using the rm command
without the recursive
option. This attempt should fail. Now use the
rmdir command, which will succeed.
[student@serverX plot_change]$rm mystery*[student@serverX plot_change]$cd ..[student@serverX my_bestseller]$rm plot_changerm: cannot remove 'plot_change': Is a directory[student@serverX my_bestseller]$rmdir plot_change[student@serverX my_bestseller]$ls -l
When the vacation is over, the vacation directory
is no longer needed. Delete it using the rm
command with the recursive option.
When finished, return to the home directory.
[student@serverX my_bestseller]$rm -r vacation[student@serverX my_bestseller]$ls -l[student@serverX my_bestseller]$cd