Search code examples
emacsdiredchown

Dired: how to do chown as superuser?


I'm working on a code I checked from remote repository, where some of it went into that repo having "root" as the file owner. Now I want to move the directory containing the repo to another place, but deleting old files fails under regular user. Also dired-do-chown fails because I need to be root to change the file owner.

Is there any way to call dired commands as root? (like tramp for finding files)


Solution

  • Yes, just type /sudo:root@localhost/... when C-x C-f asks you for file name. This will open a trampified dired where dired-do-chown and other dired commands work just fine.

    (Note that you can press TAB after /sudo:, and minibuffer completion will insert the @localhost boilerplate.)