Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where and How to store program information in Linux

Tags:

java

linux

I'm new to Linux and I've only ever messed around with it but now I want to allow my Java program to run on Linux...

I've had a quick look around on the internet, and I've found a list of directories and their discriptions. /usr/lib seems to be the best place for me to store program information, but I've just looked in there on my VirtualBox VM and it appears that I can't write there, even with root permissions. So if anyone can point me in the right direction that would be brilliant.

I have also noticed that Linux has it's own "Software Center", and I'm afraid that I may be going to wrong way about all this, so may be some sort of introduction to programming on Linux would help if anybody would be kind enough to provide one!

Thanks In Advance

PS My Virtual Machine is an Ubuntu distribution

like image 373
Andy Avatar asked Oct 08 '11 09:10

Andy


1 Answers

The file system structure of not only Linux, but any POSIX-compatible system (including BSD, Solaris, and to a lesser degree even Mac OS X) are standardized in the FHS. Specifically for Ubuntu, have a look at the Debian policy for Java and the packaging guide of the ubuntu-java team.

If your program is run interactively, it should store information(like databases and settings) in $HOME/.your-program-name (or $HOME/.config/your-program-name). If your program is a system service, it should store its information in /var/lib. You can also install a default configuration into /etc/your-program-name.

The binaries are a whole different deal, and a prefix to their location should be configurable. To get the full advantage of the Software Center and its dependency/update mechanisms, package your software. These binaries(and the libraries that go with them) will go into to /usr/ tree if packaged, and /usr/local/ if manually installed. No matter the prefix, binaries go into bin (i.e. /usr/bin), libraries into lib32/lib64, and other data into share.

If you don't want to package your program and don't want to follow the structure imposed by FHS (but you really should do that), the alternative is putting code and other objects into /opt/your-program-name. Note that the (mutable) data your program generates and operates on should still go into $HOME/.your-program-name(interactive) or /var/lib/your-program-name(service).

like image 196
phihag Avatar answered Sep 22 '22 19:09

phihag