cd - The Change Directory Command

JakeCorn2 403 views 15 slides Nov 03, 2016
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

Learn the cd command! As one of the most commonly used and needed commands, understanding it's full potential will give you a better command of filesystems! Please Visit Me at: www.HatBoySoftware.com

Jake Corn - [email protected]


Slide Content

The “cd” (Change Directory) Command Mac Terminal Tutorial

“ls” to list all the contents of the current directory so that we can see where we want to change directory into.

“cd” (Change Directory) into the Desktop directory by typing “cd Desktop”. This works for any directory that’s within the current directory. SYNTAX: cd dirName

To Change Directory (cd) into a directory that has a space in its name, place the folder’s (directory’s) name in quotation marks (“folder name”). This makes it so that the “cd” command sees the two words as one argument.

In this example I first attempted to Change Directory by simply typing my folder . It didn’t work because there is no directory (folder) with the name of “my”. So it threw an error. I corrected this by putting the “directory name” in quotation marks. I could’ve also used the escape character \ before the space to tell the program to ignore space

Typing “..” after a filesystem command references the “Parent Directory”. What we are saying here is… Change Directory into the “Parent Directory”. Parent Directory - the directory our working directory is in.

To teach the next slide I need to first show the order of directories we’ll be working with. “my folder” is in the “Desktop” directory… “Tutorials” is in the “my folder” directory..

In this Command what I was wanting to do was to change into the “Tutorials” directory which is a “sub-directory” of the “my folder” directory -- which is a “sub-directory” of the “Desktop” directory. “cd” dirName/subDirName

If we want to get back to the “parent’s parent directory” we just change directory (cd) and provide it the argument of “../..”. You may remember that “..” changes our directory to the parent directory….so this is just an extension of that concept.

A useful shorthand for Changing Directory into the “home (user)” directory is to simply type “cd” all by itself.

You can also provide “cd” with a tilda “~” to change to the “home” directory. 2 ways, same thing.

Root Directory - The directory which has no parent. To change into the root directory from anywhere, provide “cd” with an argument of “/”. “cd /”

Absolute Path: Wherever you are in the filesystem, you can always provide the “cd” command with the “absolute file path” to the directory you’re wanting to change into. Absolute file path HAS to start with “root” - /

Thanks For Watching. Please Visit: www.HatBoySoftware.com Jake Corn - [email protected]