sudo - Execute a command with superuser privileges.

learn more… | top users | synonyms

0
votes
1answer
41 views

How root can make sure that this time sudo will not prompt for password a specific user?

I am writing a script, that will setup lxc on the host, and then configure a container. I want this script to be unattended. After the container is created and run, there is a moment, when I want to ...
0
votes
1answer
132 views

What do you do when you try to sudo and root's PATH has gone kerblooey?

I've got a feeling something bad just happened to this machine. faheem@bulldog:/usr/local/src/mercurial$ sudo dpkg -i mercurial_3.0-1_amd64.deb mercurial-common_3.0-1_all.deb dpkg: warning: ...
3
votes
1answer
118 views

How do I use sudo to run multiple commands as another user within a portion of a script?

I'm trying to run the following: if [! -f .owner ]; then creator=$(whoami) sudo -u appuser ksh echo "$creator" >> .owner mkdir test1 test2 test3 exit fi However, the ...
3
votes
1answer
42 views

Difference between sudo -s and sudo su -

It might be a duplicate and I'm pretty sure I already show an answer to that somewhere, but I wondered what are the difference in term of right and variable and other stuff between sudo -s and sudo su ...
4
votes
3answers
142 views

Booting a Raspberry Pi from an NFS share

I am trying to boot my Raspberry Pi using an NFS share. I have copied the boot partition of the Raspbian Wheezy image to the SD card and copied the root partition to a networked hard drive. I have ...
2
votes
2answers
224 views

Piping tcpdump traffic via SSH - but no root ssh access

The situation I would like to use Wireshark to analyze traffic on one of our servers, but I don't want to install Wireshark on the server itself. I understand that I can pipe tcpdump traffic via SSH ...
4
votes
2answers
36 views

Use non-root user configuration for root account

When I work with the terminal and use su or sudo to execute a command with the root user's permissions, is it possible to apply the configuration of my "non-root user" (from which I am invoking su or ...
3
votes
2answers
395 views

Sudo Su automated login

I want to automate the login process with sudo su. I have seen lot of questions on these, but none of them are working for me. Automate login with sudo and su Here's my what I tried so far echo ...
2
votes
1answer
208 views

How can I run as another user?

This is the bash code that should be runned. So first it substitutes the user to openproject and than runs all the code su openproject -c "bash -l" cd ~/openproject git checkout Gemfile.lock git ...
2
votes
0answers
223 views

Reading from /etc/environment with sudo

Using Ubuntu 14.04 LTS, I'm having a problem trying to read environment variables from /etc/environment when using sudo env. Basically, they are not being displayed. When I do just env, these ...
2
votes
1answer
30 views

setup sudoers to mount network shares and loop devices and misc

I would like to setup sudoers to grant users to mount all kind of network shares and loop devices to their home directory. Here is a try that I found and changed a bit on one old post in ...
1
vote
0answers
143 views

sudo -u git clone

I'm on Ubuntu server 14.04. I am using apache web server which runs as the www-data. I need to do git clone from a script (a web hook). This script will run with www-data user privilages. Running ...
3
votes
1answer
23 views

How to execute as the logged-in user in a sudo script (OSX)?

Is there a way to switch contexts like that? The script in my specific case is an installer postinstall script, which requires sudo privileges only for some of the tasks and requires the logged-in ...
5
votes
1answer
208 views

No password to run command as root for fixed command? [duplicate]

Is it possible to define a rule in sudoers to allow one user to run one well defined command as root, without password or other authentication except being the right user? Are there alternatives to ...
1
vote
4answers
812 views

How to correctly enable sudo for user in Fedora 20

I followed this question in order to enable sudo command for my created user. So I added it into the wheels group and edited the /etc/sudoers file accordingly. But what I don't get about this is when ...
3
votes
0answers
177 views

bash does not autocomplete my command when using sudo?

I'm using SaltStack. I would like to auto-complete the minion name when calling salt command. The following line has been added into ~/.bashrc: complete -o default -o nospace -W "$(sudo ls -1 ...
4
votes
1answer
348 views

View List of Sudoers with No Sudo Priviledges

