Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've put a command sudo do something in my ~/.bashrc, this works but everytime I open the terminal I have to type in my password. How do I make it so there is no password-typing?

share|improve this question

You can use the NOPASSWD attribute in the sudoers file to tell sudo not to require a password. A line like the follows in the sudoers file should let you run that command without a password:

yourlogin ALL=(ALL) NOPASSWD: command_here

share|improve this answer
This operation is too risky. – Hckr Nov 13 '12 at 18:50
That depends on the command run. I assume user19192 actually knows what he's doing and wants to run this :) – Dennis Kaarsemaker Nov 13 '12 at 18:51
@Hckr I think there's no risk if you have control over your script. – Evandro Silva Nov 13 '12 at 18:53
Yes, @EvandroSilva . I thought that this operation allows all scripts to be opened as root without password.Cos, I have just seen "command_here".Sorry. – Hckr Nov 13 '12 at 19:03
yeah, NOPASSWD: ALL is a different beast. Wouldn't recommend that. – Dennis Kaarsemaker Nov 13 '12 at 19:06

You can edit the sudoers file by executing the following line:

sudo gedit /etc/sudoers

add the following line to the file: your_login ALL=(ALL) NOPASSWD: command

share|improve this answer
NOTE: I generally don't encourage this option because the sudo function is built in to protect the user. no longer requiring a password is negating the purpose of it. However if you are confident it will not be a security problem then go ahead. – UbuntuHusker Nov 13 '12 at 18:51
Using gedit to edit /etc/sudoers is a recipe for disaster. If you make a typo in the sudoers file you can lock yourself out of sudoing. Always use visudo to edit: export EDITOR=gedit; sudo -E visudo – mogsie Jan 22 '14 at 12:20

Yes, it is possible.

gksudo gedit /etc/rc.local

Add before "exit 0" line:

source ~/.bashrc

Save the file.Don't forget to change your file name.

share|improve this answer

Your Answer


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.