Baby Steps in Unix/Linux Part 2: Change Directories
One of the common tasks you’ll be doing in Terminal is changing directories. What Unix calls “directories” are the same as what most of us call “folders” on our computers.
Experiment with the cd (“change directory”) command to find out how it works.
Use the ls (“list”) command to see the names of directories that are inside the current one. You will probably see one named Desktop, so let’s peek inside that one. Type the following and then press Return (or Enter):
Remember that Unix is case sensitive, so pay attention to that uppercase letter “D” in Desktop.
To see what’s inside Desktop (“list” the contents), type the following and then press Return (or Enter):
You should see the names of all the stuff that’s on your Mac Desktop.
To go back “up” to the parent directory (the one you started in, in this case, and which contains the folder named Desktop), type the following and then press Return (or Enter):
FOLDERS THAT ARE DEEPLY BURIED
Finally, what if you want to change to a folder that’s easy to locate in the Finder, but you don’t want to type all the many folder names leading down, down, down to where it is buried? Easy peasy: Just find the folder the normal way, using the Mac Finder — then click it once (don’t open it) and then press Command-c to copy the “path.”
Return to your Terminal window. Type cd and one space, and then paste (Command-v). Press Return, and bingo! You’re in that directory, no matter how deep down it is.
Each of these steps is illustrated in one of the images above (CLICK for a slideshow of larger images).