How to use SUDO without password

 

sudo cartoon

We all know the sudo command, the «safe» substitute for su, and we have talked a lot in this blog about it, and about the advantages of using sudo vs su, but this time we are going to show you, for those who don't know it yet, a simple tutorial step by step of how to use this tool without having to enter a password for it. For the newbies, say that its function is to authenticate you as superuser or root temporarily to perform certain administration actions that require privileges without the need to open a session as root with the risks that this could entail.

Well, we all know that entering sudo on the command line, usually followed by the commands we want to use with privilegesAs it can be an installation of a package using a package manager, the system immediately throws us a prompt so that we can enter a password to obtain said privileges and execute the command. But ... what if we didn't have to enter the password?

That's what our mini-tutorial is about and the steps they are very simple:

  • Execute the following command to modify the file / Etc / sudoers:
sudo visudo

  • Now in the content of said file you must attempting the line containing:
root ALL=(ALL) ALL

  • And enter the following store, replacing the username with yours:

 

nombre_usuario ALL=(ALL) NOPASSWD: ALL

  • Now we save the changes and it will not ask us the password the next time we run sudo from our account ...

Is this recommended? Not, do it at your own risk, but some users, for convenience or for any other reason, may need to delete this password request every time they run sudo ... By the way, if you want a less radical solution, you can modify the grace time that sudo waits for ask for the password again (you may have noticed that when you run sudo several times in a row, it doesn't always ask for the password). This grace time can be reduced or extended, and perhaps if you are going to execute many tasks in a row it is more advisable to do that than not remove the password directly. They are just ideas!


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

8 comments, leave yours

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Predatux said

    It doesn't work for me ... I use Kubuntu 12.04
    I had already tried it before, since I have a computer in the living room that I use as a media center, and it is operated from the sofa. I had created a script to update the vlc and some other little thing, and I wanted it not to ask me for the password (so I don't have to go to open the closet where I have the keyboard), and I never got it to work.

    1.    dok said

      I think it is more convenient for what you are looking to do, assign a task to cron as root that executes that script. That is, you run crontab -e and add something like:
      0 0 * * * root /yourfolder/script.sh

      In this example it would run every day at 12 at night. Greetings

    2.    dok said

      Use cron by running the script as root, with "crontab -e" and put something like:
      0 0 * * * root /mydir/script.sh

      I would run this example every day at 12 at night. Greetings

      1.    Predatux said

        It is also another option ... thank you

  2.   Orlando Trivino said

    Mr. or Mr. LinuxAdictos.
    A cordial greeting from a recipient of your news.
    My interest is to get fully involved with free software -Linux -
    but I don't know where or from where and how to start. I request any recommendation or suggestion since I have always wanted to be a user and more than just be an expert in this software. I hope you know how to direct me to establish the respective bases in this line.
    I anticipate my thanks for your collaboration and help.
    Sincerely,
    Orlando Trivno

  3.   D'Artagnan said

    I think it would be a bad habit that could end up being reckless, modifying the / etc / sudoers. Whoever designed the system already did so so that the terminal did not reflect the root user and after a while if you want to perform administrator work again, the system asks you for the password. I myself sometimes (badly done by the way) to modify the system in the terminal I throw the command: sudo -s and after throwing the password I am already root permanently.

  4.   Carlos said

    Hi! my problem is that the terminal does NOT let me type anything when asking for the password):

    1.    George Pig said

      If it lets you but it's a security system it doesn't let you see what you write. But really if you're writing

bool (true)