Raspberry Pi For Dummies
Book image
Explore Book Buy On Amazon
You can create directories on your Raspberry Pi. As you may know from other computers you’ve used, it’s a lot easier to manage the files on your computer if they’re organized into directories (or folders). You can easily create a directory in your home directory using the command mkdir:

<strong>mkdir work</strong>

To save time, use one command to create several directories, like this:

pi@raspberrypi ~ $ <strong>mkdir work college games</strong>

pi@raspberrypi ~ $ <strong>ls</strong>

Downloads python_games work college Music Desktop Pictures Documents games Public Templates Videos

You might see additional files here, especially if you followed the earlier examples to make some text files, but the important thing is that one command made three new directories for you.

The mkdir command’s ability to make several directories at the same time isn’t unusual: Many other commands can also take several arguments and process them in order. You can see the listing of two different directories like this, for example:

<strong>ls ~ /boot</strong>

The mkdir command doesn’t give you a lot of insight into what it’s doing by default, but you can add the -v option (short for verbose), which gives you a running commentary as each directory is created. You can see what that looks like in the next code snippet.

If you want to make some directories with subdirectories inside them, it would be a nuisance to have to create a directory, go inside it, create another directory, go inside that, and so on. Instead, use the -p option, like this:

pi@raspberrypi ~ $ <strong>mkdir –vp work/writing/books</strong>

mkdir : created directory 'work'

mkdir : created directory 'work/writing'

mkdir : created directory 'work/writing/books'

The command keeps you informed of any changes it makes, but if the work directory already exists, you won’t see the first line of output shown here.

About This Article

This article is from the book:

About the book authors:

Sean McManus is an expert technology and business author. His previous books include Mission Python, Coder Academy, and Cool Scratch Projects in Easy Steps.

Mike Cook is a former professor in physics at Manchester Metropolitan University. His other books include Raspberry Pi Projects and Raspberry Pi Projects For Dummies.

Sean McManus is an expert technology and business author. His previous books include Mission Python, Coder Academy, and Cool Scratch Projects in Easy Steps.

Mike Cook is a former professor in physics at Manchester Metropolitan University. His other books include Raspberry Pi Projects and Raspberry Pi Projects For Dummies.

This article can be found in the category: