Thursday, April 16, 2015

Make sudo stop asking for a password

If you want ubuntu or your linux machine  to stop asking for the sudo password every time you issue a command with sudo

sudo sh -c "echo 'ALL ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"
 

Or a little safer, where feature is only for user

sudo sh -c "echo '$USER ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers"

PS: This is best suited for a personal machine and not on a server.

Add git branch name to bash prompt

When working with git branches I found it helpful if the branch was displayed in my terminal itself rather than me having to cross check
In both the approaches all we have to do is add the piece of code to our .bashrc and source it.

Steps : 

  1. Open your .bashrc file with your favorite editor
  2. gedit ~/.bashrc
    
  3. Copy and paste code snippets of any one approach
  4. source the .bashrc file
  5. source ~/.bashrc