You are missing the point of sudoedit, but the manual doesn't explain it so fret not.
Most editors have shell escapes, for example :shell
in vim which would allow you to gain a root shell even though you might not have such permission under sudo. This is called "privilege escalation" and is a Bad Thing.
The sudoedit
command does the equivalent of:
# cp source-file /tmp/some-temporary-name
$ ${EDITOR} /tmp/some-temporary-name
# cp /tmp/some-temporary-name source-file
# rm /tmp/some-temporary-name
Note that the editor is run as you, not root, so you cannot use the editor for privilege escalation.
If you have very permissive sudo rights (as is often the case on single user machines depending on the distribution) you can
$ sudo vim source-file
to get the behavior you want.
sudo
anyway. – Ben Sep 17 '13 at 10:42Ctrl+Z
in command mode (i.e. default mode) in vim - you'll put vim in background. After you do your work, you can usefg %n
(or just%n
) with whatevern
vim gets (bash will print the number after youCtrl+Z
) to get vim back in foreground. – Ruslan Sep 17 '13 at 12:00vim
should become the current job of the shell, sofg
without arguments should work. – jofel Sep 17 '13 at 12:18%
withoutfg
. – Ruslan Sep 17 '13 at 12:36