I am trying to delete a file that is owned by root from Emacs dired opened as a regular user.

I get the following error:

(file-error Removing old name Permission denied /opt/file)

How can I execute this command with root privileges?

  • There is a package called dired-toggle-sudo Commented Feb 4, 2018 at 6:04

2 Answers 2


Use Tramp. Instead of running dired in /opt, run it in /sudo::/opt. This gives you root permissions.


Put the cursor on the line with the file and type: ! sudo rm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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