Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to refactor the files and directories on my system. However I am not sure what is best practice.

After reading this question and it's answers I assume the most important part is to be consistent. However, this is where I'm stuck. E.g in root, there are directories suck as /bin and /usr, which all use lower-case letters. But in my user's directory /home/foobar/, there are already a bunch of directories such as ~/Pictures, ~/Documents and ~/Music (which are capitalized)!

Maybe this is just because I use Ubuntu, but what is considered best practice?

share|improve this question
1  
You do on your system what you want. If you want to store your porn collection in /boot nobody restricts that. –  Anton Barkovsky Jun 18 '11 at 15:18
    
FYI, when you start a path with /, as you have with /Pictures, that means that the path starts at the root level (i.e. an absolute path). If a path starts with ~, then its starting point is a home directory (your home directory if followed by either a / or nothing at all, someone else's if followed by their username). So you should instead write ~/Pictures to mean the Pictures directory in your home directory, or you should just write Pictures. If you want to show it's a directory, follow it with a /, as in Pictures/. –  Mike DeSimone Jun 18 '11 at 23:52
add comment

3 Answers

up vote 2 down vote accepted

There are a couple confliting parts here. The comment about being able to do whatever you want is true, but it will also make much more work for you in the long run.

If you have any idea about re-arranging anything outside of your home directory, stop! That's way more complicated than you think and you should leave it alone. If you don't like it you should change to a different distro or even operating system. If none suit you you would need to roll your own, but you can't just move system directories around without getting burned. See this question for some idea what would happen if you wanted to go that way.

So we're down to your home directory.

First of all, remember as you think up a structure that permissions are hierarchical. In order for somebody to have permissions on a given folder, they need to have at least execute permissions on every folder ABOVE that folder. If you have anything in your home directory that you share, it needs to be near the top (e.g. ~/Music), anything you want to restrict should be in subfolders with limited permissions (e.g. ~/.ssh/id_rsa).

Secondly, there are no rules or even best practices per-se but there are conventions. Lots of software use default values that you may or may not be able to change, but even when you can change them it's troublesome to have to do constantly. Gnome, and particularly Ubuntu stuff, likes folders with nice names starting with capitals. If you try moving "Downloads" to "downloads" you'll find the original probably gets created again before too long by some program with an assumed default. You'll have to decide how much swimming against the tide you want to do in these cases.

share|improve this answer
    
And I thought that Linux is as configurable as you want... –  daGrevis Jul 8 '11 at 13:53
    
Do you still need execute permissions on every folder above a directory if you access that directory from a softlink? In addition, why not create a softlink from 'Downloads' to 'downloads' as a response to your last point on some distro behaviours. –  deed02392 Feb 17 '12 at 11:53
add comment

The organization of the system files is up to the operating system maker. Linux distributions by and large follow the Linux filesystem hierarchy standard (FHS). As a user or system administrator, the FHS (and your distribution's additional conventions) may occasionally be useful if you need to locate a file or if you want to understand a file's role given its location, but it doesn't constrain you, you can still do what you want (at your own risk).

Inside your home directory, you can do pretty much what you want, with one exception: dot files, i.e. files whose name begins with a . in your home directory, are configuration or state files, and applications require them to have a particular name. For example, bash will always read ~/.bashrc when it starts (except when it doesn't but that's another story), so you'd better not use that name for another purpose.

The Freedesktop project, which is mostly a common ground for Gnome and KDE, has defined a few standard directories in $HOME: Documents, Music, etc. Some applications will create these directories if they don't exist, and use them as default locations. You can change their names, and in fact they are supposed to be translated to your language. The software component that manages these directories is xdg-users-dirs. You can change the directory names by setting different values in ~/.config/user-dirs.dirs.

share|improve this answer
add comment

On GNU/Linux the relevant standard is the Filesystem Hierarchy Standard (FHS). However that does not cover directory naming conventions within a users home directory.

share|improve this answer
    
Quibble: If you do PREFIX=$HOME ./configure; make; make install to build something without root privilege you'll get bin, lib, include, share, man etc under $HOME, so if there is any chance that you'll every want to do that you might as well use the traditional names in the first place. –  dmckee Jun 20 '11 at 3:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.