Shell/Directories Revisited

From Coder Merlin

Directories (Revisited)[edit]

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

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

ObserveIcon.png
Observe, Ponder, and Journal : Section 7
  1. How does the ls command differ from the tree command?
  2. 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 



CoderMerlin™ proudly recommends:
HintIcon.png

Your purchase via these links helps keep  Coder Merlin™ 's orbuculum ablaze. As an Amazon Associate we earn from qualifying purchases. Thank you for your support!


Designed with pride in Silicon Valley, CA, USA