How do I open a file in the file-manager "ranger" with superuser rights?

While ":open_with vim" opens the file as none root with vim, I am looking for something like ":open_with sudo vim", but that does not work.

2 Answers 2


According to man:

Flags give you a way to modify the behavior of the spawned process. They are used in the commands ":open_with" (key "r") and ":shell" (key "!").

   f   Fork the process.  (Run in background)
   c   Run the current file only, instead of the selection
   r   Run application with root privilege (requires sudo)
   t   Run application in a new terminal window

In your case you would need to use :open_with r vim

  • :open_with r vim worked fine for me, thanks a lot! Commented Jul 27, 2017 at 5:43
  • Thanks. For me the following commands only works by change order => :open_with vim r
    – DhineshYes
    Commented Feb 24, 2020 at 8:02

I usually open my file manager from a root terminal by simply typing in the program name with no parameters e.g.

root@machine: thunar

This will open the file manager as a root user and then anything I open to edit from the file manager is opened as the root user.

Or, if the file is easy to navigate to or name in the terminal such as "FSTAB" I just open my text editor with the named file such as

root@machine: mousepad /etc/fstab.

Further, if it an easy change, I simply use my terminal editor as a root user (nano in my case).

  • 2
    Starting a file manager from root terminal is a rather risky option IMO, since you can then delete and edit virtually anything without any warnings. Especially if the FM doesn't give you any clue that it was started from under root and you forget about it later!
    – Artalus
    Commented Jul 24, 2017 at 19:40
  • @Artalus Good call. I can admit I am not a system admin for more than our own business and I open a small fraction of config files that a real admin does so I can have a lower proficiency and still make less total number of mistakes than a real admin and still work on the wild side. It also helps we have VMs both mirrored and backed up.
    – Damon
    Commented Jul 24, 2017 at 23:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .