# permissioin with deb

**URL:** https://discourse.cmake.org/t/permissioin-with-deb/7135
**Category:** Usage
**Tags:** os:linux
**Created:** [December 27, 2022, 8:47am UTC](https://discourse.cmake.org/t/permissioin-with-deb/7135 "2022-12-27T08:47:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [December 27, 2022, 8:47am UTC](https://discourse.cmake.org/t/permissioin-with-deb/7135/1 "2022-12-27T08:47:07Z")

</div>

I cpack a deb and install it with sudo dpkg -i xx.deb.  
The program will be install /opt/xxx  
But the /opt/xxx permission is root:root  
How can I solve it?

I add some command on the postinst script. But the user is root, not my default user sam

```auto
chown -R "$USER:$USER" "/opt/xxx"

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 28, 2022, 12:42pm UTC](https://discourse.cmake.org/t/permissioin-with-deb/7135/2 "2022-12-28T12:42:09Z")

</div>

`dpkg` always installs as `root`, so any install script is going to do that. I recommend looking at Debian packaging guidelines for how to do this properly and, if not supported, get switches to control that implemented in CPack.

---

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [December 29, 2022, 2:09am UTC](https://discourse.cmake.org/t/permissioin-with-deb/7135/3 "2022-12-29T02:09:39Z")

</div>

Do you have the method to get the user name when run the postinst on deb

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 29, 2022, 2:27am UTC](https://discourse.cmake.org/t/permissioin-with-deb/7135/4 "2022-12-29T02:27:27Z")

</div>

AFAIK, the postinst user is always `root`.