If I'm not a sudoer, is it possible to view the list sudoers? Does /etc/group show this information?
4
votes
1answer
117 views

How safe is sudo when running from root to run an application as a less privileged user?

Lets say I am logged in at a root terminal and I run something like the following command: sudo -u '#1000' dbus-launch chromium Are there any potential security issues I should be worried about? ...
3
votes
1answer
38 views

Is there an easy way to background a sudo shell?

A bit more details, what I'm looking for is some kind of ^Z for sudo shells. For instance when running a long command I can hit ^Z to suspend the command or when I do ~^Z in ssh after hitting Enter. ...
1
vote
0answers
52 views

What is the correct way to abort an operation from the sudo password prompt?

Sometimes it amazes me the "little" things I don't know about Unix. For years now I have occasionally noted that I don't actually know how to deal with the sudo password prompt cleanly. Every once in ...
1
vote
2answers
65 views

Problem executing command as differetn user with sudo -u

I have the following problem When I'm trying to execute ls as user abc with the following command I get an error: xyz@host:~/temp$ sudo -u abc ls [sudo] password for xyz: Sorry, user xyz is not ...
0
votes
1answer
78 views

Restrict user to run shell script except which is defined in sudoer file

I have scientific linux 6.4 running on my system, I have restricted other users to run shell script except one, which is defined in /etc/sudoers file. For example: I have one file.sh in my admin's ...
1
vote
2answers
89 views

sudo for users with empty passwords

I want sudo to behave like this, for all users: If the user currently has a non-empty password, prompt for the password. If the user currently has an empty password, either prompt for the password ...
5
votes
1answer
340 views

Give user permission to rm without password or sudo

I'm trying to give the ubuntu user on my machine the ability to rm folders and files (mainly in the /www/ folder) without the need to invoke a password or the need to use sudo. I've been following ...
4
votes
1answer
75 views

keep aliases when I use sudo bash

I have a Centos 5.5 server that has my own alias commands for my account. When I do "sudo bash" I can still use those aliases, I didn't have to add the aliases to the root bashrc. I have another ...
1
vote
1answer
26 views

Replacing graphical sudo prompts with sudo command

I'm trying to replace gksudo, pkexec and its ilk with sudo. However, I'm told that using sudo <graphical_program> is a bad idea. Would the following work as a decent replacement? sudo -H ...
3
votes
1answer
457 views

sudo environment: “g++: command not found”

I have a relatively fresh RHEL 6.5 install, on to which I have installed from source GCCC 4.9. After I installed GCC 4.9, I uninstalled the distro-provided older GCC version via: sudo yum remove gcc ...
8
votes
3answers
909 views

Execute a line of commands with one sudo

For example if I want to create a file and enter text in one line I can redirect the output into a file with the use of the > operator: echo "something" > /path/foobar but if I don't have ...
5
votes
1answer
446 views

I changed /etc/sudoers, and now I can't run as sudo

I messed around with the sudoers file without really knowing what I was doing using this link. Assume I did everything that was in the top answer along with editing it with vim and not visudo. How do ...
0
votes
1answer
460 views

Running both sudo and nohup on a command

There is a complex command that requires sudo: sudo command par1 666 /home/me/... I need to launch it so that it persists after I log off from terminal (SSH). I have discovered that nohup command ...
2
votes
0answers
19 views

Why does xdg-open text_file differ from sudo -u me xdg-open text_file?

If I run the following command, the text file opens in my preferred editor (kate). $ xdg-open text_file However, if I try the following, where sparhawk is my username, I get several warnings, and ...
2
votes
1answer
60 views

How do I limit local user file system access? What is the best method?

I have a Linux installation with a default user and an admin user (and root). On startup, the default user is automatically logged in and a particular application is launched. My intention is to ...
1
vote
2answers
44 views

Disallow Changing of Passwords [duplicate]

I have a spare computer running as a small server doing various things, and I'd like to create another account for my cousin, so she can learn how do manage a server/run minecraft etc. I'd like to ...
1
vote
1answer
43 views

sudoers conditional/combo command is possible?

