1

Is it possible to change the default Unix/Linux directory structure? I mean by configuration and without need to change the kernel. Or if the kernel has to be edited, how hard is such task? Is the default directory structure (all these /usr, /bin, /etc directories) hard coded in the kernel?

What I need is to have one root (/) directory, where every user will be free to create it's own files/directories and one /Linux directory, where all OS files will exists (probably in the original structure) including all configuration files. There should be no "Home" directory at all and all configuration files should be the same for all users editable only by the system administrator.

closed as too broad by msw, Anthon, rahmu, terdon, jasonwryan Sep 18 '13 at 18:11

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    Your question does not make sense. The kernel does not need the mentioned structures. Filesystem is user-space. You are propably asking about the Linux-system - not the kernel. Please also improve your question by describing why you "need" that structure. – Nils Sep 18 '13 at 12:45
  • Why? If you are looking to create an "embedded system" look for that. Otherwise, you are looking at a world of fiddly bits which will take a long time to get right to little effect. – msw Sep 18 '13 at 12:45
  • 4
    in theory what you want is possible. in practice, it's way too much work. it would be weeks worth of work, at least, for an expert with advanced scripting and package compilation skills to automate rebuilding everything that expected the FHS. It would take a novice years, most of which time would be spent learning enough to become an expert. – cas Sep 18 '13 at 13:07
  • 2
    and that's only taking system utilities and the like into account that don't require user-specific config files in the user's home directory. most applications expect a user to have their own home directory, with their own config files (and even caches for apps like firefox). Add a few decades to the ETA to rewrite all apps to work with your non-unix system. or save yourself all that time and realise that learning to use and even like the FHS is a far better use of your time. – cas Sep 18 '13 at 13:23
  • 3
    When someone asks how to do something insane, such as saw off their own foot, asking them why they want to do such a thing is a good way to correct whatever misconception they have that is causing them to try and do such a silly thing, thus saving them from making a big mistake. – psusi Sep 18 '13 at 13:50
3

Yes, it is possible. But requires a lot of efforts to reach what you want.

For details you can check Gobo Linux project.

GoboLinux is a free and open source operating system whose most prominent feature is a reorganization of the traditional Linux file system. Rather than following the Filesystem Hierarchy Standard like most Unix-like systems, each program in a GoboLinux system has its own subdirectory tree, where all of its files (including settings specific for that program) may be found. Thus, a program "Foo" has all of its specific files and libraries in /Programs/Foo. According to the GoboLinux developers, this results in a cleaner system.

  • Note that they use symlinks to normal FHS locations in order to make that work. – goldilocks Sep 18 '13 at 13:09
  • @goldilocks - according to the wikipedia description, they emulate the standard Unix structure using symlinks. Anyway, it is a proof that such things are possible. BTW, Gobo looks very interesting project, although not exactly what I need. – johnfound Sep 18 '13 at 14:05
  • @johnfound : Yes, like I said you can do anything you want with symlinks -- eg. WRT your goal, you could move everything into a /Linux directory but you would then have to place symlinks into it from the toplevel. If you can live with that it is probably workable. I am not sure how the symlinking will affect the loading of init or grub, however. – goldilocks Sep 18 '13 at 14:12
  • @goldilocks init should deal with symlinks fine, since by that point you're running the kernel. GRUB, well, I'm pretty sure quite a few distributions put a symlink /vmlinuz to the current kernel image, though I'm not sure how many actually use it through the boot loader. – a CVn Sep 18 '13 at 15:05
  • "each application lives in its own directory tree" falls apart pretty quickly on a customary *nix when you consider system-wide configuration files. How about /etc/passwd, /etc/nsswitch.conf or /etc/resolv.conf, just to name a few? Let alone /bin/mount. – a CVn Sep 18 '13 at 15:06
2

Is the default directory structure (all these /usr, /bin, /etc directories) hard coded in the kernel?

No, most of that does not mean much to the kernel. It does, however, populate file systems mounted in standardized locations like /proc and /dev.

Is it possible to change the default Unix/Linux directory structure?

Absolutely not. The reason there is a standard for the root file system is because these directories have a defined purpose, and they are identified by path. It does not really make much sense to say, "Oh well, I'd prefer if my /etc directory where called /masterconf." If you want to access what everyone and everything else considers /etc as /masterconf, you're welcome to add a symlink ln -s /etc /masterconf, but leave /etc as pretty much everyone and everything else will be looking for that.

By analogy, someone could say, "I'd like to rename all the standard utilities -- mkdir, ls, cd, etc. -- so that they only exist by the names I've given them." Again, you can symlink them, but to create a standard which allows the system to configure names for standard utilities in place of the normal ones would be:

  1. Much more complicated.
  2. Almost certainly add overhead as installed utilities would have to constantly go through some kind of look-up to sort out your novel naming scheme.
  3. Completely pointless for 99.9999%+ of users.

Points 1 and 2 are significant drawbacks that cannot be justified in light of 3, which is why there is no such system. Likewise WRT renaming parts of the standard filesystem.

What I need is to have...

Again, you can do whatever you want with symbolic or hardlinks (see man ln), and then you can use those if you prefer them. But do not screw with the filesystem standard, it is not optional.

  • 2
    "you can do whatever you want with symbolic or hardlinks..." or bind/rbind mounts. – a CVn Sep 18 '13 at 15:02
1

In general the directory structure is not imposed by the Linux Kernel, it is imposed by File System Standards such as this one: Filesystem Hierarchy Standard. The Wikipedia article by the same name does a decent job of explaining it too.

To your question about moving/changing it. I would say this is highly discouraged, though possible, in the same way that on a Windows system they have standard locations such as:

  • C:\Windows
  • C:\Users and Settings
  • C:\Program Files
  • etc.

There is inherent value in making the systems look similar both from a packaging standpoint for software developers and users of said systems.

1

Is the default directory structure (all these /usr, /bin, /etc directories) hard coded in the kernel?

The other answers haven't covered this yet: yes, the paths are in fact hard coded - not in the kernel, but in the executables themselves. It is only possible to change these hard coded paths by recompiling the executables, which is usually accomplished with the --prefix argument to configure. The default for prefix for manually compiled executables is usually /usr/local:

./configure --prefix=/usr/local

while executables that are intended to be distributed with some package manager usually use the prefix /usr:

./configure --prefix=/usr

There are several additional arguments that you can use for more fine-grained control, as documented here: http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Installation-Names.html#Installation-Names

1

Many of distos of according to circumstances changed directory structures, even their names,Microtic is a appliance according to GNU/Linux But its kernel just Linux.

If you want to do it , you should do the following steps:

  1. change code of kernel
  2. change code of your boot process or yourself write one. such as upstart
  3. change or implement directory of runlevels or if you using UNIX according to rc files,chnage them.
  4. Leave package management or each software use directory. It's very important. You don't forget it.
  5. finally change directory structure.
  • Please don't abuse backticks like this. And perhaps except for /sbin/init (the default path to which is compiled into the kernel) what does the kernel have to do with whether a certain binary is in /bin, /sbin, /usr/bin or /useless/stuff? – a CVn Sep 18 '13 at 15:07
  • i named chenage kernel,Also i named init in number 2. another dir named in number 4. please reas agian. – PersianGulf Sep 19 '13 at 2:04

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