Manipulate files across different directories.
Outcomes
Create, copy, move, rename, and find files and directories.
Create shortcuts to files and to directories.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
[student@workstation ~]$ lab start filesystem-organize
Instructions
Create a Work directory in the Documents directory.
[student@workstation ~]$ mkdir Documents/WorkCreate an empty file called test.txt in the Documents/Work directory.
[student@workstation ~]$ touch Documents/Work/test.txtMove the test.txt file to the Documents directory.
[student@workstation ~]$ mv Documents/Work/test.txt DocumentsConfirm the file's new location by listing the contents of the Documents directory.
[student@workstation ~]$ ls Documents
Work test.txtCopy the test.txt file into the Work directory and rename it to myfile.txt.
Then remove the test.txt file in the Documents directory.
You can perform these tasks in one command by using the mv command.
[student@workstation ~]$ mv Documents/test.txt Documents/Work/myfile.txtConfirm the file's new location by using the find command.
[student@workstation ~]$ find /home/student -iname myfile.txt
/home/student/Documents/Work/myfile.txtVerify that the ~/.local/share/Trash/files directory exists.
If the directory does not exist, then create the directory.
Create the Bin symbolic link to the ~/.local/share/Trash/files directory.
Verify that the ~/.local/share/Trash/files directory exists.
[student@workstation ~]$ ls -l ~/.local/share/Trash/files
ls: cannot access '/home/student/.local/share/Trash/files': No such file or directoryCreate the Trash directory under the ~/.local/share directory.
Make sure to create any directory that is missing in the path.
[student@workstation ~]$ mkdir -p ~/.local/share/Trash/filesCreate the Bin symbolic link to the Trash directory.
[student@workstation ~]$ ln --symbolic /home/student/.local/share/Trash/files BinRename the Work directory to Done, and move it to the Trash directory by using the Bin symbolic link.
You can perform these tasks in one command by using the mv command.
[student@workstation ~]$ mv Documents/Work Bin/DoneCreate a symbolic link to the test.txt file.
[student@workstation ~]$ ln --symbolic Documents/test.txt "shortcut to test.txt"Add the hello world text to the shortcut to test.txt file.
You can perform this task by using the echo command and redirecting the output.
[student@workstation ~]$ echo "hello world" > "shortcut to test.txt"Confirm that the text appears in the test.txt file.
[student@workstation ~]$ cat Documents/test.txt
hello world