Monday, May 5, 2014

The Folder Convention for CentOS

Each Linux distribution has their own system folder convention which will let user to figure out the purpose and program deployment layout quick. For example, MySQL's database file would be deployed to "/var/mysql" after you execute mysql_install_db command without specified the instance customized storage path but use default.
Speaking of CentOS, since it is derivative from RedHat distribution, I think it is quiet easy to grab its folder convention from application server development view. In daily operation, the "/var" folder would be the most important place for data storage. "/var" folder contains all the data file or "variable data of system persistent layer" and I believe this convention should be kept from server to server.
The second folder is "/opt" this folder is containing all the application server which is like a small OS inside Linux. I found some server package would assign /opt as their parent of server root folder and the script tool of application server would consider "/opt" is the shell path for scripting included. However, "/opt"s' purpose has most discrepancy from distribution to distribution. But I prefer use "/opt" as a small set of system package. Under "/opt" folder, each server package has its own "/usr", "/bin" and even "/sbin". It likes once you get into "/opt/server", you will get your own world with a dialect to communicate with another system. But sometimes it is pretty hard to configure the program under "/opt" for well function because there might be plenty binary dependency between "/opt" package and "/usr".
If you have built up a server with some auto run daemon or program, the "/etc" folder might be your most accessed folder per day. Surprisingly, "/etc" not only contains important configuration file from OS to Server Container (such as "/my.cnf"). "/etd/init.d" also has a lot of script for daemon and server start up. So you can tread "/etc" like a launch center to configure and regular the behavior of your whole application server from OS to user application at every beginning.
"/usr" is most crucial for all developer. The "/usr" folder would show the character of each Linux Dist. Even for the same distribution, the "/usr" folder might be much different from server edition to desktop edition. All the important compiler, productivity tool and open source software are scattered in the sub-folders of "/usr". If "/bin" and "sbin" are the shell that communicate to your machine, the "/usr" would give you the ability to enhance all your work to the machine. Most open source software are targeted to be deployed into "/usr" and scattered into "/usr/local", "/usr/bin", "/usr/include", "/usr/lib" and "/usr/etc". The famous Linux Package Manager and Deployment software are managing the "/usr" folder with their deliberated protocol and mechanism. And those deployment tools are really helpful for environment set up such as Java or X windows. However, some fresh new package might require you twist the file under "/usr" folder. That means the new package has not been adopted by those deployment tools and you have to dig into "/usr" folder's set up for running the new program normally. Neither, there is no easy way to unplug all those manually installed software from "/usr" with fresh clean up.

No comments:

Post a Comment