Use pwd
command for current directory
The pwd
command returns the current directory so you can embed it in your command line:
gedit admin://$(pwd)/rootfilename
Choose a different method
As this question Which best practice for using gedit as root? points out:
My researchs brought me these proposals, are they equivalent or to be
rejected :
You are using option 2 but I prefer option 4 sudo -H gedit
which allows relative path when editing a root owned file.
Edit directly from Nautilus
If you are using Nautilus consider the extension Edit as Administrator which dramatically improves your workflow:

Use your user profile for gedit
The problem with gedit
as root is you loose your theme colors, font size, tab settings, line wrap settings, and plug-ins. I wrote a script called sgedit
(sudo gedit) that solves that problem.
In the animation below the gedit plug-in shows thumbnail overview of document on the right pane. Grab the slider mini-window with a mouse Left Click and drag it down to quickly locate sections in the document.
Other user settings for theme, font size, line wrapping, tab stop settings, convert tabs to spaces, and all your regular user profile plug-ins are available when running as sudo
.

sudo gedit
and instead should move to usegedit admin:
. Hence, I would like to better understand how to use thegedit admin:
syntax. Are you able to help? – Sun Bear Nov 23 '19 at 14:07sudo
then usesudo -H gedit ubuntu.css
. The-H
option solves the problem of messed up your personal gedit config files caused by using plainsudo
. – user68186 Nov 23 '19 at 14:26sudo -H gedit
as compared togedit admin://
. – Sun Bear Nov 23 '19 at 15:07-H
option. – user68186 Nov 23 '19 at 15:13gedit
preferences specifically. In any case, I am looking towards better understanding how to usegedit admin://
w/o typing the full path when I am already in the cwd withubuntu.css
. Can you point the way to answer my question or that can help better understand theadmin
command? I can't find references that explainadmin
. I have noticed that it usespkexec
to open the file. This is unlikesudo
. – Sun Bear Nov 23 '19 at 15:27pkexec
and theadmin://
prefix to answer your question. I tried a few variation of what you are trying to do and they didn't work for me either. So, I can't answer your question. – user68186 Nov 23 '19 at 15:32gedit admin://$(pwd)/ubuntu.css
to work. If it works you could easily create an alias or wrapper script to make it even easier to use. – Lienhart Woitok Nov 23 '19 at 17:18admin ://
cmd (if you can)? I will accept it thereafter. Thanks again. – Sun Bear Nov 23 '19 at 17:35