File and directory naming conventions

27,465

Solution 1

There are a couple conflicting 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.

Solution 2

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.

Solution 3

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:
27,465

Related videos on Youtube

Michal
Author by

Michal

http://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PG http://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PG http://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PG http://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PG http://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PGhttp://www.gravatar.com/avatar/3ddf5a285e2c5f109e0b72eb46309d5a?s=128&d=identicon&r=PG

Updated on September 18, 2022

Comments

  • Michal
    Michal almost 2 years

    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 its 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 such 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?

    • Anton Barkovsky
      Anton Barkovsky about 13 years
      You do on your system what you want. If you want to store your porn collection in /boot nobody restricts that.
    • test
      test about 13 years
      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/.
  • dmckee --- ex-moderator kitten
    dmckee --- ex-moderator kitten about 13 years
    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.
  • daGrevis
    daGrevis almost 13 years
    And I thought that Linux is as configurable as you want...
  • deed02392
    deed02392 over 12 years
    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.