简体   繁体   中英

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.

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....

  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).

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

^.^

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM