0

Although I did some research on this subject, I couldn't reach the exact information I wanted. Actually, not exactly disclosed, everyone approached in a different way.

For the: Filesystem Hierarchy Standard

I should store my files at:

  • Temp files: /var/temp/app_name/* or /temp/app_name/*

  • Cache files: /var/cache/app_name/*

  • Config files: ~/.config/app_name/*

  • Log files: /var/log/app_name/*

  • Data files (database, etc.): ???

Q1: Is that the right approach for the recent systems?

For the XDG standart that explained here:

  • Temp files: ??? or /temp/app_name/*

  • Cache files: ~/.cache/app_name/*

  • Config files: ~/.config/app_name/*

  • Log files: ???

  • Data files (database, etc.): ???

I cant understand why we store a cache file in the ~/.cache. It doesn't make any sense to me because there was a built-in cache folder called /var/cache

In that case, I'm confused. Everywhere I investigate, there have been different approaches.

Q2: Where should we put the files (datas, logs, temps, configs, etc.) for a pure Linux distribution (which does not use $XDG) to create applications?

Q3: Some applications use the Linux structure, but some of use the XDG structure. How do they choose this? According to what situation? Do they use $XDG environment variables if we're using them?

According to the above situation, my env | grep -i "XDG" output:

XDG_VTNR=1
XDG_SESSION_ID=1
XDG_DATA_DIRS=/home/furkan/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0

P.S: I don't know the parts I'm showing with ???

closed as primarily opinion-based by JigglyNaga, Kiwy, schily, jimmij, Mr Shunz Dec 13 '18 at 14:40

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

2

Part of your confusion may be the distinction between user applications and system applications.

So, for example, apache isn't run as an end user ("Harry" normally doesn't run Apache; it's run from a system startup script - systemd or init or however). These sort of applications typically will follow the file system standard and store log files in /var/log, configuration files in /etc and so on.

Similarly, commands executed by the systems administrator as root designed to impact the whole machine (e.g. apt or yum) also follow the file system standard.

However, applications designed to be executed by the end user (e.g. a web browser and other desktop applications) follow the XDG standard. Here "Harry" has his own personal cache, which is different to "Julie"; they visit different web sites, so have cached different pages. Similarly, Harry may configure his desktop different to Julie, and so the configuration will be in the ~/.config area.

Some locations (eg /tmp) are designed to be shared by all users, so even desktop apps can use them... but even here a more modern /run/user/ structure is sometimes used.

  • So, in that case, i should follow the XDG standart. :) Because the end user will use the software. Thank you! – Dentrax Dec 13 '18 at 19:39

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