Run apt-get without sudo
This might be a very naive question, but I wanted to know how I could give multiple users access to a single computer without making them root users. How would I give them limitted sudo access such that they could still issue commands like
sudo apt-get install epstopdf
I imagine this could be an incredibly stupid question as once root user access is given, they could do whatever they want. Therefore, is there any way around this? I am open to suggestions
Solution 1:
Open a terminal and type sudo visudo
. At the end of the file (really the last line in it) type %yourusername% ALL=NOPASSWD: /usr/bin/apt-get install
where %yourusername% is replaced by your username.
After that you wont be prompted for a password to use sudo apt-get install
anymore but please understand this is a very risky solution, there is a reason why you need to type a password for some commands, the use of these commands without password can leave your system open for some dangers. Use with caution.
Solution 2:
sudo
is exactly made for that. By editing the sudoers
file you can give users specific privileges. See the manual page of sudoers(5)
for details.
Solution 3:
From my answer to similar question on the Linux stachkexchange: link
For me the option with visodo
required additional steps:
- Add yourself to the sudousers:
Login as root via su -
, open sudo editor by visudo
and add next lines:
%yourusername% ALL=NOPASSWD: /usr/bin/apt-get install
%yourusername% ALL=NOPASSWD: /var/lib/dpkg/lock-frontend
-
Exit session(root and yours) typing
exit
<Enter>exit
<\Enter> -
Reopen it and type:
sudo chown %yourusername%: /var/lib/dpkg/lock-frontend chmod u+w /var/lib/dpkg/lock-frontend sudo chown %yourusername%: /var/lib/dpkg/lock chmod u+w /var/lib/dpkg/lock sudo chown %yourusername%: /var/cache/apt/archives/lock chmod u+w /var/cache/apt/archives/lock sudo chown %yourusername%: /var/lib/apt/lists/lock chmod u+w /var/lib/apt/lists/lock
PS: I also added the visudo file lines to allow myself to update repos list:
%yourusername% ALL=NOPASSWD: /usr/bin/apt-get update