Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Inspired by this question....

I am the sole person using my system with 12.04.
Every time I issue a sudo command; the system asks for the user password (which is good in its own way).
However I was thinking; without activating the root account; how can I execute the sudo commands which will not ask for user password to authenticate.

NOTE: I want to execute sudo command without authenticating via password; only when they are executed via terminal.
I don't want to remove this extra layer of security from other functions such a while using 'Ubuntu software center' or executing a bash script by drag-drop something.sh file to the terminal.

share|improve this question
1  
so you only want to be asked for the password in the terminal and for other things not, or the other way arround?! in both ways, I think its a high security breach – Dr_Bunsen Jun 6 '12 at 12:33
I want that system may not ask password only when in the terminal... for any other purpose the system must ask a password. This requirement is only temporary, and to be used while configuring n installing new servers.. during fresh server installations, it really take hours of configuring with sudo commands.. issuing password every 15 min. is headache. I don't want to use root account. – Z9iT Jun 6 '12 at 12:44
You need to read the discussion in: askubuntu.com/questions/135428/… – david6 Jun 9 '12 at 1:18

3 Answers

up vote 5 down vote accepted

sudo -i is the way to go if you don't want to be typing a password every 10 mins while doing modifications in your system (or other systems), and you don't want to modify any system files.

It will switch you to root using your sudo user password, when you close the console or type exit you are back to your normal user.

share|improve this answer
Will this hold true that I enter password only once... and till the time I don't exit; weather 5 hrs. or 15.... the system wont ask for authentication by password when any sudo command is issued. – Z9iT Jun 7 '12 at 21:10
How is it different form activating and using the root account ???? – Z9iT Jun 7 '12 at 21:12
@Z9iT Because you don't actually activate anything or change the root´s user password, there is no system modification at all except you login to a root shell allowing you to do stuff without typing sudo foo all the time. If thats all you want (to be able to type commands without using sudo all the time) and you want 0 modifications to your system this is the way to go imho. – Bruno Pereira Jun 8 '12 at 8:29
1  
@Z9iT until you type exit or until you close the terminal emulator window. – Bruno Pereira Jun 8 '12 at 8:33
Thanks.. Accepted this answer because it servers the purpose of issuing sudo commands without password authentication for n-hours till the time we won't exit.. Not modifying system files is a plus. – Z9iT Jun 8 '12 at 9:58

The approach to solve your problem is to put your user in sudoers file, like you can see.

Open terminal window and type:

sudo visudo

In the bottom of the file, type the follow:

username ALL=(ALL) NOPASSWD: ALL

Where username is your username in your system. Save and close sudoers file (if you haven't changed your default terminal editor (you'll know if you have), press ctl+x to exit nano (but note that the screenshot below shows vim), and it'll prompt you to save).

enter image description here

After this, you can, in terminal window, type sudo <Whatever you want>, without being prompted for the password.

This only applies, to sudo command in terminal window. For example, when you try to install a package in software center, you will be prompted to insert your password, like you can see in the next Screenshot.

enter image description here

I think this is what you want.

share|improve this answer
3  
It's recommended to use sudo visudo instead of editing it directly. Also changing the permissions of the sudoers may lock yourself out. When editing with vim, use :wq! to write to read-only files and quit the editor. In that way, permissions 644 are not necessary. – Lekensteyn Jun 6 '12 at 13:49
Thanks for your response. What workout you suggest for the statement by @Lekensteyn – Z9iT Jun 7 '12 at 21:06

Of course what you want to do isn't recommended. After a while, though entering sudo becomes so automatic that its usefulness diminishes.

Another approach is to leave your sudoers file as is and, while doing something complicated to your umpteen hundred servers, enter sudo bash . That will give you a shell that will be authenticated as root until you exit it.

share|improve this answer
sudo -s or sudo -i are probably both better ideas than sudo bash, because they ensure the environment is sane and things. – Darael Jun 27 '12 at 20:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.