Sudo without password on Ubuntu

sudo visudo

Add this line at the end (change “jerome” to your username):

jerome ALL=(ALL) NOPASSWD: ALL

Ctrl-X to leave, save your changes, and you're done!

 

Feedback

I have tried the above in an Ubuntu OS. It does not work and even with many other variations made to the sudoers file, I am always asked for a password when I execute sudo command.
Sir Percy
Dec 30, 2008
#1
Which version of Ubuntu are you using? It flawlessly works from at least 7.04.
Jérôme Jaglale
Dec 30, 2008
#2
8.0x Server Version I will try your fix again on Friday. thanks
Sir Percy
Dec 30, 2008
#3
I overlooked the fact that it must be at the end of the file. In my version, the last line of code gives all users in the admin group root access but with a password required. If your line precedes this, then the effects are undone by the last line of code because my user login is also a member (unintentional) of admin.
Sir Percy
Dec 31, 2008
#4
Hi, i tried previous command and it works. I have Ubuntu Jaunty 9.04 alpha 6
Mcfee - Pablo Andres Diaz A.
Mar 24, 2009
#5
hai its working fine in Kubuntu 8.04 sudo visudo jaleel ALL=NOPASSWD: ALL save and reboot thanks a lot saitjaleel@yahoo.com
S.jaleel
Jul 9, 2009
#6
'ya dont need to reboot..
Netmonger
Jul 29, 2009
#7
%sudo ALL=NOPASSWD: ALL will also help... For me helped.
ppp0
Nov 10, 2009
#8
Not working 4 me man.I did exactly what you wrote.Here as you can see.Nothing happened. # User privilege specification root ALL=(ALL) ALL caglar ALL=(ALL)NOPASSWD: ALL # Uncomment to allow members of group sudo to not need a password # (Note that later entries override this, so you might need to move # it further down) # %sudo ALL=NOPASSWD: ALL # Members of the admin group may gain root privileges ?min ALL=(ALL) ALL
caglar
Dec 31, 2009
#9
works on Karamic 9.10. Thanks....
bijugv
Jan 14, 2010
#10
caglar - you didn't place the "caglar ALL=(ALL) NOPASSWD: ALL" at the END OF THE FILE. It works for me under Karmic 9.10. (What I actually did was place the %sudo line at the end of the file, and did a "sudo adduser sudo")
cafehunk
Jan 21, 2010
#11
This is awesome, I tried it in Linux Mint 9 (Pretty much Ubuntu 10.04 with closed source packages, and a custom menu), and it works flawlessly. I hope it also works with package installs and programs like gparted.
Izzy
May 22, 2010
#12
but, but, why? you are destroying the nice security that it brings :S
Dr Dolme
Jun 22, 2010
#13
Cant download anything or play voice messages on computer due to needing my password when I forgot a long time ago
carl Lewis
Nov 15, 2010
#14
This doesn't work! What are you talking about? HA! You DON'T know what you're talking about, you big fat $%^#ing $%^!

Nov 27, 2010
#15
WOW! THAT person has obviously gone insane! IT'S JUST A COMPUTER!
By the way - Yes, that's my real name!
Julita Altagracia Maria Teresa Alvarez Tavares Perello Espaillat Julia Perez Rochet Gonzalez
Nov 27, 2010
#16
Correct. Eliminating sudo is the biggest security threat you can ever do to your system; especially a server. Awful practice.
avgvstvs
Jan 4, 2011
#17
Security? Maybe if your brother is attacking your system by slipping in while you go to the bathroom. If an attacker has access to YOUR account and you have root permission you are already screwed. What no password sudo gives to a desktop is that you can ease the burden of administration slightly. For a multi-user system it is a bad idea since the commands you issue as root will affect the work of others. Thus, the password prompt is a fine indicator that you should think twice.
L
Jan 15, 2011
#18
The password prompt is indeed a good indicator of the severity of your actions. Nullifying the use of a password is a security risk. While entering your password every time is cumbersome, it is possible to set the password timeout higher (add Defaults passwd_timeout=10 to /etc/sudoers using the command sudo visudo)*. This would dissuade intrusion, unless the attacker has physical access. No measure of security can overcome PEBKAC.

*this tip from ubuntuforums thread 229309
daakadence
Jan 27, 2011
#19
thanx cafehunk for your suggestion! I was stuck with this issue for a while..
Shubham
Mar 8, 2011
#20
works in ubuntu 11.04 beta2
<3ubuntu
Apr 25, 2011
#21
Consider keeping an open shell/editor session su'd as root while you experiment so that you don't accidentally lock everyone out of being able to sudo (and consequently have no way of reverting the change!). #LFMF
Phoenix
May 2, 2011
#22
cool
saurabh
May 17, 2011
#23
Nice
Core
Jul 17, 2011
#24
Although there is a small security issue with removing passwords from sudo, there is a much bigger security issue... passwords themselves. Password re-use is a bigger problem than password entrapy. Most people have less than 5 passwords but use 100+ websites and other PCs.

