Check out a free preview of the full Introduction to Bash, VIM & Regex course

The "Special Directories" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. Here's what you'd learn in this lesson:

James demonstrates special directories within the Bash shell that make it easier to navigate folders.


Transcript from the "Special Directories" Lesson

>> James: Okay, so hopefully by now everyone has had a little bit of a chance to play around with moving around in the directory structure of your system. Had a chance to use ls, and pwd, and the cd commands. And hopefully, also, all of you are following along with the GitHub Notes that I put up.

So you can consult back to everything that I've showed so far. So some examples of poking around on the directory. So an important thing on a Unix system as well is these special directories. Which include things like. And dot and tilde. So, dot dot so means the parent directory.

So, you can put this kind of anywhere in the path, like here. I mean, this directory, I can use "cg" space dot dot, now I'm in the parent of that, I can do it again, I'm in the parent of that, or I can do something like cd ../..

And now I'm gonna skip up two directories. Can see what's there. Or, maybe I want to cd ../../../ and then go into another directory. I can also do that.
>> James: And now I'm somewhere else.
>> James: So another important thing is dot, which you sometimes need. For example, if you have a command in the current directory that you wanna run, then you've gotta do ./ because otherwise commands have to be in your path, which we'll talk about later.

Also, you can put a ./ anywhere in a path and it does nothing, so for example if I use the Head command which I'll talk about later. I can do ././././././ which is the same as doing just because ./ means the current directory. So it's like a little cycle that points back to itself.

Another important thing to know about is tilde which means your home directory. So if I type cd ~, I'm gonna go to my home directory. There we are. You can also navigate around from your home directory. So if I go to cd ~/media/music/vaporwave, my vaporwave directory. I can also go to, if I want to edit a file without having to cd into that directory you can pass in the full path.

So can edit my bashrc file, like this. That's what tilde means. Some more examples of that. Another fun command that you can use to experiment and play around with dot, and dot dot, and tilde, is the cat command, yes.
>> Speaker 2: Did you cover pwd so people are going around everywhere?

>> James: Yeah we did. We covered cdpwt and ls. That's sure. Also another fun thing about cd is if you get lost somewhere in the directory structure and you don't know where you are you can type cd and it puts you back in your home directory. So it's the same thing as doing cd ~.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now