Questions tagged [sudo]

The sudo command is a program for Unix and Unix-like computer operating systems that allows a user to run programs with the security privileges of another user (normally the superuser, or root). The name is an abbreviation for "substitute user do" (as in, do a command as if started by another user).

The sudo command is a program for Unix and Unix-like computer operating systems that allows a user to run programs with the security privileges of another user (normally the superuser, or root). The name is an abbreviation for "substitute user do" (as in, do a command as if started by another user).

Unlike the su command, users typically supply their own password to sudo rather than the root password. After authentication, and if the /etc/sudoers configuration file permits the user access, then the system will invoke the requested command.

2818 questions
171
votes
18 answers

Root user/sudo equivalent in Cygwin?

I'm trying to run a bash script in Cygwin. I get Must run as root, i.e. sudo ./scriptname errors. chmod 777 scriptname does nothing to help. I've looked for ways to imitate sudo on Cygwin, to add a root user, since calling "su" renders the…
Ken Bellows
  • 6,711
  • 13
  • 50
  • 78
159
votes
22 answers

How to pass the password to su/sudo/ssh without overriding the TTY?

I'm writing a C Shell program that will be doing su or sudo or ssh. They all want their passwords in console input (the TTY) rather than stdin or the command line. Does anybody know a solution? Setting up password-less sudo is not an option. expect…
n-alexander
  • 14,663
  • 12
  • 42
  • 43
156
votes
5 answers

pip install: Please check the permissions and owner of that directory

While installing pip and python I have ran into a that says: The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of…
Max Phillips
  • 6,991
  • 9
  • 44
  • 71
152
votes
3 answers

How to run script as another user without password?

I have script.sh that must be run as user2. However, this script can only be run under user1 in my application. I would like the following command to run: su user2 -C script.sh but be able to run without password. I also want this to be very…
user788171
  • 16,753
  • 40
  • 98
  • 125
148
votes
2 answers

Where are sudo incidents reported?

Attempting something devious on my machine leads to ryan@debian:~$ sudo EAT_ALL_THE_COOKIES_BEFORE_DINNER [sudo] password for ryan: ryan is not in the sudoers file. This incident will be reported. Where is this incident reported, and how do I get…
user1717828
  • 7,122
  • 8
  • 34
  • 59
147
votes
14 answers

How do I edit /etc/sudoers from a script?

I need to edit /etc/sudoers from a script to add/remove stuff from white lists. Assuming I have a command that would work on a normal file, how could I apply it to /etc/sudoers? Can I copy and modify it, then have visudo replace the original with…
n-alexander
  • 14,663
  • 12
  • 42
  • 43
146
votes
10 answers

Connect to mysql server without sudo

The command: mysql -u root -p gives the error: ERROR 1698 (28000): Access denied for user 'root'@'localhost' But running sudo privileges, works: sudo mysql -u root -p Is it possible to get rid of the sudo requirement because it prevents me from…
Riyafa Abdul Hameed
  • 7,417
  • 6
  • 40
  • 55
133
votes
15 answers

On EC2: sudo node command not found, but node without sudo is ok

I have just installed nodejs on a new EC2 micro instance. I installed it normally, ./configure -> make -> sudo make install. Problem: When I run "node" under ec2-user, it runs perfectly. When I run "sudo node", it fails. I found out that node is…
foobar
  • 10,854
  • 18
  • 58
  • 66
130
votes
3 answers

www-data permissions?

So I have a directory in /var/www (called cake) and I need to allow www-data to write to it, but I also want to write to it (without having to use sudo). I'm afraid to change the permissions to 777 in case some other user on my machine (or a hacker)…
q3d
  • 3,473
  • 8
  • 34
  • 39
129
votes
8 answers

Identify user in a Bash script called by sudo

If I create the script /root/bin/whoami.sh containing: #!/bin/bash whoami and this script is called by a user with a properly configured sudo, it will indicate root Is there a fast way to obtain the actual user in a script, or will I have to…
quadmore
  • 1,291
  • 2
  • 8
  • 3
129
votes
6 answers

Getting "Permission Denied" when running pip as root on my Mac

I've started to use my Mac to install Python packages in the same way I do with my Windows PC at work; however on my Mac I've come across frequent permission denied errors while writing to log files or site-packages. Therefore I thought about…
markwalker_
  • 12,078
  • 7
  • 62
  • 99
128
votes
5 answers

Open file via SSH and Sudo with Emacs

I want to open a file inside Emacs which is located on a remote server, with sudo powers on the server. I can open local files with sudo via Tramp like this: C-x C-f /sudo::/home/user/file But I want to use sudo on the server: C-x C-f…
Fernando Briano
  • 7,699
  • 13
  • 58
  • 75
117
votes
14 answers

Composer: file_put_contents(./composer.json): failed to open stream: Permission denied

I'm trying to install Prestissimo to an Ubuntu 16.04 server, but that leads to an error: $ composer global require "hirak/prestissimo:^0.3" Changed current directory to /home/kramer65/.composer [ErrorException] …
kramer65
  • 50,427
  • 120
  • 308
  • 488
116
votes
5 answers

What are the risks of running 'sudo pip'?

Occasionally I run into comments or responses that state emphatically that running pip under sudo is "wrong" or "bad", but there are cases (including the way I have a bunch of tools set up) where it is either much simpler, or even necessary to run…
orome
  • 45,163
  • 57
  • 202
  • 418
104
votes
10 answers

How do you find the original user through multiple sudo and su commands?

When running a script via sudo or su I want to get the original user. This should happen regardless of multiple sudo or su runs inside of each other and specifically sudo su -.
evan
  • 12,307
  • 7
  • 37
  • 51