Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

gogreen1

macrumors 6502
Original poster
I want to create an executable file for my desktop with a command to clear the DNS cache. I can create the executable file just fine, but a sudo command, of course, requires an administrative password. Is there a different command I can use to clear the DNS cache that doesn't require a password? Thanks.
 
sudo vi /etc/sudoers

change the line:

%admin ALL = (ALL) ALL

to

%admin ALL = (ALL) ALL NOPASSWD: ALL

start a new shell.

Horrible security but it's obvious you don't care.
 
  • Like
Reactions: rmpbklyn
Just download the free "OnyX" app and run it in auto mode. One of its functions is to clear caches. It's a safe app and is currently updated to support High Sierra. Make sure you download the version that's for the version of macOS you're using.
 
  • Like
Reactions: gogreen1
sudo vi /etc/sudoers

change the line:

%admin ALL = (ALL) ALL

to

%admin ALL = (ALL) ALL NOPASSWD: ALL

start a new shell.

Horrible security but it's obvious you don't care.

It goes without saying that this would be very bad.

You can also just specify a command directly, e.g.
Code:
%admin    ALL = NOPASSWD: /usr/bin/killall -HUP mDNSResponder

Then any admin can just use:
Code:
sudo killall -HUP mDNSResponder

Without having to enter a password, but only for this specific command and only with these parameters. This could of course be further restricted, e.g. by user name.
 
OK.

Just wondering why...if you don't do it that often. I made the assumption the drive for automation was because you do it often.

I second the vote for Oynx. Lots of other handy, occasional-use house cleaning tools.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.