0% found this document useful (0 votes)
119 views5 pages

Guided Exercise-Day2 PDF

This document provides instructions for an exercise to practice managing files and directories from the command line. It details how to create directories and empty files on a server, organize the files by moving them into the appropriate directories, copy files between directories, and finally delete the directories and files to clean up. The goal is to help students learn how to create, organize, copy and remove files and directories using command line tools.

Uploaded by

Shriram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views5 pages

Guided Exercise-Day2 PDF

This document provides instructions for an exercise to practice managing files and directories from the command line. It details how to create directories and empty files on a server, organize the files by moving them into the appropriate directories, copy files between directories, and finally delete the directories and files to clean up. The goal is to help students learn how to create, organize, copy and remove files and directories using command line tools.

Uploaded by

Shriram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Guided Exercise: Manage Files with Command-line Tools

In this exercise, you create, organize, copy, and remove files and directories.

Outcomes

 Create, organize, copy, and remove files and directories.


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.

[student@workstation ~]$ lab start files-manage

Procedure 3.1. Instructions

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.

[student@servera ~]$ mkdir Music Pictures 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.

3. [student@servera ~]$ touch song1.mp3 song2.mp3 song3.mp3 \


4. song4.mp3 song5.mp3 song6.mp3
5. [student@servera ~]$ touch snap1.jpg snap2.jpg snap3.jpg \
6. snap4.jpg snap5.jpg snap6.jpg
7. [student@servera ~]$ touch film1.avi film2.avi film3.avi \
8. film4.avi film5.avi film6.avi
9. [student@servera ~]$ ls -l
10. total 0
11. -rw-r--r--. 1 student student 0 Mar 7 20:58 film1.avi
12. -rw-r--r--. 1 student student 0 Mar 7 20:58 film2.avi
13. -rw-r--r--. 1 student student 0 Mar 7 20:58 film3.avi
14. -rw-r--r--. 1 student student 0 Mar 7 20:58 film4.avi
15. -rw-r--r--. 1 student student 0 Mar 7 20:58 film5.avi
16. -rw-r--r--. 1 student student 0 Mar 7 20:58 film6.avi
17. drwxr-xr-x. 2 student student 6 Mar 7 20:58 Music
18. drwxr-xr-x. 2 student student 6 Mar 7 20:58 Pictures
19. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap1.jpg
20. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap2.jpg
21. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap3.jpg
22. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap4.jpg
23. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap5.jpg
24. -rw-r--r--. 1 student student 0 Mar 7 20:58 snap6.jpg
25. -rw-r--r--. 1 student student 0 Mar 7 20:58 song1.mp3
26. -rw-r--r--. 1 student student 0 Mar 7 20:58 song2.mp3
27. -rw-r--r--. 1 student student 0 Mar 7 20:58 song3.mp3
28. -rw-r--r--. 1 student student 0 Mar 7 20:58 song4.mp3
29. -rw-r--r--. 1 student student 0 Mar 7 20:58 song5.mp3
30. -rw-r--r--. 1 student student 0 Mar 7 20:58 song6.mp3

drwxr-xr-x. 2 student student 6 Mar 7 20:58 Videos

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

-rw-r--r--. 1 student student 0 Mar 7 20:58 film6.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.

0. Copy files that contain numbers 1 and 2 to the friends directory.


1. [student@servera ~]$ cd friends
2. [student@servera friends]$ cp ~/Music/song1.mp3 ~/Music/song2.mp3 \
3. ~/Pictures/snap1.jpg ~/Pictures/snap2.jpg ~/Videos/film1.avi \
4. ~/Videos/film2.avi .
5. [student@servera friends]$ ls -l
6. total 0
7. -rw-r--r--. 1 student student 0 Mar 7 21:02 film1.avi
8. -rw-r--r--. 1 student student 0 Mar 7 21:02 film2.avi
9. -rw-r--r--. 1 student student 0 Mar 7 21:02 snap1.jpg
10. -rw-r--r--. 1 student student 0 Mar 7 21:02 snap2.jpg
11. -rw-r--r--. 1 student student 0 Mar 7 21:02 song1.mp3

-rw-r--r--. 1 student student 0 Mar 7 21:02 song2.mp3

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

drwxr-xr-x. 2 student student 108 Mar 7 21:05 friends

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

drwxr-xr-x. 2 student student 108 Mar 7 21:00 Videos

87. Return to the workstation system as the student user.


88. [student@servera ~]$ exit
89. logout
90. Connection to servera closed.

[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.

[student@workstation ~]$ lab finish files-manage

This concludes the section.

You might also like