In the previous exercise, we used cd multiple times to go from the blog/ directory to the memory/ directory. You can reference the file system here.
To move across multiple directories with a single command, we can provide cd a relative path to the memory/ directory as an argument. From the blog/ directory use:
$ cd 2015/jan/memory
The relative path is a forward slash (/) separated list of all the directories leading to the goal directory. In the above example, we navigate directly to memory/ from blog/ using cd with the relative path 2015/jan/memory.
We can also move up multiple directories using the .. argument. To go from memory up 2 directories to 2015, we use `../..:
$ pwd
/home/ccuser/workspace/blog/2015/jan/memory
$ cd ../..
$ pwd
/home/ccuser/workspace/blog/2015
The relative path ../.. can be read: the directory above and the directory above that.
Lastly, we can move to an adjacent directory using .. and then a directory name. If we are in the 2015/ directory and we want to go into the 2014/ directory, we go up one directory then into the 2014/ directory:
$ ls
2014 2015 hardware.txt
$ cd 2015
$ pwd
/home/ccuser/workspace/blog/2015
$ cd ../2014
$ pwd
/home/ccuser/workspace/blog/2014
The relative path is the directory above 2015/ (which is blog/) and then the 2014/.
1.For this exercise, we want to start in the blog/2015/ directory. Check your location and navigate to this directory. Remember, you can always use cd with the absolute path, /home/ccuser/workspace/blog/2015/.
Once in the blog/2015/ directory, change the directory to the feb/ directory using a single command.
When in the feb/ directory, check the working directory.
Make sure to click the Check Work button once you’ve completed each checkpoint.
2. Now we’re in 2015/feb/, but what if we want to move to the adjacent directory 2015/jan/? (You can reference the filesystem for this lesson here.)
Using a single cd command, navigate from 2015/feb/ to 2015/jan/ and confirm your working directory.
3. Navigate back to /home/ccuser/workspace/blog using a single cd command and then use pwd to confirm your working directory.
Click the Check Work button when you are done.