Accessing a Parent Directory
And you already did something up there. You used the
cd with the two dots (
..). Yes. Before that, you used
cd to move into a folder, and here you use
cd .. to step into the parent directory.
Yep, exactly. And this might seem like it’s something different that we’re doing right here, but let’s see if we go back to doing this
ls -l we saw earlier, then we have the long listing, and I’ll also throw in an
a there, which means all.
So then I’m seeing all files, including what are called hidden files, and the difference here that you can notice that it added in
.. that looks like they are files, but they’re kind of references to—the single
. is the current directory.
So that is a way to just reference the directory that you’re currently standing in. So for instance, if I would do
cd ., that just means go to the directory you’re currently in, so do nothing in practice. This
.. is then a reference to the parent directory. So to go to the parent directory, I can do
.. like this. Okay. Yeah, that’s nice. On your prompt, we’re always seeing the folder names. So yeah, it’s a nice reminder where you are right now. Right.
And just point out that these dots are nothing particular for
cd. It kind of works with any directory. So if I, for instance, would’ve wanted to copy something up to a parent directory, I could also use the
.. inside of the
cp command, the copy command, for instance. Okay.
Become a Member to join the conversation.