sudo - Execute a command with superuser privileges.

learn more… | top users | synonyms

2
votes
1answer
57 views

sudo -i returns an error

When I try to switch to root using sudo -i i get the error /var/tmp/sclDvf3Vx: line 8: -i: command not found... However, su - works which I will continue to use. I'm by no means a linux system ...
2
votes
1answer
34 views

User without a password - how can one login into that account from a non-root account

I have just started to use Scientific Linux (7.0) (although I assume this question might be distribution neutral..). The kernel version is 3.10.0-123.20.1.el7.x86_64. Coming back to my question. I ...
3
votes
2answers
35 views

How could we allow non-root users to control a system.d service?

With sysvinit, a sudoers entry like this would suffice: %webteam cms051=/sbin/service httpd * This would allow for commands such as: sudo service httpd status sudo service httpd restart Now, ...
1
vote
1answer
28 views

Can I restrict sudoer nopasswd to directory?

Maybe I should rephrase - what is the most secure way to accomplish my needs? Details I am using WinSCP to modify my Apache document_root. The directory /var/www/html has an owner and group of root. ...
0
votes
1answer
25 views

sudo chown -R www-data & userexample /home/example/uploads

when typing in PuTTY sudo chown -R www-data /home/example/uploads My website is displayed but I cannot access my FTP but when typing sudo chown -R example /home/example/uploads I can access my FTP but ...
-1
votes
1answer
30 views

Mutiple commands after sudo in one line

I want to execute multiple commands after a sudo command su - appuser -c "cd /apps/bundle/bundle-client/bin ; export BDL_WEB_USER=not_used ; export BDL_WEB_PASSWORD=not_used ; ./bundle -b ...
5
votes
2answers
9k views

executing if-statement from command prompt

In bash I can do the following: if [ -f /tmp/test.txt ]; then echo "true"; fi However, if I add sudo in front, it doesn't work anymore: sudo if [ -f /tmp/test.txt ]; then echo "true"; fi -bash: ...
4
votes
3answers
4k 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 ...
0
votes
0answers
53 views

apache user cannot sudo while running via httpd

I have a requirement where an web application (php) must run a script on another server. I tested running the remote script as apache user by sudo-ing to the apache user via the root user. The script ...
1
vote
2answers
21 views

Script using sudo works from a terminal but not from a desktop shortcut

I create small script to mount encfs filesystem. just like this: #!/bin/bash kdialog --password "Wprowadź hasło do SSH lub ENTER żeby rozłączyć:" > /home/maciek/Pobrane/pass-1 sudo encfs -S ...
2
votes
1answer
18 views

sudo with original profile

I need to launch an app with root privileges, but the app requires access to the original user's profile....so just using sudo to start the app results in the app starting incorrectly. How can I ...
0
votes
2answers
48 views

grep with variable

I am trying to create a script to monitor all logins using sudo, both success and failure. Right now, I have: set tdate = $(date "+%b %d") set attempted_su_log = /var/log/suattempts cat ...
1
vote
0answers
17 views

How to specify regular expression for command arguments in sudoers

sudoers(5) manpage says that shell-style wildcards (aka meta or glob characters) could be used in command line arguments in the sudoers file. They are *, ?, [...] and [!...]. My idea is to use some ...
4
votes
5answers
101 views

sudo in non-interactive script

I have a script that executes three functions: A && B && C. Function B needs to be run as a super-user, while A and C doesn't. I have several solutions but neither of these is ...
0
votes
2answers
37 views

Bash function for piping data into protected file [duplicate]

I wanted to create a .bashrc function that would simplify passing data to a write-protected file. function pipe { sudo bash -c "$1" } Unfortunately the command pipe echo something > ...
1
vote
1answer
20 views

SUDO_USER undefined in sudo manual - clarification would be lovely

The following statement appears early in the sudoers manual, it refers to the "SUDO_USER environment variable" but the manual does not define it: If sudo is run by root and the SUDO_USER ...
2
votes
1answer
28 views

Secure way to allow any user to run programs in specific network namespace

I have a cell modem connected to my server that I want to use as a means to get notification emails out when the landline dies. To nicely separate normal network access and this exceptional cell ...
1
vote
1answer
2k views

