Identify the file system hierarchy and navigate directories.
Outcomes
Navigate to a different directory by using absolute and relative paths.
Identify your current directory.
View a directory structure.
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-directory
Instructions
Use the tree command to view the directory structure of the /home/student directory, and use the -L 1 option to restrict the output to one level of results.
[student@workstation ~]$ tree -L 1
.
├── Desktop
├── Documents
├── Downloads
├── Music
├── Pictures
├── Public
├── Templates
└── VideosWithout changing to the Documents directory, create a Work directory in the Documents directory by using a relative path.
[student@workstation ~]$ mkdir Documents/WorkChange your current working directory to the new directory that you created.
[student@workstation ~]$ cd Documents/WorkFrom your new location, change to the Downloads directory by using a relative path.
[student@workstation Work]$ cd ../../DownloadsView the path of your current directory.
[student@workstation Downloads]$ pwd
/home/student/DownloadsRedirect output into a file called hello.txt in the Documents/Work directory by using the absolute path.
[student@workstation Downloads]$ echo "hello world" > \
/home/student/Documents/Work/hello.txtView the contents of the hello.txt file by using a relative path.
[student@workstation Downloads]$ cat ../Documents/Work/hello.txt
hello worldUse the relative path to the hello.txt file to obtain its absolute path.
[student@workstation Downloads]$ realpath ../Documents/Work/hello.txt
/home/student/Documents/Work/hello.txtView the contents of the hello.txt file by using the absolute path.
[student@workstation Downloads]$ cat /home/student/Documents/Work/hello.txt
hello worldReturn to the student user home directory by using the default action of the cd command.
[student@workstation Downloads]$ cd
[student@workstation ~]$