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.

2549 questions
1523
votes
9 answers

How does the vim "write with sudo" trick work?

Many of you have probably seen the command that allows you to write on a file that needs root permission, even when you forgot to open vim with sudo: :w !sudo tee % The thing is that I don't get what is exactly happening here. I have already…
Doppelganger
  • 17,749
  • 7
  • 28
  • 28
1361
votes
37 answers

How to fix npm throwing error without sudo

I just installed node and npm through the package on nodejs.org, and whenever I try to search or install something with npm, it throws the following error unless I sudo the command. I have a feeling this is a permissions issue? I am already the…
Chad
  • 16,774
  • 8
  • 29
  • 41
967
votes
15 answers

How do I use sudo to redirect output to a location I don't have permission to write to?

I've been given sudo access on one of our development RedHat linux boxes, and I seem to find myself quite often needing to redirect output to a location I don't normally have write access to. The trouble is, this contrived example doesn't work: sudo…
Jonathan
  • 23,467
  • 12
  • 62
  • 81
628
votes
15 answers

sudo echo "something" >> /etc/privilegedFile doesn't work

This is a pretty simple question, at least it seems like it should be, about sudo permissions in Linux. There are a lot of times when I just want to append something to /etc/hosts or a similar file but end up not being able to because both > and >>…
David
  • 16,423
  • 8
  • 63
  • 95
478
votes
27 answers

How to fix 'sudo: no tty present and no askpass program specified' error?

I am trying to compile some sources using a makefile. In the makefile there is a bunch of commands that need to be ran as sudo. When I compile the sources from a terminal all goes fine and the make is paused the first time a sudo command is ran…
hebbo
  • 6,005
  • 4
  • 21
  • 44
463
votes
6 answers

How to keep environment variables when using sudo

When I use any command with sudo the environment variables are not there. For example after setting HTTP_PROXY the command wget works fine without sudo. However if I type sudo wget it says it can't bypass the proxy setting.
Ahmed Aswani
  • 7,169
  • 7
  • 31
  • 52
338
votes
12 answers

How to use sudo inside a docker container?

Normally, docker containers are run using the user root. I'd like to use a different user, which is no problem using docker's USER directive. But this user should be able to use sudo inside the container. This command is missing. Here's a simple…
drubb
  • 10,047
  • 6
  • 13
  • 11
291
votes
17 answers

Why does sudo change the PATH?

This is the PATH variable without sudo: $ echo 'echo $PATH' | sh /opt/local/ruby/bin:/usr/bin:/bin This is the PATH variable with sudo: $ echo 'echo $PATH' | sudo sh /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin As…
Michiel de Mare
  • 40,513
  • 27
  • 100
  • 132
181
votes
9 answers

Open a file with su/sudo inside Emacs

Suppose I want to open a file in an existing Emacs session using su or sudo, without dropping down to a shell and doing sudoedit or sudo emacs. One way to do this is C-x C-f /sudo::/path/to/file but this requires an expensive round-trip through…
Chris Conway
  • 52,725
  • 40
  • 121
  • 150
168
votes
7 answers

proper way to sudo over ssh

I have a script which runs another script via SSH on a remote server using sudo. However, when I type the password, it shows up on the terminal. (Otherwise it works fine) ssh user@server "sudo script" What's the proper way to do this so I can type…
darkfeline
  • 6,794
  • 5
  • 29
  • 30
164
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,181
  • 12
  • 47
  • 73
162
votes
9 answers

Command not found when using sudo

I have a script called foo.sh in my home folder. When I navigate to this folder, and enter ./foo.sh, I get -bash: ./foo.sh: Permission denied. When I use sudo ./foo.sh, I get sudo: foo.sh: command not found. Why does this happen and how I can…
Neko
  • 2,900
  • 6
  • 25
  • 33
156
votes
10 answers

how to run two commands in sudo?

Is there any way how I can run two Db2 commands from a command line? (They will be called from a PHP exec command.) db2 connect to ttt (note that we need to have the connection live for the second command db2 UPDATE CONTACT SET EMAIL_ADDRESS =…
Radek
  • 14,395
  • 48
  • 147
  • 231
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…
Phil Andrews
  • 5,501
  • 6
  • 32
  • 61
151
votes
20 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
  • 12,733
  • 11
  • 39
  • 43
1
2 3
99 100