Clear DNS cache without sudo command?

Discussion in 'Mac Basics and Help' started by gogreen1, Mar 9, 2018.

  1. gogreen1 macrumors regular

    gogreen1

    Joined:
    Nov 20, 2017
    #1
    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.
     
  2. MC6800 macrumors 6502

    Joined:
    Jun 29, 2016
    #2
    The setuid bit is the usual way to do this, but it won't work on a shell script if that's what you have.
     
  3. gogreen1 thread starter macrumors regular

    gogreen1

    Joined:
    Nov 20, 2017
    #3
    Thanks, MC6800, but this is far beyond my capability. I think I'm going to just live with clearing the cache occasionally manually.
     
  4. rmpbklyn macrumors newbie

    rmpbklyn

    Joined:
    Oct 25, 2015
    #4
  5. gogreen1 thread starter macrumors regular

    gogreen1

    Joined:
    Nov 20, 2017
    #5
    But the sudo command requires a password, right? That's what I'm trying to avoid.
     
  6. Southern_Vet macrumors newbie

    Joined:
    Mar 6, 2018
    #6
    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.
     
  7. chscag macrumors 68030

    chscag

    Joined:
    Feb 17, 2008
    Location:
    Fort Worth, Texas
    #7
    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.
     
  8. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #8
    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.
     
  9. gogreen1 thread starter macrumors regular

    gogreen1

    Joined:
    Nov 20, 2017
    #9
    Thanks, KALLT. What about the spacing on that first code?
     
  10. hobowankenobi macrumors 6502a

    Joined:
    Aug 27, 2015
    Location:
    on the land line mr. smith.
    #10
    Just curious...

    What problem are you trying to solve by deleting DNS often?
     
  11. gogreen1 thread starter macrumors regular

    gogreen1

    Joined:
    Nov 20, 2017
    #11
    I don't clear the DNS cache often. I just want to be able to automate the task.
     
  12. hobowankenobi macrumors 6502a

    Joined:
    Aug 27, 2015
    Location:
    on the land line mr. smith.
    #12
    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.
     
  13. gogreen1 thread starter macrumors regular

    gogreen1

    Joined:
    Nov 20, 2017
    #13
    Yup. Thank you, hobowankenobi and chscag. Onyx is the way to go for what I want to do.
     

Share This Page