My problem is the following: I want to edit a file that is only readable by root. That's why I use
sudo vim ~/thefile
I could type
sudo -K
after exiting vim, but I was hoping that there's an option or something that makes sudo forget the password automatically. Of course I thought about editing the sudoers file and setting the timeout to 0, but I don't want to change the settings in general. I also found nothing in the manpage...
Is there a way to do this?
If interesting: I'm using Ubuntu 12.04 and bash.
function sudok () { sudo "$@"; sudo -K; }
– Mark Plotnick Feb 25 '15 at 16:37~/.bashrc
or~/.bash_aliases
. This will make it only available to your user account which sounds like what you want. If you want every user on the system to have access tosudok
then put it in/etc/bash.bashrc
. – EarlCrapstone Feb 25 '15 at 18:02sudoedit
instead ofsudo vim
. You don't need the editor to run as root. – Gilles 'SO- stop being evil' Feb 25 '15 at 23:37