Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to change the write permissions on a file from inside emacs, without killing/re-opening the buffer?

Sometimes I forget to modify the permissions on a file before opening it. I can modify the permissions from inside emacs (M-! chmod u+w filename) but this doesn't update the buffer which remains write protected and refuses to modify the file.

Is there a way to update permissions inside the buffer? Bonus point if I can assign this to a shortcut!

share|improve this question
up vote 7 down vote accepted

After changing the file mode, and before doing any edit, run M-x revert-buffer to reload the file. If the file is now writable, the buffer will no longer be read-only.

Alternatively, type C-x C-q (toggle-read-only). This makes the buffer no longer read-only. You can edit and even save, but you'll get a confirmation prompt asking whether you want to overwrite the read-only file.

share|improve this answer

To change the read-only status of a buffer, use C-xC-q (toggle-read-only). To file permissions, you can run dired on the file's directory (C-xd), search for the file by C-s and use M to change its mode.

share|improve this answer
Apparently, you've missed dired-jump (normally bound to C-x C-j). It runs dired and jumps to the line for the file you're editing. – cjm Sep 10 '12 at 16:33
@cjm: It does not work for me unless I load dired-x. – choroba Sep 10 '12 at 16:47
Sorry, I'd forgotten that I'd set up an autoload for dired-jump about 20 years ago. I recommend it. – cjm Sep 10 '12 at 17:04

Your Answer


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.