Questions tagged [sudo]
The sudo command is a program for some Unix and Unix-Like operating systems, that allows a user to execute programs with the security privileges of another user. Typically those of a superuser or the root user.
109
questions
209
votes
12
answers
610k
views
sudo with password in one command line?
On busy days, I'd like to run
$ ./configure && make && sudo make install && halt
on the night and go to bed, hoping the application would automatically be installed. But ...
13
votes
3
answers
61k
views
How to change user in WinSCP?
I'm using WinSCP to access Unix computers. How can I change user after I have logged into a Unix server using WinSCP?
E.g. I have personal account in Unix computer A. I can log into this computer ...
54
votes
6
answers
120k
views
How do I make sudo preserve my environment variables?
Using sudo 1.7.4p4 on Solaris 5.10 and sudo 1.6.7p5 on RHEL4 u6 I can't see how to preserve my environment variables, for instance $PYTHONPATH. I've added this line to sudoers, but it doesn't make any ...
1
vote
1
answer
3k
views
how do I run a sudo command and load the environment variables of current logged on user?
I need to run an ssh sudo command.
command is as follows:
ssh -i keyfile [email protected] 'sh -v /opt/dir/script'
the script contains the following:
sudo -E node some.js
the reason I use the -E ...
334
votes
9
answers
114k
views
How to append to a file as sudo?
I want to do:
echo "something" >> /etc/config_file
But, since only the root user has write permission to this file, I can't do that. But the following also doesn't work.
sudo echo "something" ...
82
votes
4
answers
102k
views
How to set path for sudo commands
If I issue
sudo my-command
how does Linux look for that my-command?
The my-command is in my PATH. I can invoke it without any problem. However, when I invoke it with sudo, I'll get command not found.
...
60
votes
6
answers
118k
views
command not found when using sudo
There are a few question on the site that seem related to my problem but I could not find a solution in any of them.
My operating system is Ubuntu 12.04. I have mvn installed in /tools/noarch/apache-...
32
votes
5
answers
62k
views
How to prevent sudo users from running specific commands?
I have a very sensitive network setup and I really dont want to mess up with it. My network consists a bunch of users who are with sudo privilege.
I want to stop them from running
service ...
5
votes
3
answers
33k
views
How to provide password directly to the sudo su -<someuser> in shell scripting
I got a requirement to automate in shell script for sudo su -<someuser> which asks for password.
How to provide password directly to the sudo su - in shell scripting for IBM AIX servers.
I have ...
138
votes
7
answers
286k
views
scp to remote server with sudo
I have a file on server A (which is behind a NAT so not directly addressable). The file needs to be copied to server B in a directory restricted to root. I have an account on server B with sudo ...
53
votes
5
answers
44k
views
Sudo vs root; any actual differences?
I'm working with a support member for a product, and he insists that I need to be root to install a series of patches, and that sudo won't work; he doesn't provide a reason but seems very firm in his ...
18
votes
0
answers
7k
views
sudo unable to write to /etc/profile [duplicate]
I am following the instructions on this site for Grails installation, but am not able to write to /etc/profile like it instructs.
sudo echo ‘JAVA_HOME=/usr/lib/jvm/java-6-sun’ >> /etc/profile
...
18
votes
4
answers
34k
views
How I can make sudo session an hour and not few minutes in Ubuntu 10.04?
How I can make sudo Ubuntu 10.04 session an hour and not few minutes?
Now I have to write my password for sudo commands every few minutes.
8
votes
5
answers
7k
views
Should I use sudo in a script or sudo an entire script?
I run a small group of macOS machines for students (say 20) and they all need to be setup with things like homebrew and other packages and applications. I'm writing a bash script to automatically ...
7
votes
2
answers
13k
views
Sudoers NOPASSWD for single executable but allowing others
Operating System: Arch Linux
Linux version: 4.16.11
Sudo version: 1.8.23
What I need:
be able to execute any executable with a sudo with a password prompt
be able to execute one executable, /home/...
4
votes
2
answers
7k
views
Remove files from a root-owned directory using sudo with wildcards
Let's say I have a folder, /var/log/nginx which is protected (owned by root, and no one else can read or write into it). Even using sudo, I can't do sudo rm -f /var/log/nginx/ab* without getting "No ...
48
votes
3
answers
73k
views
SSH: execute sudo command
I have an interactive shell script, that at one place needs to ssh to another machine (Ubuntu based) and execute something as root (the user should enter his password, but the remote command should ...
29
votes
3
answers
12k
views
sudo command trying to search for hostname
Recently, I have changed the sudoers file and the hostname through /etc/hostname. After changing this files, my sudo command is taking a lot of time. Also, it says sudo unable to resolve host kaagini(...
17
votes
2
answers
26k
views
sudoedit: why use it over sudo vi?
According to the man page:
sudoedit /etc/file
creates a copy of the file, opens it as the current user, and when saved overwrites the existing file with the copy.
whereas
sudo vi /etc/file
opens ...
9
votes
2
answers
2k
views
Creating an alias containing bash history expansion
I often forget to run a command with sudo, so I find myself often typing sudo !! immediately afterwards.
I tried aliasing this, but bash chokes on the !! part. Is there some way to represent this ...
8
votes
4
answers
4k
views
Terminal: prefix previous command?
Frequently in Terminal (though I fully expect any answer will work in bash and most others), I type some command, and then get some sort of permission error due to missing sudo.
Okay, so press 'up', ...
8
votes
6
answers
6k
views
Allowing automatic command execution as root on Linux using SSH
What is a good setup that allows automatic execution of a command or a script on a remote server with root privileges using SSH?
I'm aware (only vaguely for some the options) of the following options:
...
6
votes
5
answers
67k
views
Automating the "sudo su - user" command
I want to automate
sudo su - user
from a script. It should then ask for a password.
5
votes
2
answers
6k
views
How can I alias a command for sudo?
I have an alias that I would like to use both as a regular user and as root, via sudo. Specifically, it is this:
alias rm=trash
This works fine as a normal user, and it works fine when I use sudo -i ...
4
votes
2
answers
7k
views
Cannot do sudo: "/etc/sudoers is mode 0740, should be 0440"
I have a problem:
I don't have a root password on my mac. I just have an Admin account, which can do stuff using sudo. Now, I wanted to add my normal user to the /etc/sudoers file as well. Since it ...
3
votes
2
answers
4k
views
How is WinSCP able to provide a sudo user for executing scp?
The tool WinSCP is able to perform a sudo on the remote machine to perform the scp as the sudo user. That leads me to think that this must be possible with the command-line version of scp as well.
...
2
votes
2
answers
4k
views
Sudo doesn't work on Aliases [duplicate]
I have added alias ll='ls -la' in /etc/bash.bashrc but sudo ll is not working. Is there a way to "source" bash.bashrc? In a related post, another user suggesting creating an alias for sudo with a ...
203
votes
6
answers
298k
views
Why won't "sudo cd" work?
Why typing sudo cd whatever won't change the directory?
35
votes
7
answers
151k
views
How can I add a regular user to the sudoers file?
How can I add more users to the "sudoers" file?
34
votes
11
answers
55k
views
Sudo - is there a command to check if I have sudo and/or how much time is left?
(Originally posted on Stack Overflow). They suggested I try here instead. Here's the original post:
Sudo - is there a command to check if I have sudo and/or how much time is left?
See title. I ...
25
votes
9
answers
32k
views
What's the difference between the commands "su -s" and "sudo -s"?
What is the difference between the two super user commands, su -s and sudo -s?
They both give a shell with access to the superuser account.
24
votes
9
answers
57k
views
Opening Explorer shell with admin privileges on XP (with IE7 installed)
I used to demote my user account so that it had no admin priveleges and used a 'sudo-like' trick where you create a shortcut to IE6 and enabled the 'Run with different credentials' option to open a ...
22
votes
1
answer
7k
views
Why does wget give an error when executed with sudo, but works fine without?
I tried the following command:
$ wget -q --tries=10 --timeout=20 --spider http://google.com
(From this SO post. I want to check my internet connection in bash.)
I get following output:
Spider mode ...
17
votes
3
answers
21k
views
Why can't I sudo some commands? (e.g., vim)
I have sudo access on my friends server, running centos-6.3, but when I try to run some commands like sudo vim /var/www/html/index.html I get an error sudo: vim: command not found I can, however, run ...
15
votes
4
answers
19k
views
Passing PATH through sudo
In short: how to make sudo not to flush PATH everytime?
I have some websites deployed on my server (Debian testing) written with Ruby on Rails. I use Mongrel+Nginx to host them, but there is one ...
10
votes
5
answers
39k
views
sudo chmod -R 777 /
sudo chmod -R 777 /
I did this. It was a mistake. Is there any way to undo it?
Basically it's messed up more things than I can list. I don't have time-machine enabled on my mac.
9
votes
1
answer
5k
views
non-interactive ssh sudo... prompts for the password in plain text
I'm running some non-interactive ssh commands. The ssh authentication is taken care of fine through the ssh agent, but if I run a command that requires sudo then the password prompt in my terminal is ...
7
votes
7
answers
3k
views
Pre-authorise sudo? (So it can be run later)
I often set my work computer running some time-consuming computations before I go home in the evening. After they're done, I'd like it to shutdown. However, as shutdown requires root privileges, it ...
6
votes
3
answers
40k
views
"Unable to locate package sudo" when i try to install sudo on new Debian
i installed a new Debian on a small VPS and now when i try to install sudo i just get this message. I also tried to add FTP-Server into the list and i still get that error.
root@srv45758:~# vi /etc/...
5
votes
1
answer
3k
views
What is the + at the end of Unix permissions in a long listing format?
Here's an example
drwxr-xr-x+ 6 reza reza 204 Mar 5 20:23 .ssh/
Although I am the owner of this directory, I cannot modify it without using sudo!
Why is that? how can I remove '+' here (...
5
votes
2
answers
11k
views
Ubuntu: Write to serial port: permission denied
I've connected a USB to Serial bridge dongle, and running dmesg | grep tty outputted the following:
[ 0.000000] console [tty0] enabled
[603199.380677] usb 2-2: cp210x converter now attached to ...
4
votes
5
answers
4k
views
a safer no password sudo?
Ok, here's my problem - Please don't yell at me for being insecure! :) This is on my host machine. I'm the only one using it so it's fairly safe, but I have a very complex password that is hard to ...
146
votes
12
answers
521k
views
How to check if I have sudo access?
I recently got into trouble because of this.
$sudo vim /etc/motd
[sudo] password for bruce:
bruce is not in the sudoers file. This incident will be reported.
Is there a way to check if I have ...
63
votes
3
answers
244k
views
Command: sudo su -
I understand what su - does
logs you into root with the root environment
(as opposed to su which logs you into root with your environment)
And I understand what sudo does
you are root for one ...
62
votes
11
answers
102k
views
Run rsync with root permission on remote machine
I want to sync a folder from my machine with a folder on a remote machine. The remote folder can only be manipulated by root. I have an account on the remote machine which can use sudo. How can I run ...
54
votes
2
answers
7k
views
Where did the term "superuser" originate?
Where did the term "superuser" originate? Is it a shortening of "supervisory user", or is it just an indicator of the level of power one such user holds in a system?
43
votes
2
answers
57k
views
How to allow user to preserve environment with sudo?
I'm running into the following error trying to allow some environment variables to pass through to the new environment when running sudo:
sudo: sorry, you are not allowed to preserve the environment
...
42
votes
3
answers
62k
views
sudo without password when logged in with SSH private keys
Is it possible to make sudo command to support SSH private keys, so that when the user logins using a private key then he/she could sudo without typing a password.
This would allow storing the UNIX ...
33
votes
5
answers
49k
views
sudo sending annoying alerts: issue with defaults entries
tl;dr
Sudo causes extra, useless alerts of "problem with defaults entries"
The environment
Ubuntu 16.04 Server LTS, sudo 1.8.16
The problem
Whenever a user (whether sssd-ad authenticated user, or ...
27
votes
4
answers
44k
views
Adding a line into the hosts file, getting permission denied when using sudo - Mac
I'm trying to add a line into the hosts file on my Mac by executing a one line command on the terminal.
I thought this would be easy using sudo, but it returns "permission denied" when I try to add &...