Hot answers tagged

14 votes
Accepted

Difference between sudo -e and sudo vim?

The big difference is who is editing what file. With sudo vim (assuming successful authentication), the root user invokes vim and edits the file in place (with root's environment and vim swap files ...
user avatar
  • 224
7 votes

Difference between sudo -e and sudo vim?

There’s one key difference: with sudo -e, the editor runs as your user, not as root; with sudo vim, the editor runs as root. This has a number of consequences; one of them is that with sudo -e, you’ll ...
user avatar
3 votes

How to add echo write commands to sudoers

It looks like sudo is having problems with arguments that contain quotes or whitespace. There may be a syntactically correct way of dealing with this, but the simplest solution is to move the shell ...
user avatar
  • 26.1k
3 votes

How come I am able to use sudo without being in sudoers?

In cloud environments, many distributions (including CentOS 7) use cloud-init to configure the system when it first boots. If we look at /etc/cloud/cloud.cfg on the CentOS 7 cloud image, we find: ...
user avatar
  • 26.1k
2 votes

Is there a way to run a script every time `sudo` is run?

In view of the PAM integration suggested by mesr, an alternative I see would be to configure your sudo to log via syslog using a unique identifier and have your system's rsyslog/syslog-ng invoke an ...
user avatar
  • 1,091
2 votes

Is there a way to run a script every time `sudo` is run?

Answering the question literally: yes, there is such a way, by virtue of sudo's (the sudoers plugin, more exactly) integration with PAM. Simply add a line that calls pam_exec.so in /etc/pam.d/sudo, at ...
user avatar
  • 137
2 votes

Ignore sudo for each command

A simple no-op passthrough script would be: #!/bin/sh "$@" It just takes the arguments it's given, and runs a command using them, using the first one as the command name. So if installed as ...
user avatar
  • 120k
2 votes

How to add echo write commands to sudoers

sudo does not treat ' and " specially when used as arguments for a command. You can see this if you use sudo -ll to list what sudo has parsed. For your example it will say /bin/sh -c 'echo 1 > ...
user avatar
  • 45.7k
2 votes

Is there ever a good reason to add users to the "root" group?

Unlike the root user, the root group does not bring any inherent powers or privileges. So any special permissions you get from group root are because of group permissions on files in the root group, ...
user avatar
  • 3,313
1 vote

apt autoremove and autoclean without root

Yes, most apt-get commands need to be run as root, including autoremove and autoclean. With your configuration, that means sudo apt-get autoremove Note that allowing users to run any apt-get command ...
user avatar
1 vote

Sudo Command Not Found for Plesk User

You don't need to do any of this. If the objective is to run a cronjob as this user, all you need to do is add an entry to /etc/crontab. This file has an extra field that normal per-user crontabs don'...
user avatar
  • 219k
1 vote
Accepted

How to access an enviroment variable of `$SUDO_USER`'s within a shell script?

To use option -E, --preserve-env with sudo to carry the environment. For example sudo -E ./test.sh. Please note to allow any environment is not encouraged. Please refer to Command environment section ...
user avatar
  • 223
1 vote
Accepted

How to add echo write commands to sudoers

Alternative way is allowing tee such file in sudoers username ALL = NOPASSWD: /bin/tee sys/devices/system/cpu/intel_pstate/no_turbo Then using | sudo tee instead of > echo 1 | sudo tee /sys/...
user avatar
  • 223
1 vote
Accepted

Ignore sudo for each command

You can try to set an alias like this: alias sudo=""
user avatar
  • 164

Only top scored, non community-wiki answers of a minimum length are eligible