I cannot tell you how many times I get asked by collaborators, colleagues, friends and family, “Why do you never put spaces in file and folder names?” The answer to that question is generally met with either blank stares or cries of “What?” Way back when, in the mid-1990s, when I was still using Windows, spaces in file and folder names were commonplace for me.

Then I made the switch to Linux in 1997, and everything changed on every level. That included the names I gave files and folders. Back then, creating a folder name with a space was in very bad form and could cause you all sorts of trouble navigating the directory structure.

SEE: Linux service control commands (TechRepublic Premium)

For instance, take a directory named TEST DIRECTORY. If you issued the command mkdir TEST DIRECTORY, you wouldn’t be creating a directory named “TEST DIRECTORY” but two directories, TEST and DIRECTORY. To create “TEST DIRECTORY,” you’d have to issue the mkdir command with the name in double-quotes, as in mkdir “TEST DIRECTOR.” To change into that directory, you’d issue the command:


However, if you created the directory TEST_DIRECTORY, you wouldn’t have to go through the extra steps. Most Linux commands see every separate entry as an option, so mkdir TEST DIRECTORY would be taken as two commands—mkdir TEST and mkdir DIRECTORY.

This issue isn’t nearly as problematic in a GUI. In fact, when working with a GUI, you can create files and directories with multiple spaces. If you’ll also be working from within the command line, I suggest you don’t because you won’t want to have to deal with the headache of accidentally deleting both the TEST and the TEST DIRECTORY directories.

This issue can get a bit convoluted, so just remember to avoid using spaces in your Linux file and folder names and you’ll be okay. Get friendly with either the dash or the underscore and everything will be fine.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Image: Jack Wallen