Questions tagged [sudo]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
4k views

Need to execute script file using sudo - run from teamcity

I need to execute a script in Linux platform "runme.sh" (which can be executed as sudo user) using another ant script "build.xml". Now i have execute this build.xml from teamcity. I have code for ...
coolgokul's user avatar
4 votes
3 answers
6k views

Execute a command from another group

In Linux, I have the following id: uid=1005(username) gid=1005(username) groups=1005(username),33(www-data),1002(git) I'd like to change my effective gid to git so that everything I create will ...
kolypto's user avatar
  • 11.2k
3 votes
3 answers
9k views

pass a password to sudo su

I wanted to sudo to different user after ssh'ing into remote server, for this i tried the following: cat remote-test.sh ssh -t -t [email protected] 'bash -s' << EOF /tmp/test.sh EOF ...
kumar's user avatar
  • 133
6 votes
2 answers
3k views

Using sudo inside a script

Is it considered good or bad practice to use the sudo command inside a shell script? One advantage is that if the user runs the script as non-root, she or he will be asked for password on demand ...
August Karlstrom's user avatar
2 votes
1 answer
2k views

How to allow a git hook to run an executable with sudo by modifying /etc/sudoers

I'm using a git post-update hook to run a command via sudo, and I get the error: sudo: sorry, you must have a tty to run sudo. I believe I need to modify /etc/sudoers but I don't know how to do this. ...
Justin Meltzer's user avatar
3 votes
4 answers
9k views

Apache sudoers access

I am making a system call from php which is `sudo /usr/bin/perl -pi -e 's/foo/bar/g' /tmp/newxml.xml`; which works fine in php cli. But would not work in php via browser, because apache does not ...
user1263746's user avatar
3 votes
2 answers
4k views

sudo prompts for password over ssh

I have sudo set up for a user (myuser) as follows on "hostname" (sudoers content): Cmnd_Alias SCRIPT=/path/script* myuser ALL=(suser) NOPASSWD: SCRIPT this works fine, so I can run the following, ...
Joe Watkins's user avatar
1 vote
1 answer
62 views

Changed Password Won't seem to work for account

Bit of an odd problem. I've got a server I can SSH into as one of two logins: root or erik. Once I've logged in as erik I've tried to switch to the root user: # sudo su - root Password: And entered ...
erik's user avatar
  • 89
0 votes
2 answers
2k views

Using sudo /etc/init.d/httpd start complains for log file rights

I created a custom log directory with the root account, and chmoded it to 777 teporarily. ls -la /var/mylogs/log/ total 16 drwxrwxrwx 2 root root 4096 Jun 24 06:27 . drwxr-xr-x 5 root root 4096 Jun ...
SCO's user avatar
  • 143
-1 votes
3 answers
688 views

Unable to Sudo into EC2 server

When i type "sudo -i" on an EC2 instance, i get following error: sudo: must be setuid root Which means that someone has tampered with the sudo permissions. Now the only way to login to server and ...
Farhan's user avatar
  • 4,309
3 votes
3 answers
1k views

How to sudo as another user, without specifying the username

So I'm currently trying to create a sudoers file, but I ran into something I can't figure out. The end result I'm looking for is that I want users to be able to do something like: sudo /usr/sbin/...
Pedro's user avatar
  • 31
2 votes
1 answer
1k views

Check if a file exists, using another user (sudo -u)

I want to check if a file exists [ -f /path/to/file ] using another user. So, I added: USER1 ALL=(USER2) /bin/mkdir, /usr/bin/git, /bin/echo to the sudoers file. The problem is, when I ...
dmmd's user avatar
  • 415
1 vote
1 answer
4k views

How to use sudo with WinSCP and ProFTPd?

I need to run the SFTP fileserver binary as root, but direct root login is not allowed. In WinSCP, if I use "default" on SFTP server protocol option everything works as expected. Following the ...
Gaia's user avatar
  • 1,895
3 votes
3 answers
141 views

SSH access and control

IS there an ideal way to limit access to server admins as to what they can and can not do with sudo? I would like to have levels of access from basic command line actions to more advanced abilities ...
Tiffany Walker's user avatar
-1 votes
2 answers
621 views

sudo to the same ordinary user, without authentication

My script, when executed as root, uses the sudo without passwd, and that is fine. Sometimes however, I must execute that script as an ordinary user, which "switches" to itself by that sudo command. I ...
stoqlt's user avatar
  • 81
2 votes
3 answers
5k views

sudo sourcing user's .bashrc without impacting /root/.bashrc or /etc/bashrc

Is there any way to make sudo use the user's .bashrc file instead of the root one? I would like to use my own .bashrc while using sudo instead of the one of root or /etc/bashrc (I would have to force ...
philippe's user avatar
  • 2,383
8 votes
6 answers
9k views

Broke my /etc/sudoers file on amazon EC2

