How to open a file in ranger as root?
6,343
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
Related videos on Youtube
![PatrickSteiner](https://i.stack.imgur.com/EYaKY.jpg?s=256&g=1)
Author by
PatrickSteiner
Preferred OS: Linux Mint 18.3 Sylvia Occupation: Computer Science Student
Updated on September 18, 2022Comments
-
PatrickSteiner almost 2 years
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.
-
Artalus almost 7 yearsStarting 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!
-
Damon almost 7 years@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.
-
PatrickSteiner almost 7 years
:open_with r vim
worked fine for me, thanks a lot! -
DhineshYes over 4 yearsThanks. For me the following commands only works by change order => :open_with vim r