# How to run pkg_xxx



## a129878 (Apr 14, 2011)

Do the pkg_xxx applications have to be run under 'root'? I tried *pkg_add mod_perl2* under my user name and got all sorts of complaints, but under root all seems to have worked. What if a user is not able to get to 'root', how does one get to try a port? Is there anything in the distribution to give an indication?


----------



## wblock@ (Apr 14, 2011)

In general, yes.  Things that make changes to the system require root privileges to prevent unauthorized changes.


----------



## Oxyd (Apr 14, 2011)

You could also use sudo to use root's privileges for pkg_* stuff. You may set up /etc/sudoers to only allow /usr/sbin/pkg_* for only certain users, if you don't like the idea of giving full root access to those users.

Of course, if you're not an admin of the system and the admin doesn't want you to be able to run pkg_* tools, then you're out of luck.


----------



## sk8harddiefast (Apr 15, 2011)

> You could also use sudo to use root's privileges


Or 
	
	



```
su root
```


----------



## Beastie (Apr 15, 2011)

Check pkg_add(1) for the *-C, --chroot chrootdir* option.
I've never used it so I don't know for sure if it works.



			
				sk8harddiefast said:
			
		

> Or
> 
> 
> 
> ...


Or just su?


----------



## mamalos (Apr 16, 2011)

You can create a special user and/or group that will be able to install applications using *pkg_add* and/or ports. In order to do that you'll have to give special permissions to the folders that ports are built (or change the ports' build directory, configure directory, etc. see man ports). Then you should change the permissions on the folders you want ports to be installed in (/usr/local/bin, /usr/local/etc, /usr/local/lib, etc) so that your special user and/or group will be able to have write privileges in there. Your special user and/or group should be able to update *ldconfig* too. I must be missing a few steps more steps, and once these are also completed you'll be able to have your requested functionality.

Why don't you use *su -* or *sudo* instead, as the rest of the guys suggest? It just takes a few clicks .


----------

