Linux 101: Why File and Directory Names Are Running Out of Spaces



Jack Wallen explains why spaces in file and folder names aren’t always the best option in Linux.

I can’t tell you how many times coworkers, coworkers, friends and family ask me, “Why do you never put spaces in file and folder names?” The answer to this question is usually met with either blank stares or shouts of “What?” A long time ago, in the mid-90s, when I was still using Windows, spaces in file and folder names were commonplace for me.

Then I switched to Linux in 1997, and everything changed on every level. This included the names I gave to the files and folders. Back then, creating a folder name with a space was very poor quality and could cause you all kinds of trouble navigating the directory structure.

SEE: Linux service control commands (TechRepublic Premium)

For example, take a directory named TEST DIRECTORY. If you started the command Mkdir TEST DIRECTORY, you would not create a directory named “TEST DIRECTORY” but two directories, TEST and DIRECTORY. To create “TEST DIRECTORY”, you must issue the mkdir command with the name in quotes, as in mkdir “TEST DIRECTOR.” To access this directory, run the command:


However, if you created the TEST_DIRECTORY directory, you would not have to follow the additional steps. Most Linux commands see each separate entry as an option, so Mkdir TEST DIRECTORY would be taken as two orders—Mkdir TEST and DIRECTORY mkdir.

This problem is not as problematic in a GUI. In fact, when working with a GUI, you can create files and directories with multiple spaces. If you are also working from the command line, I suggest you don’t do this as you won’t want to have to worry about accidentally deleting the TEST and TEST DIRECTORY directories.

This problem can get a bit complicated, so remember to avoid using spaces in your Linux file and folder names and you will be fine. Be friendly with the hyphen or underscore and you’ll be fine.

Subscribe to TechRepublic How to Make Technology Work on YouTube for all the latest technical advice for professionals at Jack Wallen’s business.

Also look

linux penguin

Image: Jack Wallen

Source link


Comments are closed.