I want to allow sudo this way: myuser ALL=NOPASSWD:/usr/bin/pkill -fx "/usr/sbin/nethogs -v 3 -s" || /usr/sbin/nethogs -v 3 -s so I get only a single running instance of nethogs. visudo accepts ...
1
vote
1answer
30 views

How do I switch user without any references to the old one?

A while back, when playing with unprivileged LXC, I discovered that the command to create a container failed if I used su to switch to the user, but it worked if I used ssh user@localhost to login. ...
4
votes
2answers
350 views

How to get the name of the user who executed a bash script as sudo?

I want to create a bash script that must be executed with sudo but should take into account the name of the non sudo user who executed it. So if user bob runs sudo ./myscript.sh I would like ...
6
votes
1answer
61 views

How to make gksudo or gksu sessions last longer in Linux

Every time I want to open a GUI program that needs root permissions, I have to put my password. For example, I open synaptic and put my password then close it and a second later decide to reopen it it ...
0
votes
1answer
154 views

How to give All privilege rights to user ubuntu 12.04

I am working with my first VPS.I created a new user adduser username and then I added this line username ALL=(ALL:ALL) ALL under root in visudo I saved the changes and exit the ...
3
votes
1answer
4k views

“sudo: sorry, you must have a tty to run sudo” when using sudo in a remote script

I want to run a series of sudo-elevated commands on a remote machine from an embedded script. To simplify the question, I'm just trying to run sudo id and get it to tell me that it's root. I am ...
2
votes
3answers
157 views

Can sudo replace su?

There is much duplication of functionality on Linux-based systems, for example these do the same thing: sudo --login --user <user> sudo su - <user> The sudo-only approach looks more ...
3
votes
1answer
125 views

how to use rsync (using password-less ssh), with sudo just on the local side?

This command works fine for me with password-less ssh: rsync -aqve ssh ${user}@${remote_host}:/etc/bind /tmp/etc/bind Since I would like to rsync directly to my own local /etc/bind with root ...
2
votes
0answers
67 views

PHP exec and amixer

I'm trying to make php lower the dB level of amixer using exec, but it seems like php isn't able to perform the task which requires sudo-access. What should be the best way to solve this? I tried: ...
3
votes
1answer
2k views

Vim Error E138: Can't write viminfo file $HOME/.viminfo!

I'm afraid I've run into something rather strange. When I open a file normally, vim README.txt, everything is fine. But upon sudo vim README.txt, the file renders blank, and gives me a E138: Can't ...
1
vote
3answers
263 views

Send a command with password in upstart script

CentOS 6.5 The server is an AWS AMI, specifically this one I'm trying to use upstart to start a process on boot On this particular box, the root login is disabled, and every time I need to run ...
4
votes
1answer
106 views

How can I run growisofs via sudo?

Whenever I've attempted to run growisofs via sudo I've always gotten the following error message. $ sudo -i growisofs :-( growisofs is being executed under sudo, aborting! See NOTES paragraph in ...
1
vote
4answers
317 views

sudo not preserving PS1

The configuration below is in my /etc/sudoers: Defaults !visiblepw Defaults always_set_home Defaults env_reset Defaults env_keep = "COLORS EDITOR DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR ...
1
vote
1answer
687 views

Switch users with sudo or su in a shell script

I inherited this. Long story short I have an XML file that is calling a shell to run some commands. Everything I have tried has failed at the second su in the script. Here are some of the failure ...
1
vote
1answer
112 views

Slow sudo because of socket connections

Some time ago sudo started to behave very slow on our server. Some times we have to wait even a few minutes until it executes. I've checked all hostname and dns causes that forums all full of, but ...
2
votes
1answer
99 views

Sudo email notification setup error

I'm Using Centos version: [sysadmin@backup-srv ~]$ cat /etc/redhat-release CentOS release 6.4 (Final) I'm using this sudo version: [sysadmin@backup-srv ~]$ sudo -V Sudo version 1.8.6p3 Sudoers ...
2
votes
2answers
120 views

Will I be prompted for the sudo password a second time?

This is what I plan to do: #!/bin/bash sudo -i <<'EOF' iptables-save | awk '/^[*]/ { print $1 } /^:[A-Z]+ [^-]/ { print $1 " ACCEPT" ; } /COMMIT/ { print $0; ...