When I need to edit files with superuser privileges, like those in etc directory, I used to do:

$ sudo vim /etc/hosts

This launches the editor with root privileges.

I recently learnt that there is a safer and more elegant way do this: using sudoedit. This makes a temporary copy of the file you want to edit in /tmp and opens it in your favorite editor with normal user privileges. After you save the file, the original file is replaced with the updated copy.

To do this:

$ sudoedit /etc/hosts

Or equivalently:

$ sudo -e /etc/hosts

Tried with: Ubuntu 14.04

One thought on “sudoedit”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s