3

I'm using Aquamacs to do most of my text editing, and would like to, selectively, open some files as root when editing them.

Is there a way for me to open some files as root with Aquamacs (and not the rest)?

I know that I can just start Aquamacs with a sudo command, but that's a bit too risky for me - I'd rather only have root permissions for editing files which absolutely require it.

giordano
  • 8,087
  • 3
  • 23
  • 48
blueberryfields
  • 45,910
  • 28
  • 89
  • 168
  • 3
    `C-x C-f /sudo::/path/to/file` – giordano Jun 27 '13 at 22:13
  • I'm getting an error due to the second : in that command, telling me that the command is invalid, and the single colon version doesn't seem to escalate (it keeps telling me the file I'm editing is read-only) – blueberryfields Jun 27 '13 at 22:38
  • What error exactly? Which version of Aquamacs (or Emacs) are you using? The single colon version is simply wrong, TRAMP syntax requires two colons. – giordano Jun 27 '13 at 22:40
  • Ah, I see. I had a typo in my command. After correcting, I'm being prompted for my root pwd, but the file opens up as read-only anyways. It may be a read-only file to begin with - is that something I can override with aquamacs? – blueberryfields Jun 27 '13 at 22:49
  • Ah. http://stackoverflow.com/questions/180910/how-do-i-change-read-write-mode-for-a-file-using-emacs. Mind putting your comment in as an answer? – blueberryfields Jun 27 '13 at 22:54

1 Answers1

6

You can open a file as root using TRAMP (bundled with Emacs since version 22.1):

C-x C-f /sudo:root@localhost:/path/to/file RET

If you don't insert the username@host part, TRAMP defaults to root@localhost when using /sudo, so you can shorten the syntax to

C-x C-f /sudo::/path/to/file RET

giordano
  • 8,087
  • 3
  • 23
  • 48