I know I could just put something like sudo mypassword in my .bash_profile, but I don't want to run every command as root.
I want password to autofill under following circumstances:
- only the commands requiring root privileges
- only commands that I explicitly state I plan to run su to root with
sudo
Example:
sudo cd /var/root #When I type this
Password: #I don't want to be prompted for my password
#I want to fill it from my `.bash_profile`
But:
cd /var/root #When I type this
-bash: cd: /var/root: Permission denied #I still want this, or the like, returned
I saw this post on increasing sudo timeout, but I don't think it's quite equivalent. For example, I want it to carry across different shell log-in sessions. I could be wrong.
Any suggestions regarding what to (or not to!) add to my .bash_profile, or which method (timeout vs profile) is preferable would be greatly appreciated! Thank you in advance.
/etc/sudoersvisudoto edit the sudoers file.man sudo- or just read the comments in your/etc/sudoers. and by the way, if there is a directory on your disk into which cannotcd- then proably nobody should. dols dirthencat ./dir/tgt.filestay out of there - root user or otherwise.sudo cd /var/rootdoesn't do anything useful, because a subprocess can't change the directory of its parent.