Questions tagged [sudoers]

The sudo command is configured through a file located at `/etc/sudoers` or `/usr/local/etc/sudoers`

241 questions
152
votes
3 answers

How to run script as another user without password?

I have script.sh that must be run as user2. However, this script can only be run under user1 in my application. I would like the following command to run: su user2 -C script.sh but be able to run without password. I also want this to be very…
user788171
  • 16,753
  • 40
  • 98
  • 125
135
votes
11 answers

Linux: 'Username' is not in the sudoers file. This incident will be reported

After logging into ssh in a linux machine, I got this message: 'Username' is not in the sudoers file. This incident will be reported. How can I resolve this? I'm connecting ssh to my virtual private server. I need to have sudoers privilegies.
Danish Arman
  • 1,427
  • 2
  • 8
  • 7
92
votes
3 answers

Ansible: create a user with sudo privileges

I have taken over a Ubuntu 14.04 server. It has a user called "deployer" (used with capistrano), and as such, it needs sudo privileges. With this setup, I can log into the server and do stuff like: workstation> ssh deployer@myserver myserver> sudo…
Jay Godse
  • 15,163
  • 16
  • 84
  • 131
91
votes
3 answers

Cannot create directory. Permission denied inside docker container

Can not create folder during image building with non root user added to sudoers group. Here is my Dockerfile: FROM ubuntu:16.04 RUN apt-get update && \ apt-get -y install sudo RUN adduser --disabled-password --gecos '' newuser \ && adduser…
Vadim Kovrizhkin
  • 1,575
  • 4
  • 16
  • 27
46
votes
5 answers

Exit/save edit to sudoers file? Putty SSH

Been following instructions for editing sudoers file, made changes but the instructions say to exit using ctrl+x - this just gives me a capital X and a caret. Have tried ctrl:x ctrl+Q Esc. Not using nano or any other gui (just putty terminal), the…
Gonzalez
  • 1,529
  • 2
  • 11
  • 8
27
votes
1 answer

File in /etc/sudoers.d file not being read by sudo

I want to add a user in the sudoers file and I don't want to touch the original /etc/sudoers file, so I added a new file under directory /etc/sudoers.d. The interesting thing is about the name of the newly added file. Initially, I named the file as…
Rick
  • 939
  • 4
  • 9
  • 14
14
votes
6 answers

"/etc/sudoers is world writable" on Mac OS X Mavericks

Currently, I am working on an OSX Maverick, and I can't use sudo command in Terminal. My-Mac:~ phucnd$ sudo sudo: /etc/sudoers is world writable sudo: no valid sudoers sources found, quitting. How can i fix it ?
s7ven
  • 173
  • 1
  • 2
  • 12
14
votes
3 answers

How to give sudo access to a bash script?

I have a bash script(chbr.sh) to change my display brightness from terminal as my brightness keys doesn't work. `sudo setpci -s 00:02.0 F4.B=30` Now, every time I run that script it asks for password which I don't like. So, I googled a little and…
ronnie
  • 1,799
  • 3
  • 17
  • 22
11
votes
1 answer

how to make non root user as sudo user in docker alpine image?

I am trying build cassandra docker image using alpine based os. on the container run process i am getting permission related issue, as i am running as cassandra user. i am unable to run sudo and switch my user cassandra as sudo user. below is my…
andy
  • 525
  • 3
  • 6
  • 22
8
votes
4 answers

Unexpected mongo exit code 100. Restarting

I was trying to run Meteor on my VPS and I was getting this error: Unexpected mongo exit code 100. Restarting. Unexpected mongo exit code 100. Restarting. Unexpected mongo exit code 100. Restarting. Can't start Mongo server. MongoDB had an…
Marek
  • 2,608
  • 4
  • 25
  • 32
7
votes
3 answers

How to fix /etc/sudoers: syntax error near line number

I am new to Ubuntu. And as while editing anything in visual studio code, I had to enter password. so for that I tried to change in sudoers file but after that I am unable to find what happened and also getting error like below. I used the command to…
Dcoder14
  • 1,831
  • 3
  • 12
  • 22
7
votes
3 answers

How to execute multiple commands with sudo in script

Can we use heredocs to run multiple commands using sudo? I am facing an issue (need to pass password for every command) while running multiple commands: echo 'password'| sudo -S ls echo 'password'| sudo -S cat /var/log/abc.log Can anyone help me…
Sasikiran Vaddi
  • 2,199
  • 4
  • 23
  • 29
7
votes
2 answers

How can I allow bash -c for sudoers (followed by multiple commands)?

I have this in /etc/sudoers: %wheel myhostname =NOPASSWD: /bin/bash -c "echo foo && echo bar", \ /bin/bash -c echo foo Executing sudo /bin/bash -c echo foo works without being prompted for a password. However, sudo…
user569825
  • 2,369
  • 1
  • 25
  • 45
7
votes
2 answers

su pass password to script

I am trying to write a script that will run the following commands: sudo su runmqsc_result=`su -c "runmqsc QMGR < /home/rob/query_queue.txt" -m "mqm"` My issue however, is that these commands are run as part of a shell script, by user that is in…
RobM
  • 303
  • 1
  • 4
  • 14
6
votes
6 answers

Net::SSH sudo command hangs after entering password

I've been trying to write a small library using Thor to help assist me in quick creating new projects and sites. I wrote this small method: def ssh(cmd) Net::SSH.start( server_ip, user, :port => port) do |session| session.exec cmd …
joeellis
  • 2,745
  • 7
  • 28
  • 45
1
2 3
16 17