Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Emacs loads my .emacs.d/init.el startup file just fine when run as a regular user, but refuses to load it when run as sudo emacs file.type. I have tried changing the owner of .emacs.d to root with no success.

share|improve this question

3 Answers 3

When you run as sudo add -s to preserve your environment. It's not maintaining your environment, thus your HOME directory is lost. Emacs looks in ~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el, so if you lose HOME, you lose the pathing to your startup files.

share|improve this answer

I'm a little of topic, but you could use Emacs as a normal user, and tramp to open file as root:

C-xC-f /sudo::/path/to/file

will ask you for your sudo password, and open the file as root.

share|improve this answer

jmq is right. In alternative tricky solution. If you are the only one allowed to be sudoer or to login as root, you can add a symlink in /root/ to your .emacs.d directory. For example:

ls -l /root/.emacs
lrwxrwxrwx. 1 root root 18 May  5 11:14 /root/.emacs -> /home/<user>/.emacs
share|improve this answer

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.