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
22
votes
2 answers

How to grant sudo rights only to specific script files?

I would like a user to have sudo rights (without password check) to a couple of shell scripts under a specific directory (in my case, /usr/local/tomcat7/bin), and to nowhere else. What's the simplest way to accomplish this? Something like this in…
Jonik
  • 2,961
  • 4
  • 38
  • 48
22
votes
8 answers

Linux - use "su -" but keep the current directory

When I do su - to get to root, my current directory is set to root's home. Is there anyway to keep the current directory that I was in, much like sudo -s. Or is the answer to use sudo?
Amandasaurus
  • 31,471
  • 65
  • 192
  • 253
22
votes
5 answers

Temporarily increasing sudo's timeout for the duration of an install script

I'm trying to write a script that will install a bunch of software and I'd like to not have to run everything as root, so I'd like to be able to prompt for a password and then go about the install, using sudo or su to get privileges when I need…
Arelius
  • 357
  • 2
  • 5
21
votes
5 answers

`sudo echo "bla" >> /etc/sysctl.conf` permission denied

Disclaimer: I'm pretty novice at sysadmin stuff. I'm trying to set up port forwarding in an AWS EC2 instance, this has to be done in the command-line because I don't want to go in and edit anything, it has to be automatic (it's part of a build…
bevacqua
  • 327
  • 1
  • 3
  • 11
20
votes
4 answers

How can I use sudo to check if a file exists?

I want to check if a file exists like so [ -f /path/to/file/ ] However I am running this command as a regular user and the file is owned by root. How can I use sudo to accomplish this. sudo [ -f /path/to/file/ ] does not work.
ckliborn
  • 2,778
  • 4
  • 25
  • 37
20
votes
9 answers

root login or sudo user for server administration?

I'm trying to understand the technical arguments/security implications between ssh'ing with root directly, or making an auxiliary sudo user in the context of maintaining a server. To clarify, we're talking about servers owned by a single admin. For…
alex.b.bg
  • 143
  • 1
  • 9
18
votes
2 answers

sudo rejects password that is correct

sudo (Which I have configured to ask for a password) is rejecting my password (as if I mis-typed it) I am absolutely not typing it incorrectly. I have changed the password temporarily to alphabetic characters only, and it looks fine in plaintext,…
Ryan
  • 351
  • 1
  • 2
  • 6
17
votes
1 answer

Sudo directive in /etc/sudoers.d doesn't work (but it's fine if it's in /etc/sudoers)

I wish to add a file to the /etc/sudoers.d folder that includes a directive to allow www-data to run one specific script with no root password. The directive is www-data ALL=(ALL) NOPASSWD: /path/to/script.sh If I visudo and add it to /etc/sudoers,…
Ben Holness
  • 944
  • 2
  • 10
  • 28
16
votes
2 answers

AWS - removing ec2-user from sudo list

I'm running a production-level Amazon ec2 instance, and I want to close out root privileges to all users. Normally, when one logs in to the instance as ec2-user, the ec2-user immediately gets sudo privileges, which I am trying to do away with in…
Nicholas Finch
  • 275
  • 3
  • 7
15
votes
2 answers

sudo not working on certain commands

I have a rather weird problem with sudo on Debian 8. Users cannot execute some of commands in /etc/sudoers.d. I use Chef to distribute configurations, so all files are automatically generated. Example: This config works fine root@server:~# cat…
Lain Iwakura
  • 163
  • 1
  • 1
  • 5
15
votes
3 answers

check admin rights inside python script

How to check that my python script is running under Administrator rights (sudo) under BSD-like OS? Need to display user-friendly warning in order it is executed without admin rights.
grigoryvp
  • 3,655
  • 11
  • 39
  • 59
14
votes
4 answers

Is it insecure to have an ansible user with passwordless sudo?

I'm new to Ansible. Most VPS provisioning guides I've seen so far do this: disable root from logging in create a new user who can only log in with ssh (not password) add the new user to the wheel group, with passwordless sudo permission I…
lonix
  • 896
  • 10
  • 23
14
votes
8 answers

Every single time I use sudo it hangs before completing

Whether I get prompted for a password or not, it hangs between accepting the authentication and executing what I asked for. In other words sudo ls will hang for about 60 seconds. I'm confused about what might be causing this. This is on Centos 5,…
dlamblin
  • 939
  • 2
  • 10
  • 20
14
votes
3 answers

sudoers to execute commands as another user

I'd like to allow one of my users to execute commands as another user on my Ubuntu Lucid server. I'm struggling with finding the syntax for the sudoers file to do this. Say I'm connecting to the box with a user called 'ludo', and I want ludo to be…
Ludo
  • 1,099
  • 3
  • 10
  • 11
13
votes
4 answers

Giving access of a set of commands to a non-root user without sudo

I want to give non-sudo access to a non-root user on my machine, there is a user dns-manager, his only role is to run all the BIND commands(rndc, dnssec-keygen) etc. Now everytime he has to run a command, he types, sudo rndc reload Is there a way…
Anss
  • 313
  • 1
  • 4
  • 11
1 2
3
59 60