Creating Directories

Creating Directories

As with any system, a Linux system can quickly become a computing home. Everyone has a unique method for organizing the items in their life, even if it’s a complete lack of organization! In order for your Linux system to truly become a computing home, you’ll probably need to find a way to organize it in a structure that makes sense to you.

Creating directories is a crucial element, for me, to computer housekeeping. I try to create directories that make sense to me, both in where they reside and in the names I choose to give them. The mkdir command is what makes that organization possible. As long as you’re the owner of the high-level directory into which you’d like to create a subdirectory, mkdir will fulfill your every directory-creation wish.

    mkdir /home/tony/downloads/slackware

This is how I created the directory into which I downloaded the Slackware .isos you’ll read about next week. In fact, had I been in the /home/tony/downloads directory when I executed the mkdir command, the entire command would have looked like this:

    mkdir /downloads

That’s because Linux makes possible both relative and absolute references to directories and subdirectories. The discussion of relative and absolute references is a bit long. We’ll cover that later.

For now, know that mkdir carries a small but useful toolkit of options. Using those options is, in the end, what makes the use of mkdir a GnomeTWEAK. Here’s a list of the options for mkdir:

-msets the mode or permissions on the directory being created
-pcreate intervening parent directories if none exist
–verboseprint a message for each directory created
–helpprint a help message and exit
–versionprint the mkdir version number and exit

One particular option amongst these can be very useful. The -p options helps to avoid a series of commands that might look like this:

    mkdir downloads; cd downloads
    mkdir slackware; cd slackware
    mkdir isos; cd ../..

Instead, using the -p option, these six steps can be accomplished with:

    mkdir -p downloads/slackware/isos

… provided you’re in the /home/tony directory.

Now that’s efficient housekeeping.