I used sudoedit
to create a file:
$ sudoedit /etc/systemd/system/apache2.service
but when I went to save the file, it wrote it in a temporary directory (/var/temp/blahblah). What is going on? Why is it not saving it to the system directory?
sudoedit
I used sudoedit
to create a file:
$ sudoedit /etc/systemd/system/apache2.service
but when I went to save the file, it wrote it in a temporary directory (/var/temp/blahblah). What is going on? Why is it not saving it to the system directory?
Best Answer
The point of
sudoedit
is to allow users to edit files they wouldn’t otherwise be allowed to, while running an unprivileged editor. To make this happen,sudoedit
copies the file to be edited to a temporary location, makes it writable by the requesting user, and opens it in the configured editor. That’s why the editor shows an unrelated filename in a temporary directory. When the editor exits,sudoedit
checks whether any changes were really made, and copies the changed temporary file back to its original location if necessary.