exclude commands from user's sudo permissions

Consider the following line in a /etc/sudoers file: username ALL=(ALL) ALL, !/usr/bin/passwd as far as I know, this allows user username to use sudo, unless he not uses /usr/bin/passwd. But ...
3
votes
4answers
93 views

SUID accidently removed from /bin/su file

It is a production server - CENTOS 6.1 Some user having root access in the past had logged on to the server and removed the SUID bit from the /bin/su file and then exited root. Now we are not able to ...
1
vote
2answers
50 views

How do I use my own local text editor to modify system (requires root to save) files on a remote system?

I've recently fallen in love with github's Atom text editor, and I enjoy using it for all my local coding and configuration. I started to maintain a Nagios installation for several dozen servers and ...
2
votes
1answer
22 views

Sandbox an account and prevent it from any system modifications

I am trying to sandbox a user account to the point where it cannot edit or view any files beyond a certain folder, namely /home/user/test. This account will be compiling and running a C++ program that ...
0
votes
1answer
709 views

Webmin administrative panel options are missing

When I log into Webmin, with the Ubuntu administrative user frank, I cannot see most of the administrative options: frank is shown as the Administration username in Webmin. I accidentally ...
2
votes
2answers
1k views

Using sudoers to allow php to run command

I am trying to get my php page to run this command: shell_exec("sudo /home/xbian/433Utils/RPi_utils/codesend {$num}"); So I added this entry to my sudoers file with visudo: www-data ALL=NOPASSWD: ...
2
votes
1answer
1k views

How do I change file/directory permission of a nfs mounted directory, so I access files as user?

On a Ubuntu computer I mounted a directory from another computer using the following line in the fstab: 12.34.56.78:/space/Images /mnt/space/images nfs rsize=16384,wsize=16384,rw,auto,nolock 0 0 ...
1
vote
2answers
436 views

Script to su -c into a screen is not working as intended

I'm working on a script that will allow me to load up a screen from a user via sudo and su -c. However, when I use it, it will just show the shell of the user: sudo su -c "script /dev/null; screen -r ...
0
votes
1answer
42 views

Restore sudo privileges

Trying to install tor-browser, I screwed up my sudo privileges when I tried to take ownership of a directory. Now I get a message: sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit ...
1
vote
1answer
41 views

su or sudo keeping/removing certain environment variables

I would like to be able to log in as another user and keep most, but not all of my environment. Specifically, I would like to set $HOME to the correct value for the new user, but keep probably ...
1
vote
2answers
54 views

Why does sudo ask for a password?

USER@notebook:~/foo/notebook$ sudo /usr/bin/mplayer /home/USER/foo/notebook/something.mp3 [sudo] password for USER: USER@notebook:~/foo/notebook$ USER ALL=(ALL) NOPASSWD: /usr/bin/mplayer ...
9
votes
3answers
3k views

Stay at same working directory when changing to sudo

When working on the command line, I often change to sudo using sudo -i. However, my working directory changes automatically to /root. I never want to go there; I want to stay where I was! How can I ...
1
vote
2answers
3k views

How to execute changes on remote server as root?

I'm wondering if there is a way to execute a script/commands from the the local machine without making any modifications as root on the remote machine? Some background I'm trying to setup some tasks ...
8
votes
4answers
3k views

Copying protected files between servers in one line?

I'd like to copy squid.conf from one server to another. The servers don't talk to each other. I'd like to go through my workstation. Both servers have the file, so it will be overwritten on the ...
1
vote
3answers
76 views

How can I make sudo forget the password automatically after one command?

My problem is the following: I want to edit a file that is only readable by root. That's why I use sudo vim ~/thefile I could type sudo -K after exiting vim, but I was hoping that there's an ...
0
votes
1answer
23 views

Is it possible to capture SSH+sudo output locally without writing the hostname and [sudo] lines?

Is it possible, when locally writing output from SSH command execution, to suppress the hostname and [sudo] lines? For instance, when I SSH into a server and run sudo <command> it displays ...
0
votes
2answers
25 views

Is there a sudoedit equivalent for vimdiff?

I'm trying to get into the habit of editing root-owned files with sudoedit, instead of sudo vim. This has a few advantages, one of which is that it uses my user's ~/.vimrc. Is there an equivalent, ...
1
vote
1answer
29 views

