Solved pkg for all users

When I want to use pkg, I have to put "sudo" even though I just search some packages. I think this is uncomfortable. How can I use pkg without sudo?
 
Searching for packages should work without sudo. Eg pkg search elixir should work just fine.

As far as I understand it, pkg search queries the repository database in /var/db/pkg/repo-FreeBSD.sqlite. You might want to check the permissions on that file. In my case they are -rw-r--r-- 1 root wheel

Commands such as pkg install and pkg delete do require elevated privileges, and hence the usage of sudo, doas or su. If you grow tired of having to type in your password you can always configure sudo to not ask for it for these commands specifically! To do so add something like:
Code:
your_username ALL=(root) NOPASSWD: /usr/sbin/pkg install *, /usr/sbin/pkg delete *

to /usr/local/etc/sudoers by means of visudo. Though you might want to read up on the dangers of using wildcards in sudoers() first
 
Back
Top