There are useful shortcuts that you can use when specifying a path.
- "." (a single period or dot) refers to the current directory
- ".." (a double period, or two adjacent dots) refers to the parent directory, relative to wherever you happen to be in the path up to this point
- To move to a parent directory, we can type cdSpace..
- To move to a grandparent directory, we can type cdSpace../..
Assume we have a directory named 'parent' with two children, 'childA' and 'childB', and we are currently inside the 'childB' directory and want to enter the 'childA' directory.
- To move to a sibling directory, we can type cdSpace../childA
View the Directory Hierarchy
Sometimes it’s helpful to obtain an overview of our directory hierarchy. We can do this with the tree command. Let's try:
│ ├─ newFile.txt
│ └─ out.txt
- How does the ls command differ from the tree command?
- How do you choose to use one over the other?
Remove a Directory
Let's remove the two directories that we won't be using anymore. We can do this with the rmdir command. Move to the Merlin directory and then remove the hello2 and hello3 directories. Then do a directory listing to see what’s left.
john-williams@codermerlin:~$ cd Merlin
john-williams@codermerlin:~/Merlin$ rmdir hello2
john-williams@codermerlin:~/Merlin$ rmdir hello3