Questions tagged [visudo]

visudo edits the sudoers file in a safe fashion

visudo is a command-line utility that allows editing of the /etc/sudoers file in a safe fashion. It opens /etc/sudoers, using the vi editor's interface by default (although this can be changed by setting the shell's EDITOR environment variable to a different text editor), prevents multiple simultaneous edits with locks, performs sanity checks and checks for parse errors.

Source: [Wikipedia] - visudo (command)

89 questions
320
votes
18 answers

How to modify an invalid '/etc/sudoers' file?

How do I edit an invalid sudoers file? It throws the below error and it's not allowing me to edit again to fix it. Here is what happens: $ sudo visudo >>> /etc/sudoers: syntax error near line 28 <<< sudo: parse error in /etc/sudoers near line…
user25165
226
votes
2 answers

How to change visudo editor from nano to vim?

When I use visudo, it always opens it with nano editor. How to change the editor to vim?
dedunu
  • 9,556
48
votes
3 answers

What are the differences between sudo, su, visudo, chroot, and gksu?

What are the differences between sudo, su, visudo, chroot, and gksu ?
lambda23
  • 3,362
39
votes
4 answers

Change the default editor when sudo visudo

When doing sudo visudo, the default editor is nano. I want to change it to vi or vim. I already made vim the default editor, and use it as a substitute for gedit to open php, .txt, .c and .h files, by placing a vim.desktop file in…
Cbhihe
  • 2,801
  • 3
  • 27
  • 47
18
votes
1 answer

Get email notification for using 'sudo' by a specific user

I have a server set-up and I let somebody that I trust with a little bit of sudo access have it. However, I also want an email anytime that they use sudo. I know that I can use Defaults mail_always to get an email anytime ANYONE tries to use…
user323419
12
votes
3 answers

Why I must use 'visudo' to edit the '/etc/sudoers' file?

In /etc/sudoers, it says: # This file MUST be edited with the 'visudo' command as root. My question is, why must this file be edited with visudo? It seems I was able to edit the file successfully with gedit, by issuing: sudo gedit /etc/sudoers If…
Tosh
  • 429
8
votes
1 answer

Difference between "select-editor" and "update-alternatives --config editor"

I'm looking at how Ubuntu selects a default editor, and I notice that to set the default editor for editing crontabs, I use select-editor while to set the default editor for visudo I use update-alternatives --config editor. Does anyone know the…
geckels1
  • 183
7
votes
1 answer

How disable mysql command in sudoers file?

How can I disable /usr/bin/mysql command in sudoers file? I've tried to use it this way: %tailonly ALL=!/usr/bin/mysql But when I access user 'tailonly' of group 'tailonly', this command is still enabled. In short, I only want that 'tailonly' user…
Carlos Spohr
  • 193
  • 3
  • 10
6
votes
2 answers

How to see what pkaction a software uses

So, I have one software that always asks for password when starting. And I want to run this software without this gksu password prompt popping up everytime. The first thing I tried was adding its path to sudoers. However, that didn't work. Later I…
PKM
  • 839
4
votes
1 answer

systemctl still asking for password even with sudoers

My /etc/sudoers josh ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart servicename.service running systemctl restart servicename.service still asks for password. Does anyone have any ideas? Running command: locate systemctl shows it located here:…
Josh
  • 125
4
votes
1 answer

user not in sudo group but can perform sudo operations

Is this normal behaviour when I put a user student in sudoers file using visudo command like this : visudo student ALL = NOPASSWD: ALL And he is not in sudo group but can still perform sudo operations ? So if a user is decribed in sudoers…
Tomas.R
  • 433
4
votes
1 answer

Add user to sudoers

I want to add a user account to sudoers. I type in sudo usermod -aG sudo username Then I reboot. I type apt update I get permission denied. I type sudo apt update Followed by account password and apt update runs. I thought that adding…
3
votes
4 answers

Change in sudoers does not take effect. Ubuntu 16.10 fresh install + one line.

Trying to remove password on sudo. My current sudoers file: Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin" root ALL=(ALL:ALL)…
Vidar
  • 41
3
votes
2 answers

Certain commands not working for a user with sudo after adding to `sudoers` file

I cannot seem to allow the user (In this case Ruby) to run sudo rm -rf, sudo rmdir, or sudo mkdir. I have tried it with other commands and it works fine allowing that user to run sudo apt-get update it just does not work allowing them to do those…
Alex Lowe
  • 471
3
votes
1 answer

Explanation of visudo lock file

When I edit /etc/sudoers using visudo, I think it saves to sudoers.tmp, checks it for errors, then copies it to the real /etc/sudoers. However, I can't confirm my theory (how the lock file is used) in the man…
Tosh
  • 429
1
2 3 4 5 6