I created a Debian package, I want to install the files to the directory /home/user/myapp instead of /usr/bin

but after install the deb, the owner of /home/user/myapp is root

I hope after install the deb, the owner should be user, so I add postinst to do the post-work:

chown -R user /home/user/myapp

but I always got an error "chown: ... Operation not permitted"

any idea?

  • This belongs on Superuser, but I've answered anyway.
    – detly
    May 13, 2011 at 1:32

2 Answers 2


The whole point of a Debian package is to install system-wide software. Think about it: if multiple users install this package to their respective /home/user/myapp area, what should show up in your package manager?

If you want to install to your home directory, use the original source (eg. tarball) distribution.

  • @camino - most tarball installation scripts allow you to set things like "PREFIX" and "LIB"... you should ask the developers of whatever it is you're trying to install for help with user-area installation.
    – detly
    May 13, 2011 at 2:28

you need to make a routine in the package's postinstall that copies the contents of what you need to put on the user's home

Something like this:

# For every user in /home/ ...
for HOME_U in /home/*?; do

# Obtain the username
USER=$( basename ${HOME_U} )

# In case the user is active (exists in /etc/shadow) ...
if [ $( grep -c "${USER}:.*:.*:.*:.*:.*:::" /etc/shadow ) == 1 ] \
&& [ $( grep -c "${USER}:.*:.*:.*:.*:.*:/bin/.*sh" /etc/passwd ) == 1 ] \
&& [ -d ${HOME_U}/.config ] \
&& [ -d ${HOME_U} ]; then

# Making sure .config/your-package/ exists
mkdir -p /home/${USER}/.config/your-package/

# with appropiate permissions
chown ${USER}:${USER} /home/${USER}/.config/your-package/

# copy what we need
cp /etc/skel/.config/your-package/x.conf /home/${USER}/.config/your-package/
cp /etc/skel/.config/your-package/y.conf /home/${USER}/.config/your-package/
cp ... /home/${USER}/.config/your-package/

# with appropiate permissions
chown ${USER}:${USER} /home/${USER}/.config/your-package/x.conf
chown ${USER}:${USER} /home/${USER}/.config/your-package/y.conf


Hope you can use it.

  • 1
    The list of subdirectories in /home is NOT a list of users (even if it often looks like it). On most Linux systems, you could check UID_MIN and UID_MAX in /etc/login.defs, and then extract the info from the /etc/passwd lines where the UIDs are in the range. If you have LDAP, you need to parse the output of the getent passwd command instead. If the system uses NIS, I think you need yet something else.
    – mivk
    Nov 3, 2012 at 15:49

You must log in to answer this question.

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