My home PC has a password to log in with a keyboard, but as soon as I find a way to do log in with a dongle, I'm going to remove password access all togeather. All servers such as SVN and PostgreSQL on my PC are OS user based.
Phil
Jul 21, 2011
#25
Works fine........ gr8 Tip. Helped me alot
Laxminarayana
Aug 5, 2011
#26
faltou antes chmod +w /etc/sudoers
acrecenta a linha
e chmod-w /etc/sudoers
charles
Aug 8, 2011
#27
Works with Ubuntu 11.04 Desktop i386.
tobascoman
Aug 11, 2011
#28
PS remember to change it back, otherwise you have a security issue. If you read this tip in the wrong place maybe your IP address and who knows your login name as well are now out there.
Would you leave your hall door open while playing in the back garden with your dog? - hm, maybe you don't have a garden; maybe you don't have a dog ; maybe you don't have a hall door :-)
tobascoman
Aug 11, 2011
#29
The technique work on OS X, too. Maybe it works on all *nix-like OSes with /etc/sudoers files? Anyway, OS X has prototype lines in the file clearly commented like, "Uncomment to allow all people in group wheel to run all commands". There are other ones for per user, etc. Makes it easy to eliminate security. Who cares about security, anyway? Don't you leave your front door open? i do.
AK
Sep 12, 2011
#30
Very important! Add it at the END of the file!

It doesn't work if you add it at the top.

READ.
Dagelf
Nov 13, 2011
#31
thank you..it works fine
aj
Nov 15, 2011
#32
Thanks, very helpful. I use an Ubuntu virtual machine to record screencasts and with this I don't have to enter my password all the time during recordings.
Stefan
Dec 13, 2011
#33
NEVER edit /etc/visudo directly, as charles suggested. If you do something wrong, which creates a syntax error, then you can't use sudo to change it back... Use visudu to change that file, it checks for syntax errors and warn you if needed. (One syntax error is if there is no empty line after the last line, but there are also other syntax errors.)

A better idea is to specify those commands you want to run without password, and have sudo ask for password for other commands.

username ALL=NOPASSWD: /usr/bin/apt-get
visudo
Dec 24, 2011
#34
No a member just stumbled accross the thread & had to give props for the only honesy accurate advice Ive heard yrt ! Some people seem to think there GOD of the info of somethin ? We all started somewhere ~ Cheers
ThaddeusCanada
Jan 24, 2012
#35
walterpops01@aim is my most reg e.mail if either of you wanna pass along any more insightful advice of reccommendations ? My nex project is a full WIPE, SCAN, PARTITION, & Running several O.S. and obviouly some more indepth details I know I need advice !
ThaddeusCanada
Jan 24, 2012
#36
????? ???? ??? ??? ????????
Thank you very much for this information
????
Feb 1, 2012
#37
Works perfectly!
Linux mint 13 MATE
Sean
Jul 15, 2012
#38
It worked for me .. thanks
sunil
Aug 5, 2012
#39
@visudo : that never works for me. it's NOPASSWD=ALL or nothing.
anon
Sep 12, 2012
#40
Or you could just do what I did and write a package managing script that injects NOPASSWD=ALL into /etc/sudoers for the duration of functions then changes /etc/sudoers back to original upon exit.
DebFan
Dec 31, 2012
#41
I was able to run it on Ubuntu 12.10 to do you should

1. create a script inside the directory /etc/sudoers.d and name the file as XX_someName where XX is a numeric value. Eg 99_aptget
2. inside the file include the line
someUser ALL = NOPASSWD: /usr/bin/apt-get

3. change the mode to 0440
eg. chmod 0440 99_apt_get

You should now be able to run it.
aaaa
Feb 19, 2013
#42
Not working for me :-( How do you use it? I set the user dimi, but when I login via ssh I cannot sudo.. :-(

ex.:
bash-4.1$ sudo --help
bash: sudo: command not found

please help
dimi
Mar 6, 2013
#43
I think I just made it with another user. I still dont know why the user dimi cannot execute the sudo comand but the other user does. However, this solution is OK for me so far.
dimi
Mar 6, 2013
#44
this works for all versions!@!@!@!@it will remove the password on unbuntu and linux!@@!!@!@!@!@it worked it worked!!@!@@!!@!@!@!@!@ its sudo><#> 4.3 version 32.1 chirrouteantbusybox4.321ip:ALL open close sudo=false routeinre6ip3.32


type that in and replace chirroute with ur username,once done with that switch the parameters to your ip and dns listing. ANd it should work. your all welcome :)!@@!!@!@!@!@!@!@!@


-hacker
-hacker
Jun 6, 2013
#45
how do i get ubuntu12.10 off a dell inspiron 1525 laptop with a password . what command do i type in after " grub>"?
bal
Nov 23, 2013
#46
It works!
Santiago J. Valls
Dec 5, 2013
#47
Thanks!
Marc Christenfeldt
Mar 13, 2014
#48
It worked for me, running Lint Mint 13 =)

Apr 24, 2014
#49
12.04, just add the line at the end.

Thanks alot

Jun 14, 2014
#50
Still works wonderfully on latest ubuntu.
Zeus Of Lightning
Jun 24, 2014
#51