solitude@Solitude:~/Desktop$ sudo gedit ~/.bashrc
error: XDG_RUNTIME_DIR not set in the environment.
(gedit:12631): Gtk-WARNING **: cannot open display:
Asked
Active
Viewed 4,046 times
0

Zanna
- 70,465

Varun Sahdev
- 21
1 Answers
2
You should never use normal sudo to start graphical applications as root. For a complete explanation of this read the answers to this question: Why should users never use normal sudo to start graphical applications?.
Nautilus Admin (nautilus-admin) is a simple Python extension for the Nautilus file manager that adds some administrative actions to the right-click menu:
- Open as Administrator: opens a folder in a new Nautilus window running with administrator (root) privileges.
- Edit as Administrator: opens a file in a Gedit window running with administrator (root) privileges.
To install Nautilus Admin in all currently supported versions of Ubuntu open the terminal and type:
sudo apt install nautilus-admin
An alternative way of editing the same file is to use the system's default text editor program that is designed to run from the terminal without needing any other graphical environment.
sudoedit path/to/file

karel
- 114,770
vi
command instead ofgedit
there. – dobey Mar 28 '18 at 15:37