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

learn more… | top users | synonyms

17
votes
6answers
8k 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 ...
3
votes
3answers
27k 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 ...
8
votes
9answers
10k 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 ...
60
votes
8answers
24k 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 ...
39
votes
5answers
41k 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 ...
23
votes
3answers
51k 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 ...
38
votes
2answers
4k 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 ...
5
votes
2answers
5k 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 ...
22
votes
4answers
5k 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 ...
29
votes
10answers
8k 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 ...
8
votes
1answer
925 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 ...
7
votes
3answers
4k 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 ...
7
votes
4answers
4k 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?
5
votes
4answers
3k 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 ...
5
votes
5answers
14k 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 ...
3
votes
1answer
431 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. ...
1
vote
2answers
1k 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
5answers
2k views

How do I reset ownership of /usr/bin/sudo on Linux?

I accidentally changed ownership of /usr/bin/sudo to my current user (i also did this for some other stuff in my /usr directory). I can't change any of them back because I need ownership of ...
33
votes
8answers
5k 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 ...
19
votes
4answers
5k 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 ...
18
votes
14answers
22k 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 ...
22
votes
8answers
31k 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 ...
5
votes
2answers
2k 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 ...
23
votes
5answers
1k 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 ...
3
votes
4answers
8k 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 ...
8
votes
4answers
1k 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 ...
6
votes
2answers
953 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 ...
3
votes
3answers
287 views

What's the magic of the “sudo su”?

[demo@PHP_DEV_57 ~]$ sudo su [root@PHP_DEV_57 www]# Why I can switch to root by simply sudo su, what's the difference between sudo and su?
2
votes
2answers
3k views

Troubleshooting sudoers via ldap

The good news is that I got sudoers via ldap working on Red Hat Directory Server. The package is sudo-1.7.2p1. I have some LDAP/Kerberos users in an LDAP group called wheel, and I have this entry in ...
2
votes
3answers
7k 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 ...
1
vote
4answers
2k views

Editing with Winscp

I would like to edit files in my /etc from winscp. I have administrator privileges on this computer, How can i edit files and save them from Winscp in folders that require sudo be written before any ...
5
votes
1answer
799 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 ...
5
votes
3answers
3k views

Sudo asks for password twice with LDAP authentication

I have Ubuntu 8.04 LTS machine and Windows 2003 AD domain. I have succesfully set up that I can log in with domain username and password, using domain prefix, like "domain+username". Upon login to ...
4
votes
1answer
246 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 ...
4
votes
8answers
12k views

How to specify root's environment variable?

I do rails development. In this app, I need to specify the environment variable LD_LIBRARY_PATH = /usr/local/oracle/lib, but when I run the app with sudo script/server, it doesn't run because that ...
3
votes
2answers
2k 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 ...
2
votes
4answers
610 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 ...
2
votes
5answers
2k views

Debian and LDAP for sudo

I'm on debian and want sudo to use ldap instead of /etc/sudoers. Anyone have exprience doing this?
1
vote
1answer
3k 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 ...
1
vote
2answers
3k views

Best practices to avoid Jenkins error: sudo: no tty present and no askpass program specified

When running any sudo command from Jenkins I get the following error: sudo: no tty present and no askpass program specified I understand that I can solve this by adding a NOPASSWD entry to my ...
1
vote
6answers
4k views

sudo to super-user after scp

For deploying code to a server I run a script which scp's the deployment file onto the server using my private key . But after scp I have to manually ssh to the machine sudo to a superuser account ...
0
votes
4answers
526 views

To understand sudo and “.”

I am reading MySQL's manuals. They suggest me that the command cd /usr/local/mysql sudo ./bin/mysqld_safe // it seems that sudo = . + master rights is the same as . ...