Guided Exercise-Day2 PDF
Guided Exercise-Day2 PDF
In this exercise, you create, organize, copy, and remove files and directories.
Outcomes
This command prepares your environment and ensures that all required resources are available.
1. Log in to the servera machine as the student user. In the student user's home directory,
create three subdirectories: Music, Pictures, and Videos.
1. Use the ssh command to log in to the servera machine as the student user. The
systems are configured to use SSH keys for authentication; therefore, a password is
not required.
2. [student@workstation ~]$ ssh student@servera
3. ...output omitted...
[student@servera ~]$
4. In the student user's home directory, use the mkdir command to create three
subdirectories: Music, Pictures, and Videos.
2. Use the touch command to create sets of empty practice files to use during this lab. In each
set, replace X with the numbers 1 through 6.
Create six files with names of the form songX.mp3.
Create six files with names of the form snapX.jpg.
Create six files with names of the form filmX.avi.
31. Move the song files (.mp3 extension) to the Music directory, the snapshot files (.jpg extension)
to the Pictures directory, and the movie files (.avi extension) to the Videos directory.
32. [student@servera ~]$ mv song1.mp3 song2.mp3 song3.mp3 \
33. song4.mp3 song5.mp3 song6.mp3 Music
34. [student@servera ~]$ mv snap1.jpg snap2.jpg snap3.jpg \
35. snap4.jpg snap5.jpg snap6.jpg Pictures
36. [student@servera ~]$ mv film1.avi film2.avi film3.avi \
37. film4.avi film5.avi film6.avi Videos
38. [student@servera ~]$ ls -l Music Pictures Videos
39. Music:
40. total 0
41. -rw-r--r--. 1 student student 0 Mar 7 20:58 song1.mp3
42. -rw-r--r--. 1 student student 0 Mar 7 20:58 song2.mp3
43. -rw-r--r--. 1 student student 0 Mar 7 20:58 song3.mp3
44. -rw-r--r--. 1 student student 0 Mar 7 20:58 song4.mp3
45. -rw-r--r--. 1 student student 0 Mar 7 20:58 song5.mp3
46. -rw-r--r--. 1 student student 0 Mar 7 20:58 song6.mp3
47.
48. Pictures:
49. total 0
50. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap1.jpg
51. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap2.jpg
52. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap3.jpg
53. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap4.jpg
54. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap5.jpg
55. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap6.jpg
56.
57. Videos:
58. total 0
59. -rw-r--r--. 1 student student 0 Mar 7 20:58 film1.avi
60. -rw-r--r--. 1 student student 0 Mar 7 20:58 film2.avi
61. -rw-r--r--. 1 student student 0 Mar 7 20:58 film3.avi
62. -rw-r--r--. 1 student student 0 Mar 7 20:58 film4.avi
63. -rw-r--r--. 1 student student 0 Mar 7 20:58 film5.avi
64. Create three subdirectories for organizing your files, and name the
subdirectories friends, family, and work. Use a single command to create all three
subdirectories at the same time.
65. [student@servera ~]$ mkdir friends family work
66. [student@servera ~]$ ls -l
67. total 0
68. drwxr-xr-x. 2 student student 6 Mar 7 21:01 family
69. drwxr-xr-x. 2 student student 6 Mar 7 21:01 friends
70. drwxr-xr-x. 2 student student 108 Mar 7 21:00 Music
71. drwxr-xr-x. 2 student student 108 Mar 7 21:00 Pictures
72. drwxr-xr-x. 2 student student 108 Mar 7 21:00 Videos
drwxr-xr-x. 2 student student 6 Mar 7 21:01 work
73. Copy files that contain numbers 1 and 2 to the friends directory and files that contain
numbers 3 and 4 to the family directory. Keep in mind that you are making copies; therefore,
the original files must remain in their original locations after you complete the step.
When you copy files from multiple locations into a single location, Red Hat recommends that
you change to the destination directory before you copy the files. Use the simplest path
syntax, whether absolute or relative, to reach the source for each file management task.
12. Copy files that contain numbers 3 and 4 to the family directory.
13. [student@servera friends]$ cd ../family
14. [student@servera family]$ cp ~/Music/song3.mp3 ~/Music/song4.mp3 \
15. ~/Pictures/snap3.jpg ~/Pictures/snap4.jpg ~/Videos/film3.avi \
16. ~/Videos/film4.avi .
17. [student@servera family]$ ls -l
18. total 0
19. total 0
20. -rw-r--r--. 1 student student 0 Mar 7 21:04 film3.avi
21. -rw-r--r--. 1 student student 0 Mar 7 21:04 film4.avi
22. -rw-r--r--. 1 student student 0 Mar 7 21:04 snap3.jpg
23. -rw-r--r--. 1 student student 0 Mar 7 21:04 snap4.jpg
24. -rw-r--r--. 1 student student 0 Mar 7 21:04 song3.mp3
-rw-r--r--. 1 student student 0 Mar 7 21:04 song4.mp3
74. Copy the family and friends directories and their contents to the work directory.
75. [student@servera family]$ cd ../work
76. [student@servera work]$ cp -r ~/family ~/friends .
77. [student@servera work]$ ls -l
78. total 0
79. drwxr-xr-x. 2 student student 108 Mar 7 21:05 family
80. Your project tasks are now complete, and it is time to clean up the directories. Use the rmdir -
r command to recursively delete the family, friends, and work directories and their contents.
81. [student@servera work]$ cd ..
82. [student@servera ~]$ rm -r family friends work
83. [student@servera ~]$ ls -l
84. total 0
85. drwxr-xr-x. 2 student student 108 Mar 7 21:00 Music
86. drwxr-xr-x. 2 student student 108 Mar 7 21:00 Pictures
[student@workstation ~]$
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.