Lab Manage Files From The Command Line
Lab Manage Files From The Command Line
A later version of
Table of Contents Course Lab Environment this course is
available
(/rol/app/courses/rh124-9.0/pages/ch03s10)
Previous (/rol/app/cour
Next
Outcomes
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
Instructions
1. Use the ssh command to log in to the serverb machine as the student user. The system's configuration supports the use of SSH keys for authentication.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 2/11
9/12/24, 4:48 PM RH124 - ch03s11
Hide Solution
2. Create a directory called project_plans in the Documents directory. The Documents directory is placed in the student user's home directory. Create two empty files
in the project_plans directory called season1_project_plan.odf and season2_project_plan.odf.
Hint: If the ~/Documents directory does not exist, then use the mkdir command -p option to create it.
Documents/project_plans:
total 0
-rw-r--r--. 1 student student 0 Mar 7 03:50 season1_project_plan.odf
-rw-r--r--. 1 student student 0 Mar 7 03:50 season2_project_plan.odf
Hide Solution
3. Create sets of empty practice files to use in this lab. If you do not immediately recognize the intended shell expansion shortcut, then use the solution to learn
and practice. Use shell tab completion to locate file path names. Create 12 files with tv_seasonX_episodeY.ogg names in the /home/student directory. Replace X
with the season number and Y with that season's episode, for two seasons of six episodes each.
Hide Solution
4. As the author of a successful series of mystery novels, you are editing your next bestseller's chapters for publishing. Create eight files with mystery_chapterX.odf
names. Replace X with the numbers 1 through 8.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 3/11
9/12/24, 4:48 PM RH124 - ch03s11
Hide Solution
5. Use a single command to create two subdirectories called season1 and season2 under the Videos directory to organize the TV episodes. Move the appropriate TV
episodes into the season subdirectories. Use only two commands, and specify destinations with relative syntax.
5.1. Create two subdirectories called season1 and season2 under the Videos directory by using a single command.
5.2. Move the appropriate TV episodes into the season subdirectories by using only two commands.
Videos/season1:
tv_season1_episode1.ogg tv_season1_episode3.ogg tv_season1_episode5.ogg
tv_season1_episode2.ogg tv_season1_episode4.ogg tv_season1_episode6.ogg
Videos/season2:
tv_season2_episode1.ogg tv_season2_episode3.ogg tv_season2_episode5.ogg
tv_season2_episode2.ogg tv_season2_episode4.ogg tv_season2_episode6.ogg
Hide Solution
6. Create a two-level directory hierarchy with a single command to organize the mystery book chapters. Create the my_bestseller subdirectory under the
Documents directory, and create the chapters subdirectory under the new my_bestseller directory. Create three more subdirectories directly under the
my_bestseller directory with a single command. Name these subdirectories editor, changes, and vacation. You do not need to use the mkdir -p command to
create parents because the my_bestseller parent directory exists.
6.1. Create the my_bestseller directory under the Documents directory. Create the chapters directory under the my_bestseller directory.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 4/11
9/12/24, 4:48 PM RH124 - ch03s11
Documents/my_bestseller:
chapters
Documents/my_bestseller/chapters:
Documents/project_plans:
season1_project_plan.odf season2_project_plan.odf
6.2. Create three directories called editor, changes, and vacation, under the my_bestseller directory by using a single command.
Documents/my_bestseller:
changes chapters editor vacation
Documents/my_bestseller/changes:
Documents/my_bestseller/chapters:
Documents/my_bestseller/editor:
Documents/my_bestseller/vacation:
Documents/project_plans:
season1_project_plan.odf season2_project_plan.odf
Hide Solution
7. Change to the chapters directory. Use the tilde (~) home directory shortcut to move all book chapters to the chapters directory, which is now your current
directory. Use the simplest syntax to specify the destination directory.
You want to send the first two chapters to the editor for review. Move only those two chapters to the editor directory to avoid modifying them during the
review. Starting from the chapters subdirectory, use brace expansion with a range to specify the chapter file names to move and a relative path for the
destination directory.
While on vacation, you intend to write chapters 7 and 8. Use a single command to move the files from the chapters directory to the vacation directory. Specify
the chapter file names by using brace expansion with a list of strings and without using wildcard characters.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 5/11
9/12/24, 4:48 PM RH124 - ch03s11
7.1. Change to the chapters directory and use the tilde (~) home directory shortcut to move all book chapters to the chapters directory.
7.2. Move the first two chapters to the editor directory. Use brace expansion with a range to specify the chapter file names to move and a relative path for
the destination directory.
7.3. Use a single command to move the chapters 7 and 8 from the chapters directory to the vacation directory. Specify the chapter file names by using
brace expansion with a list of strings and without using wildcard characters.
Hide Solution
8. Change your working directory to ~/Videos/season2, and then copy the first episode of the season to the vacation directory. Use a single cd command to change
from your working directory to the ~/Documents/my_bestseller/vacation directory. List its files. Use the previous working directory argument to return to the
season2 directory. (This argument succeeds if the last directory change with the cd command used only one command rather than several cd commands.) From
the season2 directory, copy the episode 2 file into the vacation directory. Use the shortcut again to return to the vacation directory.
8.1. Change your working directory to ~/Videos/season2, and then copy the first episode of the season to the vacation directory.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 6/11
9/12/24, 4:48 PM RH124 - ch03s11
8.2. Use a single cd command to change from your working directory to the ~/Documents/my_bestseller/vacation directory, list its files, and use the -
argument to return to the previous directory. Copy the episode 2 file into the vacation directory. Use the cd command with the - argument to return to
the vacation directory.
Hide Solution
9. The authors of chapters 5 and 6 want to experiment with possible changes. Copy both files from the ~/Documents/my_bestseller/chapters directory to the
~/Documents/my_bestseller/changes directory to prevent these changes from modifying original files. Navigate to the ~/Documents/my_bestseller directory. Use
square-bracket pattern matching to specify which chapter numbers to match in the filename argument of the cp command.
Hide Solution
10. Change your current directory to the changes directory and use the date +%F command with command substitution to copy the mystery_chapter5.odf file to a
new file that includes the full date. Use the mystery_chapter5_YYYY-MM-DD.odf name format.
By using command substitution with the date +%s command, make another copy of mystery_chapter5.odf, and append the current time stamp (as the number
of seconds since the epoch, 1970-01-01 00:00 UTC) to ensure a unique file name.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 7/11
9/12/24, 4:48 PM RH124 - ch03s11
Hide Solution
11. After further review, you decide that you do not need the plot changes. Delete the changes directory.
If it is necessary, then navigate to the changes directory and delete all the files within the directory. You cannot delete a directory when it is the current working
directory.
Change to the parent directory of the changes directory. Try to delete the empty directory by using the rm command without the -r recursive option. This
attempt should fail. Finally, use the rmdir command to delete the empty directory, which succeeds.
When the vacation is over, you no longer need the vacation directory. Delete it by using the rm command with the recursive option.
11.1. Delete the changes directory. Change to the parent directory of the changes directory, and try to delete the empty directory by using the rm command
without the -r recursive option, which should fail. Use the rmdir command to delete the empty directory.
11.2. Delete the vacation directory by using the rm command with the -r option. Return to the student user's home directory.
Hide Solution
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 8/11
9/12/24, 4:48 PM RH124 - ch03s11
12. Create a hard link to the ~/Documents/project_plans/season2_project_plan.odf file called ~/Documents/backups/season2_project_plan.odf.back. A hard link
protects against accidental deletion of the original file and keeps the backup file updated as you change the original file.
Hint: If the ~/Documents/backups directory does not exist, then use the mkdir command to create it.
/home/student/Documents/backups:
total 0
-rw-r--r--. 2 student student 0 Mar 7 03:50 season2_project_plan.odf.back
/home/student/Documents/my_bestseller:
total 0
drwxr-xr-x. 2 student student 118 Mar 7 04:07 chapters
drwxr-xr-x. 2 student student 62 Mar 7 04:06 editor
/home/student/Documents/my_bestseller/chapters:
total 0
-rw-r--r--. 1 student student 0 Mar 7 03:56 mystery_chapter3.odf
-rw-r--r--. 1 student student 0 Mar 7 03:56 mystery_chapter4.odf
-rw-r--r--. 1 student student 0 Mar 7 03:56 mystery_chapter5.odf
-rw-r--r--. 1 student student 0 Mar 7 03:56 mystery_chapter6.odf
/home/student/Documents/my_bestseller/editor:
total 0
-rw-r--r--. 1 student student 0 Mar 7 03:56 mystery_chapter1.odf
-rw-r--r--. 1 student student 0 Mar 7 03:56 mystery_chapter2.odf
/home/student/Documents/project_plans:
total 0
-rw-r--r--. 1 student student 0 Mar 7 03:50 season1_project_plan.odf
-rw-r--r--. 2 student student 0 Mar 7 03:50 season2_project_plan.odf
Notice that the link count is 2 for both season2_project_plan.odf.back and season2_project_plan.odf files.
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 9/11
9/12/24, 4:48 PM RH124 - ch03s11
Hide Solution
Evaluation
As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.
Finish
On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that
resources from previous exercises do not impact upcoming exercises.
(/rol/app/courses/rh124-9.0/pages/ch03s10)
Previous (/rol/app/cour
Next
RH124 Chapter 15 Lab 3: Install zsh Package Red Hat System Administration I | Guided Red Hat System Administration I (RH124)
VictoriaB97 16 Jan 2024 Exercise: Explain and Investigate RPM Softwar… Haley_Ruccio 19 Jul 2023
AbeHiero 10 Nov 2023
Hello,I am trying to finish up Lab 3 of the Chapter 15 The first of two courses covering the core system
I cannot start the lab with command: lab start software-
Comprehensive Review Labs in RH124, and when I type… administration tasks needed to manage Red Hat…
rpm. I get this error:ModuleNotFoundError: No module…
1 2 378 1 2 1183 3 1 336
Revision: rh124-9.0-bb67ff8
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 10/11
9/12/24, 4:48 PM RH124 - ch03s11
https://rol.redhat.com/rol/app/courses/rh124-9.0/pages/ch03s11 11/11