Questions tagged [sudo]
sudo is a tool which allows users to run commands as another user (usually the root user)
76
questions
82
votes
7
answers
121k
views
Log all commands run by admins on production servers
It is company policy for admins to login to the servers via a personal username, and then run sudo -i to become root. Upon running sudo -i, sudo will create an environmental variable called SUDO_USER,...
21
votes
5
answers
31k
views
`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, ...
214
votes
8
answers
349k
views
How to setup passwordless `sudo` on Linux?
How can passwordless sudo access be setup on either RHEL (Fedora, CentOS, etc) or Ubuntu distributions? (If it's the same across distros, that's even better!)
Setting: personal and/or lab/training ...
4
votes
3
answers
30k
views
chmod -R 777 / on ubuntu - numerous problems
A client has accidentally given the entire filesystem full permissions on their ubuntu 10.04 box.
chmod -R 777 httpdocs/cd /
As you can see they attempted to cd to the root, and instead gave chmod a ...
80
votes
2
answers
137k
views
sudoers: how to disable requiretty per user
I don't want to comment out the line in /etc/sudoers:
Defaults requiretty
Instead, I only want a certain user not to require a tty.
How can this be done?
197
votes
11
answers
109k
views
ssh-agent forwarding and sudo to another user
If I have a server A into which I can login with my ssh key and I have the ability to "sudo su - otheruser", I lose key forwarding, because the env variables are removed and the socket is only ...
50
votes
7
answers
28k
views
How do I sudo over sshfs?
On my local host alpha I have a directory foo that is mapped via sshfs to host bravo as follows:
$ sshfs charlie@bravo:/home/charlie ~/foo
However, on host bravo there is another user, delta, that I ...
8
votes
9
answers
32k
views
Editing sudoers file to restrict a user's commands
Is it possible to edit the sudoers file so a user can use sudo for any command except for a specified one? I reverse is true, I believe, that the sudoers file can be setup so that a user can only ...
72
votes
4
answers
186k
views
How can I allow one user to su to another without allowing root access?
I'd like to allow certain users to su to another user account without having to know that account's password, but not allow access to any other user account (i.e. root).
For instance, I'd like to ...
54
votes
2
answers
10k
views
Why do I have to edit /etc/sudoers with visudo?
I've noticed that the sudoers file and cron config files act in a special way compared to other config files on Linux. They need to be edited with a special wrapper rather than any text editor. Why is ...
13
votes
4
answers
20k
views
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 ...
13
votes
1
answer
4k
views
Accessing SSH_AUTH_SOCK from another non-root user
The Scenario:
I am running ssh-agent on my local PC, and all my servers/clients are setup to forward SSH agent auth. I can hop between all my machines using the ssh-agent on my local PC. That works.
...
13
votes
5
answers
52k
views
ubuntu: let a user run a script with root permissions
I have ubuntu 8.04 and I want to write a bash script that runs as root which every user can run.
I myself can do sudo.
How do I do that?
CLARIFICATION: I don't want to do it with sudo, because then ...
11
votes
2
answers
26k
views
No TTY present when running commands over SSH in here-document
I'm trying to run a command over SSH like this in a here-document:
ssh example.com <<END
sudo /etc/init.d/apache2 reload
END
Which normally works except when I'm trying to run something that ...
7
votes
5
answers
4k
views
How to add a line to the end of a file which I can access via sudo?
I have tried:
sudo "some string" >> test.txt
But I am getting permission denied warning.
Can anyone help?
51
votes
4
answers
3k
views
Linux: set up for remote sysadmin
Every now and then I get the odd request to provide remote support, troubleshooting and/or performance tuning on Linux systems.
Larger companies often already have well established procedures to ...
33
votes
10
answers
13k
views
Why su to root instead of logging in as root?
I've heard often that it is better to su to root rather than log in directly as the root user (and of course people also say that it's even better to use sudo). I've never really understood why one ...
30
votes
4
answers
9k
views
vim re-edit as root
I often open a file in vim, make some changes and when it's time to save the file is read-only.. (owned by another user). I'm looking for tips on how I could re-open the file
as root and keep my ...
14
votes
4
answers
8k
views
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 ...
13
votes
5
answers
10k
views
Ubuntu: borked my sudoers file, how can I fix it?
I was editing my /etc/sudoers file and saved it but it has a syntax error in there. Now I can't sudo vim /etc/sudoers because sudo thinks the sudoers file is not valid.
How can I fix this?
9
votes
2
answers
3k
views
Why can the root user edit read-only files, but a regular user with sudo access can't?
If you try to append to a file with no write permissions (say, the /etc/sudoers file which is is owned by root and has 0440 permissions), if you're the actual root user, this works. However, if you're ...
8
votes
1
answer
1k
views
Configuring sudo to work without password
I'm trying to configure sudo to allow all users to restart apache without having to enter a password.
Security concerns aside, why isn't this working?
I added the line to /etc/sudoers: %admin ALL=...
6
votes
2
answers
8k
views
Parse error in sudoers file
I've created a user called kafka to whom I am trying to give a sudo access to run only /etc/init.d/kafka commands.
I added the following entry to /etc/sudoers.d/kafka via Ansible:
kafka ALL = ...
5
votes
3
answers
40k
views
nagios nrpe unable to read output
I'm trying to use check_nrpe to check on a remote server, but it's not working and I can't figure out what am I missing...
# /usr/lib/nagios/plugins/check_nrpe -H XXX -c check_load -a 6,5,4 8,7,6
...
5
votes
4
answers
5k
views
ubuntu - how can I avoid typing a password on every admin action?
I just set-up ubuntu 9.10 on my computer, and I'm trying to figure out how to avoid typing a password on every action that requires sudo privileges. I just want to type a password once on login and ...
4
votes
1
answer
12k
views
SELinux blocking sudo from zabbix_agentd
I have a custom user parameter for Zabbix that calls a hardware RAID CLI tool (arcconf / megacli) and checks if any arrays are degraded. Since these tools are root-only, I have configured sudoers to ...
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 ...
1
vote
1
answer
7k
views
Accidentally deleted symlink libc.so.6 in CentOS 6.4. How to get sudo privilege to re-create it?
I accidentally deleted the symbol link /lib64/libc.so.6 -> /lib64/libc-2.12.so with
$ sudo rm libc.so.6
Then I can not use anything including ls command. The error appears for any command I type
ls:...
-3
votes
1
answer
414
views
How do I add a user to the sudoers file? [closed]
I already know that I should:
run visudo
be logged in as root
But then what changes should I make to the sudoers file?
p.s. The question got 'down-voted'. Is this a bad question?! I looked at man ...
127
votes
18
answers
151k
views
Why does sudo command take long to execute?
I've been picking up Linux (Fedora 10, then 11) over the past few months (and enjoying it immensely-- it's like discovering computers all over again, so many things to learn).
I've added my user to ...
83
votes
12
answers
69k
views
How can I run arbitrarily complex command using sudo over ssh?
I have a system that I can only log in to under my username (myuser), but I need to run commands as other user (scriptuser). So far, I have come up with the following to run the commands I need:
ssh -...
63
votes
9
answers
14k
views
Is it OK to set up passwordless `sudo` on a cloud server?
I love the idea of accessing servers via keys, so that I don't have to type in my password every time I ssh into a box, I even lock my user's (not root) password (passwd -l username) so it's ...
60
votes
10
answers
250k
views
how to use xauth to run graphical application via other user on linux
My regular user account is, let's say, user1. I created separate user2 for some x application that i would like to run while being logged into x as user1 but in a way that will prevent it from read/...
56
votes
1
answer
170k
views
What's the difference between sudo su - postgres and sudo -u postgres?
PostgreSQL users peer authentication on unix sockets by default, where the unix user must be the same as the PostgreSQL user. So people frequently use su or sudo to become the postgres superuser.
I ...
40
votes
1
answer
4k
views
Why can I update a file owned by root using sudo vi, but not append a line to it with sudo echo "Thing" >> file?
I would like to have script that is doing automated migrations of websites from another be able to append Includes to the /etc/httpd/conf.d/vhosts.conf file.
However, when I try to use echo to put ...
27
votes
5
answers
5k
views
What are the actual benefits of assigning sudo privileges to a user instead of using root?
I am fairly new to server administration, and I have seen a lot of sites recommending to assign sudo privileges to a user created by the root user and giving the root user an insanely long password ...
25
votes
2
answers
4k
views
Why does password entering work in a piped sudo command?
If I do:
sudo cat /etc/resolv.conf | less
It will prompt me for the password, even though less (presumably) takes stdin. Over what fd's is the password prompt shown and how does it get the input ...
15
votes
8
answers
25k
views
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 ...
14
votes
3
answers
22k
views
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 ...
14
votes
2
answers
31k
views
Using FreeIPA for centralized sudo - how to specify ALL commands?
I'm having a hard time wrapping my head around FreeIPA's model. The FreeIPA manual states:
FreeIPA adds an extra control measure with sudo command groups, which
allow a group of commands to be ...
13
votes
3
answers
20k
views
Is "sudo su -" considered a bad practice?
Background
I know the difference between su -, sudo su -, and sudo <command>:
su - - switches user to root, requires the root password
sudo su - - switches user to root, requires only the ...
13
votes
2
answers
2k
views
Allow complex sudo command on Debian Linux
I need to allow a specific command on a Debian Linux box for a single user. I've tried this in the /etc/sudoers file:
# User privilege specification
zabbix ALL=NOPASSWD: /usr/bin/apt-get --print-...
13
votes
4
answers
45k
views
Starting a script as another user
I've created a script in /etc/init.d/ which has to run several other scripts from other (non-root privileged) users from their home directories, as if they started them.
I launch these scripts with:...
8
votes
5
answers
3k
views
Update multiple sudoers file
We have multiple Linux servers that authenticate to an Active Directory Domain. For a group in AD, I want to add a list of commands that are allowed to run as root using sudo. I can obviously ssh-in ...
8
votes
3
answers
8k
views
Running 'sudo' over SSH
I'm writing a script which is to log onto a bunch of remote machines and run a command on them. I've set up keys so the user running the script does not have to type the password of each machine, but ...
6
votes
1
answer
6k
views
What's the difference between "sudo su -" and "sudo -i"? [duplicate]
Possible Duplicate:
What is the difference between sudo -i and sudo su -
I know both commands result in gaining a root-shell. But there are some differences.
On some servers e.g. the prompt is ...
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 ...
6
votes
4
answers
31k
views
Allow Apache to run a command as a different user
I have a script that executes several commands in a user's home directory. The files are owned by the user and Apache (the www-data group) only has read privileges to them. The script needs to be ...
6
votes
2
answers
3k
views
Easy multi-level authentication for sudo
I have a FreeBSD server with password-based SSH enabled. I would like to enable sudo, but I do not want a potential attacker to be one password away from root access. My current solution is logging ...
5
votes
4
answers
13k
views
How to override a PATH environment variable in sudo?
I set PATH in /etc/profile. I do not have any problems in the case of the general user, but PATH does not go when I become the root authority in sudo.
What would you do to override the PATH which is ...