A lot of the time I edit a file with nano, try to save and get a permission error because I forgot to run it as sudo. Is there some quick way I can become sudo without having to re-open and re-edit the file?
|
No, you can't give a running program permissions that it doesn't have when it starts, that would be the security hole known as 'privilege escalation'. Two things you can do:
Edit: See this related question for other solutions in advanced editors that allow writing the file buffer to a process pipe. |
|||||||||||||||
|
|
I just tried Here's a (basic) script that does that. It checks if you can edit the file, and if you can't, it runs "nano" as root instead. /usr/local/bin/edit (or ~/bin/edit)
And a command I called /usr/local/bin/view (or ~/bin/view)
There's already a program called Full versions |
|||||||||||||
|
vim. I'm considering the merge... though I'm also considering the fact that vim specific instructions will not work innano. – xenoterracide♦ Apr 24 '11 at 8:50nanois notvim... and nonanosolutions that are similar tovim's have presented themselves. – xenoterracide♦ Apr 25 '11 at 8:16