Directories Revisited
You can use several helpful shortcuts 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
Thus:
- 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 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[edit]
Sometimes it's helpful to obtain an overview of our directory hierarchy. We can do this with the tree command. Let's try:
john-williams@codermerlin:~$ tree
.
└─ Merlin
├─ hello
│ ├─ newFile.txt
│ └─ out.txt
├─ hello2
└─ hello3
- How does the ls command differ from the tree command?
- How do you choose to use one over the other?
Remove a Directory[edit]
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
john-williams@codermerlin:~/Merlin$ ls
hello