I am packaging one of my projects on Debian. The project expects a directory to be created at XDG_DATA_HOME or ~/.local/share/ where the data files will be kept. Now I am trying to create and feed the initial data using postinst script shipped with the .deb package. The problem is since packages are installed as root, the directory is getting created as root and the user who is installing it won't have write permission on it.

My question is how can I create the directory so that the user who is installing the package will have write permission on it and all subdirectories?


What you are asking dose not make sense. The user doing the installing is always root. If you want new users to automatically have this file in their home directory, then you add it to /etc/skel. If an existing user does not have it, then the program needs to be capable of dealing with that, possibly by automatically creating it, possibly by copying defaults from /etc/skel, or perhaps /usr/share.

| improve this answer | |

To my knowledge the postinst is just a shell script so you can do what ever you want (with in reason) inside this script. Perhaps doing a chown or chmod to the directory afterwards would set the permissions the way you want.

#Creating the user if it does not exist
if ! getent passwd $the_user > /dev/null; then
adduser $the_user

chown -R $the_user /path/to/some/file
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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