I'm writing a program, and would like it to store a log file. Problem is, the program really shouldn't be ran as root.

So if I wanted to uphold to the traditions of where files are placed, where could I keep the log file if not in /var/log that a normal user would have permissions to?

Edit: I'm using Arch linux.

2 Answers 2


Since the operating system you are using is missing, a more generic approach could be: Create a directory with the name of your app(say, foo) inside /var/log

# mkdir /var/log/foo

Most of all unix-like OSs will allow you to navigate through var_log folders, but not to view the logfiles contents(as expected).

Give the ownership to the user that you are using to run your program, and permission to this user(only) to see/write those logfiles

# chown userfoo /var/log/foo
# chmod 600 /var/log/foo

You could play with groups too, giving read access to operators for example(and of course, a different permission set of chmod, like 640.

Done. This should be generic enough to any Unix like system, and maybe, a better approach than adding a user to administrative groups.

  • 1
    My bad, I should add that I'm using arch linux. I'm not sure I would want method since this will be going into a package. I was really more hoping that there might a folder inside of a users home directory that could be used to hold log files. Commented Dec 12, 2013 at 23:37
  • 1
    Ok, so help me to understand. This program will be run by "normal users"(like password, cd, yes...), or a daemon or some server software that needs to run as a normal user or administrative user to reduce the risks of your system being compromised? I don't se a more appropriated place to put user logs, since even the FHS does not talk about it - refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html. Maybe: /home/user/.your_app/logs like almost all applications do on users home folders to handle config files and stuff ;)
    – user34720
    Commented Dec 12, 2013 at 23:47

If the program is not a daemon, the XDG Base Directory Specification specifies that:

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

  • actions history (logs, history, recently used files, …) […]


If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.

  • Went through so many questions and answers before finding your answer, @tastytea. Exactly what I needed to be pointed towards, thanks! Commented Oct 13, 2023 at 19:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .