I am trying to edit the file /etc/postfix/main.cf
but this applies to any file.
Currently its permission bits are set to -rw-r--r--
I want to open, edit and save this file when operating as a regular user in emacs. However, try as I might, I just can not do it. Here are the options I have tried.
First I tried this method: C-x C -q
This allows me to edit the buffer well enough, but when I try to save the buffer I am presented with: File main.cf is write-protected; try to save anyway? (yes or no)
and when I type yes
I get:
Doing chmod: operation not permitted, /etc/postfix/main.cf
Similarly, if I try M-! chmod u+w main.cf
at any point I get the message:
chmod: changing permissions of 'main.cf': Operation not permitted
Lastly if I try to edit the file in wdired
with wdired-allow-to-change-permissions
I get
chmod 664 '/etc/postfix/main.cf' failed
Emacs is so powerful it seems like there must be a way to do this without using
the /sudo::/filename
trick mentioned here
Additionally, I think there should be a "permissions" tag here in emacs stack overflow.