Changing and Creating Directories

Another handy command is cd, for change directory. This lets you move around the file system, from directory to directory. Say you're in a directory that has another directory in it, named mydirectory2. Switching to it is easy:

cd mydirectory2

But how do you get out of this directory once you're in it? Try the following command: cd ..

The .. refers to the "parent" directory, which is the one containing the directory you're currently browsing. Using two dots to indicate this may seem odd, but it's just the way that Ubuntu (and Unix before it) does things. It's one of the many conventions that Unix relies on and that you'll pick up as you go along.

You can create directories with the mkdir command:

mkdir mydirectory

What if you want to create a new directory and, at the same time, create a new directory to contain it? Simply use the -p command option. The following command will create a new folder called flowers and, at the same time, create a directory within flowers called daffodil:

mkdir -p flowers/daffodil

0 0

Post a comment