Questions tagged [sudo]

sudo is a tool which allows users to run commands as another user (usually the root user)

sudo allows users to run commands as another user. It is typically used to allow trusted users to run commands as root, without giving them root access, or to allow a user to run commands as another user. Both of these uses must be allowed by the root user.

886 questions
13
votes
3 answers

Is "sudo su -" considered a bad practice?

Background I know the difference between su -, sudo su -, and sudo : su - - switches user to root, requires the root password sudo su - - switches user to root, requires only the current user's password sudo - grants root access…
Kingand
  • 253
  • 1
  • 2
  • 6
13
votes
3 answers

Which method to use for granting sudo

What is the difference between adding a user to /etc/sudoers and usermod -a -G sudo? Which method should be used for granting sudo?
Sonique
  • 241
  • 1
  • 9
13
votes
4 answers

Starting a script as another user

I've created a script in /etc/init.d/ which has to run several other scripts from other (non-root privileged) users from their home directories, as if they started them. I launch these scripts with: sudo -b -u
Ivan Kovacevic
  • 1,801
  • 3
  • 15
  • 19
13
votes
2 answers

Using FreeIPA for centralized sudo - how to specify ALL commands?

I'm having a hard time wrapping my head around FreeIPA's model. The FreeIPA manual states: FreeIPA adds an extra control measure with sudo command groups, which allow a group of commands to be defined and then applied to the sudo configuration as…
HTTP500
  • 4,833
  • 4
  • 23
  • 31
13
votes
2 answers

Allow complex sudo command on Debian Linux

I need to allow a specific command on a Debian Linux box for a single user. I've tried this in the /etc/sudoers file: # User privilege specification zabbix ALL=NOPASSWD: /usr/bin/apt-get --print-uris -qq -y upgrade 2>/dev/null |awk '{print $2}' |…
Daniel
  • 3,047
  • 5
  • 22
  • 27
13
votes
1 answer

Accessing SSH_AUTH_SOCK from another non-root user

The Scenario: I am running ssh-agent on my local PC, and all my servers/clients are setup to forward SSH agent auth. I can hop between all my machines using the ssh-agent on my local PC. That works. I need to be able to SSH to a machine as myself…
Danny F
  • 498
  • 3
  • 10
13
votes
2 answers

What is the difference between "sudo -i" and "sudo bash -l"

There is a recent question regarding multiple sysadmins working as root, and sudo bash -l was referenced. I searched for this on google and SE, but I don't understand the difference between sudo bash -l and sudo -i. From the man pages for bash and…
Rqomey
  • 1,055
  • 9
  • 25
13
votes
4 answers

Test whether a user has sudo privileges without requiring user input

I have a local shell script that performs a number of tests on a remote host, before delivering the payload; one of these tests being whether the user has sudo privileges, checked simply with sudo -v however this requires the user to enter their…
DanH
  • 827
  • 2
  • 9
  • 26
13
votes
4 answers

Save file after forgetting to open as root / sudo vi

Possible Duplicate: vim re-edit as root I could have sworn I saw this question asked. But after looking though every search result for "vi" I'm stumped/lazy. I've opened a file, made an edit and now I realize it's read only and I've opened it as…
MathewC
  • 6,957
  • 9
  • 39
  • 53
13
votes
5 answers

Ubuntu: borked my sudoers file, how can I fix it?

I was editing my /etc/sudoers file and saved it but it has a syntax error in there. Now I can't sudo vim /etc/sudoers because sudo thinks the sudoers file is not valid. How can I fix this?
fred basset
  • 665
  • 2
  • 7
  • 14
12
votes
5 answers

ubuntu: let a user run a script with root permissions

I have ubuntu 8.04 and I want to write a bash script that runs as root which every user can run. I myself can do sudo. How do I do that? CLARIFICATION: I don't want to do it with sudo, because then users will have to type their password. I just want…
flybywire
  • 597
  • 4
  • 9
  • 20
12
votes
1 answer

Chown in sudoers file : Safe or not?

Is it safe to add this command in sudoers file? mike ALL= NOPASSWD:/bin/chown -R www-data\:www-data /var/www and this is the only command that I want to run $mike@ubuntu: sudo chown -R www-data:www-data /var/www Thank you.
Mike
  • 135
  • 1
  • 1
  • 6
12
votes
2 answers

Allow User 'git' to run 'git pull' as 'www-data' via sudo

I would like to allow git to run 'git pull' as user 'www-data'. As far as i understand git ALL=(www-data) git pull in /etc/sudoers should make it. Sadly i get an Syntax error for this line and visudo Syntax highlight breaks right after the "-"…
Ben
  • 123
  • 1
  • 1
  • 4
12
votes
8 answers

using su inside of a shell script

I'm automating a deploy process and I want to be able to just call one .sh file on my machine, have it do my build and upload the .zip to the server and then do a bunch of stuff on the server. One of the things I need to do requires me to be root.…
cmcculloh
  • 989
  • 2
  • 9
  • 14
11
votes
4 answers

linux command found but not found when using sudo

I am trying to run a python3 install like this: pip3 install django I get the error: PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/pytz' I then try: sudo pip3 install django I get the error: sudo: pip3:…
petey
  • 572
  • 3
  • 9
  • 20