I edited my Linux Amazon EC2 instance using vim /etc/sudoers and tried adding another account to the list. I realize now that this was a terrible mistake. I can no longer sudo from any account (which ...
Progger's user avatar
  • 253
14 votes
2 answers
4k views

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 ...
Rqomey's user avatar
  • 1,065
0 votes
2 answers
3k views

Problems opening Gedit using X11 in new Ubuntu installation

I've just installed Ubuntu 11.10 and created a new user (and added them to the sudo group). When I log in as the new user (not root) and try to open gedit I get the following error: ** (gedit:17414):...
Pete W's user avatar
  • 143
2 votes
1 answer
2k views

sudoers not working for tar command

I want to disable the requirement of sudo or running as root for a bash script that does backups with tar. I added this line to my sudoers file username ALL=NOPASSWD: /bin/tar However after I added ...
bash-'s user avatar
  • 847
1 vote
1 answer
595 views

Safely execute custom script parts as sudo

In /usr/local/bin I've the following script called sdown /usr/local/bin$ cat sdown #!/bin/bash if [ $# -lt 1 ]; then echo "no time set" else sudo shutdown -h $1 fi Permssions are 788: -rwxr-xr-...
nuala's user avatar
  • 168
2 votes
2 answers
503 views

How safe is it to allow www-data to run sudo quota?

I manage the hosting of a custom Software-as-a-Service (SAAS) CMS and Ecommerce system. This system is powered by a cluster of LAMP servers behind an HAproxy instance, and each customer / domain has ...
Josh's user avatar
  • 9,208
2 votes
3 answers
17k views

using wildcards for paths in sudoers file

I'm trying to set up the sudoers file to allow users to chown files only under a certain directory for example %hmis ALL=/bin/chown eng:hmis /usr/lib/bogimac/bsc/* is not good because hackers ...
user avatar
1 vote
1 answer
563 views

Ruby Enter Your Password to Create App

I have just installed ruby on rails on a Centos server with directadmin following http://blog.ilwilliams.net/installing-rails-3-with-apache-on-centos/ I'm now in a non privileged user account (...
Pez Cuckow's user avatar
0 votes
4 answers
2k views

Operation not permitted

I have a server on Amazon ec2, When I try to change group file (chgrp danny /tmp/bla) I get "Operation not permitted". (I don't want to use "sudo") Anyone know the problem?
Oren's user avatar
  • 9
5 votes
2 answers
122 views

Non-deterministic behavior of `sudo`

I've got a rather strange problem with sudo. Basically, it authenticates, but sometimes just doesn't launch the command provided. For example: liori@marvin:~$ sudo whoami root liori@marvin:~$ sudo ...
liori's user avatar
  • 767
3 votes
2 answers
6k views

changing shadow hash algorithm to bcrypt: how to rehash

I want to change my SHA512 shadow file to use bcrypt as shown in this question/answer: Enable blowfish-based hash support for crypt The problem is that i run into a chicken and egg problem, because ...
Fabian Zeindl's user avatar
2 votes
2 answers
8k views

Run a script as root from apache

I would like to update my hosts file and restart dnsmasq from a web interface (php/apache2). I tried playing around with suid bits (the demonstaration). I have both apache and dnsmasq running on an ...
Lord Loh.'s user avatar
  • 1,079
2 votes
3 answers
5k views

How can I use sudo when I logged in with a SSH key in PuTTY?

I know the title probably doesn't even make sense, but anyway. I downloaded PuTTY and set it up, and followed this tutorial to set up SSH keys so I don't have to input a user or password when logging ...
Alex's user avatar
  • 53
0 votes
1 answer
377 views

How do I install something from source and make it available to root?

I have a CentOS VM and I need to install the latest version of Ruby on it. Unfortunately, yum only makes Ruby 1.8.6 available so I'm trying to install Ruby from source. Here's what I'm using: cd /...
anthonyvd's user avatar
  • 103
3 votes
2 answers
5k views

Why can't I run sudo -g?

$ sudo -u fish -g fish bash Sorry, user steve is not allowed to execute '/bin/bash' as fish:fish on myserver. $ sudo -u fish bash $ groups fish What's the -g option meant to be used for, and why I ...
Steve Bennett's user avatar
1 vote
1 answer
997 views

BASH quoting for sudo su user -c

I need to run the following command: sed -i 's/^/command="\/bin\/false",no-agent-forwarding,no-pty,no-X11-forwarding, /' ~/.ssh/authorized_keys within sudo su user -c I think I've spent about 3 ...
bVector's user avatar
  • 140
1 vote
2 answers
2k views

let users group do "sudo -u username chown"

I would like to edit /etc/sudoers so that group users can execute (only) /bin/chown as user dummy. How might this be done?
dogglebones's user avatar
4 votes
4 answers
17k views

How to configure sudoers to always keep LD_LIBRARY_PATH envrionment variable?

No matter what I try, it seems that the LD_LIBRARY_PATH environment variable is not kept after I run a command with sudo. The only way I managed to have it stick, is to prefix my sudo command with ...
Yanick Girouard's user avatar
2 votes
2 answers
74 views

What is the best method to define a list of commands and access one would need in order to administer a certain application?

My team needs to install and administer a very big application on Red Hat 5.7, and needs to be able to do so as root. During the project, the Unix support team (which is responsible for the OS support)...
Yanick Girouard's user avatar
0 votes
2 answers
1k views

ps aux | grep su, how to kill all su processes?

if I ps aux | grep su I currently have the following after switching users a few times: fmaster 24811 0.0 1.3 10652 7000 pts/3 S 23:11 0:00 -su root 24932 0.0 0.2 5352 1464 pts/...
tester's user avatar
  • 565
13 votes
4 answers
32k views

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 ...
DanH's user avatar
  • 857
0 votes
1 answer
1k views

cp throws 'cannot access' even when sudo'ing

I have a directory ~/c9/support/npm that is owned by my account. I have a target directory /mnt/ws/users/jan/npm that doesn't exist yet, but /users/jan is owned by usr_jan. Now I want to copy the ...
Jan Jongboom's user avatar
2 votes
1 answer
812 views

Grant password-less permission for specific script as specific user with sudo

I have a server running Debian Squeeze with the latest updates. I tried to set up the sudoers file to allow the user www-data execution of a specific shell-script as a specific user. I used visudo for ...
Erwin Brandstetter's user avatar
5 votes
2 answers
7k views

Use sudo -i in bash script

I would like to write a bash script to perform some tasks under root while logging as normal user. Is it possible to have something like this? #!/usr/bash sudo -i <multiple line perform all my ...
Voon's user avatar
  • 77
1 vote
1 answer
357 views

Ubuntu Server Permission Problems

Our sysadmin quit and I have been handed "the ropes." Unfortunately, I don't know how to climb very well. Here is my problem. We have 4 servers that we use for our hosting of client's sites. ...
Brandon Shutter's user avatar
4 votes
2 answers
302 views

best ways allowing a group to edit some /etc files

we have a group called JBossAdmins and users of this group must edit some /etc files on a RHEL 6: /etc/httpd/* /etc/java/* /etc/jboss/* my first idea was to give the following sudo permissions: %...
JMW's user avatar
  • 1,473
5 votes
4 answers
5k views

Why doesn't sudo -E actually preserve my environment?

I'm trying to sudo some binaries that lies in a custom path. That custom path is removed when I run sudo though, but sudo -E should preserve my path. Why doesn't it work? $ env | egrep ^PATH PATH=/...
Hubro's user avatar
  • 1,148
0 votes
1 answer
291 views

Lock down Solaris Shell Changing for normal users

I have a few dozen Solaris(5.10) boxes. By default, they are using ksh as the shell. Only a few users have sudo privileges. The rest do not. I don't want my regular users changing to another shell. ...
Publiccert's user avatar
  • 1,112
0 votes
2 answers
2k views

Why does "su - X" require password, but "sudo -u X bash" doesn't?

I know "why" questions are dangerous :) I have sudo access on RHEL, and noticed this: su - fred Password: (I don't know fred's password). sudo -u fred bash [fred] $ Is there a way to not ...
Steve Bennett's user avatar
4 votes
2 answers
13k views

how to deny "sudo su"

I have several servers where some users require to be sudoers to work. The problem is that when sudoers can run the command sudo su and login as user root. It seems very risky to run that command. I ...
Gon's user avatar
  • 91
1 vote
1 answer
376 views

Create link with right owner / group

I have a git-daemon accessed through ssh. All repositories are in /srv/git. I have some other projects saved on a exfat disk, so I want to create a symbolic link from that disk to /srv/git. For ...
Jaffa's user avatar
  • 238
2 votes
2 answers
2k views

How to config the parameter in puppet sudo module in order to replace the client sudoer?

I'm configuring sudo module in puppet according to this code class sudo { package { sudo: ensure => present, } if $operatingsystem == "Ubuntu" { package { "sudo-ldap": ensure => ...
bayou's user avatar
  • 33
1 vote
2 answers
3k views

sudo: sorry, you must have a tty to run sudo

I am trying to run this bash script as a cron job, but I am getting an error which says sudo: sorry, you must have a tty to run sudo. I am running this bash script in amazon EC2 linux instance. #!/...
Jeevan Dongre's user avatar
3 votes
2 answers
1k views

Why can't I run ausearch (part of auditd) remotely over SSH?

Any idea why the following doesn't work? It hangs with no output. desktop$ ssh myserver "sudo ausearch -k my_key" However, the following works. It outputs the auditing history of this key from ...
richardkmiller's user avatar

1
11 12
13
14 15
18