Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Catch 22: If I open my text editor without using sudo, I don't have permission to save any changes. If I open it with root privileges, any files I create are owned by root. I want to be able to create files that are owned by me (non-root user), and also edit files that require root access in the same session. Possible? Is this a Linux thing or a text editor setting?

I'm using Sublime Text 2.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

If you use sudoedit to edit your root-owned text files, then your editor will be running as you. Sudoedit works by making a temporary copy of the root-owned file(s), owned by you, and invoking your editor (chosen via $SUDO_EDITOR, $VISUAL, $EDITOR, or the sudoers config file) on it. When you quit the editor, it copies the temporary file(s) back if they're modified. Full details are in the man page.

share|improve this answer

This is more a text editor thing, in that you add that capability through an additional package or plug-in. I know it is possible in emacs (with tramp) and gEdit (with beesu-plugin). I'm not familiar with Sublime Text but I guess it could be possible with the right plug-in.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.