Different password for login and sudo - security concerns

I'm planning to follow the steps described in this answer to have a different password to log in and sudo. The reason is that I want a high security password to access my account or unblock the ...
16
votes
1answer
9k views

sshfs mount, sudo gets permission denied

I am using sshfs to mount a folder with some python projects over ssh to my ~/ directory. $ mkdir -p ~/mount/my-projects $ sshfs user@example.com:/home/user/my-projects ~/mount/my-projects I can ...
0
votes
1answer
66 views

C/C++: Running multiple commands as root

I want to execute commands within my C program. However, I need root priviliges to create some folders. I run the following: system("echo <rootpass> | sudo cd <folder> && make ...
2
votes
2answers
10k views

How to kill a process that says “Operation not permitted” when attempted?

I have a process I would like to kill: computer@ubuntu:~$ ps aux | grep socat root 2092 0.0 0.0 5564 1528 pts/1 T 14:37 0:00 sudo socat TCP:xxx.17.29.152:54321 ...
1
vote
1answer
47 views

How do I install some required libraries for a program without sudo?

I am trying to run a program on a computer running Red Hat 6.5. This results in the three following errors: "/lib64/libc.so.6: version `GLIBC_2.14' not found" "/usr/lib64/libstdc++.so.6: version ...
3
votes
2answers
1k views

Programatically use visudo to edit sudoers?

I have a sudoers file stored in our svn repo. I want to svn export it to /etc/sudoers but can't do it because sudo detects that it was not edited by visudo and throws syntax errors. What exactly does ...
2
votes
3answers
43 views

How to launch xev from console?

I am trying to launch Xev from console, it always gives "unable to open display", I need to launch xev from a console as another user (I use sudo -u '#1000' to do this). I know xev has a "display" ...
0
votes
2answers
28 views

Ubuntu CentOS RHEL cross bash script su support

I know that title was a little ambiguous. Allow me to explain our issue. We designed an installer script on Ubuntu since Debian based systems are our primary core, however, some of our cloud based ...
-1
votes
1answer
30 views

sudo issue during echo something to a root file [duplicate]

I have a problem, during write something into a root file: $ ll /sys/bus/usb/devices/3-2/power/wakeup -rw-r--r-- 1 root root 4096 Feb 16 17:28 /sys/bus/usb/devices/3-2/power/wakeup $ sudo echo ...
2
votes
3answers
237 views

Why does sudo ignore aliases?

I am running Ubuntu 10.04 and I use upstart for daemon management. My enterprise application is run as a daemon and must be run as root because of various privileges. E.g.: sudo start ...
23
votes
3answers
10k views

If I sudo execute a Bash script file, will all commands inside the Bash script be executed as sudo as well?

I want to write an automated post-installation script in Bash (called post-install.sh, for instance). The script will automatically add and update repositories, install and update packages, edit ...
0
votes
0answers
11 views

Will I be able to install a service as a sudoer?

I will need to install a custom application as a service on a RHEL 6.2 box this weekend. Will I be able to do this with sudoer powers or will I need the root password for anything?
0
votes
1answer
51 views

Sudo User: Not able to see the home directory of other users

I created sudo user hrsupport with following commands: hrsupport ALL=ALL, NOPASSWD: /bin/chown, /bin/chmod, /bin/chgrp, /scripts/pkgacct, /scripts/restorepkg How can I achieve this The hrsupport ...
1
vote
1answer
45 views

File that is only readable with root privileges

I have a binary file that needs to run at startup on all accounts (including unprivileged user accounts), so a command to run it will be put into /etc/rc.local. The program itself will have only ...
3
votes
1answer
38 views

Puzzle over sudo and paths

I have a couple of programmes which are in /usr/local/bin which require root privileges to run. If I run sudo my_prog I get sudo: my_prog: command not found I have to write sudo ...
4
votes
2answers
781 views

Running programs as root with my own password in Scientific Linux/Red Hat/Fedora/CentOS

In Debian-derived Linux distros, if you are not root but are authorized in /etc/sudoers, GNOME will ask you for your own password to allow privileged operations. However, Scientific Linux asks you ...