I am trying to prevent bash to ask for sudo permission to run the port command (OSX packet manager) adding it to visudo. I basically tried to follow this SO thread but I still get an error
manfredo@cave05:~$ port selfupdate
---> Updating MacPorts base sources using rsync
Error: Error synchronizing MacPorts sources: command execution failed
Please run `port -v selfupdate' for details.
Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed
The same selfupdate command runs smoothly if I sudo it.
My visudo has the following lines
# User privilege specification
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL
%admin ALL=(ALL) NOPASSWD: /opt/local/bin/port
and I also tried susbtituitng the last line with
<user_name> ALL=(ALL) NOPASSWD: /opt/local/bin/port
What am I missing? Also can someone explain the syntax of the last line of the visudo file.
You actually want to achieve two things:
1. Making it possible to run
sudo portwithout the need to enter a password.You already solved that by adding the following line to
/etc/sudoers:2. Making it possible to run
sudo portwithout the need to explicitely typesudoThis can be done by an shell alias. Since the question is tagged
bashI assume your shell is bash. In that case modify your.bashrcand add the following line:Start a new shell and it should work.