views:

114

answers:

5
+2  Q: 

Linux directories

I am writing installation script for my program, which is supposed to run on Linux/Unix OS. What is the default directory for the following files:

  1. Executable files (programs). Program should be executed by typing its name from the command line.
  2. Shared libraries.
  3. Third-party shared libraries (the program is not open source, so I need to redistribute third-party libraries).
  4. Read-only program configuration files for all users.
  5. Configuration data available for read/write access for all users.
+3  A: 

Executable (Binary):

  • /bin/
  • /usr/bin/
  • /home/~user/bin/

Shared:

  • /usr/share/

Other:

  • /etc/

I'm not sure it would be wise to be writing an install script if you don't know the file structure of a *nix OS. Besides which, each distribution of *nix is sligthly different when it comes to where the data is stored.

I suggest you read this: http://www.comptechdoc.org/os/linux/commands/linux_crfilest.html

^.^

Neurofluxation
NO! /usr/share is for files than can be shared by multiple architectures (i686, amd64, ppc, armel ...) such as images, or documentation. It is not for shared libraries that should go as 2).
Didier Trosset
+1 for the link but you should mention that user programs must not go into /bin
Aaron Digulla
Apologies all round, first answer of the morning - please forgive me :'( - Cheers for the +1 though!
Neurofluxation
Neurofluxation, thank you for useful link. /etc is read-only on my Ubuntu computer, what about read/write access for all users?
Alex Farber
+3  A: 

The listing varies depending on the Linux filesystem.

1) /bin, /usr/bin, /usr/local/bin

2/3) /lib, /usr/lib, /usr/local/lib

3. /usr/share/lib

4) /etc is a read-only spot for configuration data.

5) /usr/local/etc or usually in the /home directory under the dot directory name, if the profile allows the bin directory to be located under the /home/user_id/bin where 'user_id' is the relevant login id.. for an example for user 'jdoe', his configuration could be written to /home/jdoe/.configs or ~/.configs

Do not rely on this, for the most part the LSB filesystem dictates that there shall be at minimum: /bin, /etc, /usr, /lib, /home

For instance, the /usr could be on a different partition, likewise the same for /home

Edit: Thanks to dtrosset for pointing out my blooper....

tommieb75
NO! /usr/share is for files than can be shared by multiple architectures (i686, amd64, ppc, armel ...) such as images, or documentation. It is not for shared libraries that should go as 2).
Didier Trosset
/etc is read-only on my Ubuntu computer, what directory is available for read/write access for all users, like Documents and Settings\All Users in Win XP?
Alex Farber
@Alex: The other spot can be /usr/local/etc
tommieb75
/usr/local/etc is also read-only.
Alex Farber
@Alex: In general it is considered a bad idea if one user can arbitrarily affect how a program runs for another user (special cases like the high score table in games are usually handled with a setgid executable). If you *really* need this, you can always create (at install-time) an `/etc/<appname>` directory for your application, and a `/etc/<appname>/all-users` directory or config file that is world-writeable. It still seems like a bad idea though (on XP the "All Users" folder is only writeable by Administrators and Power Users by default).
caf
+3  A: 

Check out the Filesystem Hierarchy Standard.

Dave Paroulek
+1  A: 

The easiest way is to make an .rpm of your application and then use for example alien to make an .deb out of it. Last I made a deb, it was really, really simple. The packaging also enables you to have a sorts-of auto-update if you want to enable it and you will not need to think a lot about uninstallation procedures.

Pasi Savolainen
+3  A: 
  1. $PREFIX/bin
  2. $PREFIX/lib
  3. $PREFIX/lib
  4. /etc
  5. $HOME/.config

Where $HOME is the home directory of the user running the application, determined at runtime. $PREFIX depends on the method of distribution:

  • If distributed as source, $PREFIX should be configurable but default to /usr/local;
  • If distributed as a binary tarball, $PREFIX should usually be /usr/local (but /opt is also common);
  • If distributed as a distribution package (eg RPM or DPKG), $PREFIX should be /usr.

Documentation and other architecture-independent files should go in $PREFIX/share/doc; program-generated files shared between instances should go in /var/run (things like lockfiles, pidfiles and sockets) or /var/lib (things like shared binary databases).

caf
Right. And apropos of the OPs comments, if you don't have root privileges you install in $HOME and update your various path variable to reflect that.
dmckee