Results 1 to 8 of 8

Thread: Which best practice for using gedit as root?

  1. #1
    Join Date
    May 2015
    Beans
    6

    Which best practice for using gedit as root?

    gksudo seeming to be somehow depreciated since 2017 as I see on the french forum documentation, is there an environment and version agnostic best practice allowing to use gedit as root?

    (excluding vim, nano or tee: the use case being a GUI amendment of sources.list for instance)

    My researchs brought me these proposals, are they equivalent or to be rejected :

    • pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit
    • gedit admin:///path/to/file
    • sudo -i gedit
    • sudo -H gedit



    Any other ?
    Last edited by amauryat; February 25th, 2018 at 06:46 PM.

  2. #2
    Join Date
    Feb 2008
    Location
    Texas
    Beans
    29,836
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Which best practice for using gedit as root?

    It is best to use
    Code:
    sudo -H gedit

  3. #3
    Join Date
    Aug 2016
    Location
    Wandering
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: Which best practice for using gedit as root?

    Quote Originally Posted by wildmanne39 View Post
    It is best to use
    Code:
    sudo -H gedit
    +1
    I agree with wildmanne39
    From man sudo
    Code:
    -i, --login
                     Run the shell specified by the target user's password data‐
                     base entry as a login shell.  This means that login-specific
                     resource files such as .profile, .bash_profile or .login will
                     be read by the shell.  If a command is specified, it is
                     passed to the shell for execution via the shell's -c option.
                     If no command is specified, an interactive shell is executed.
                     sudo attempts to change to that user's home directory before
                     running the shell.  The command is run with an environment
                     similar to the one a user would receive at log in.  Note that
                     most shells behave differently when a command is specified as
                     compared to an interactive session; consult the shell's man‐
                     ual for details.  The Command environment section in the
                     sudoers(5) manual documents how the -i option affects the
                     environment in which a command is run when the sudoers policy
                     is in use.
    Code:
    -H, --set-home
                     Request that the security policy set the HOME environment
                     variable to the home directory specified by the target user's
                     password database entry.  Depending on the policy, this may
                     be the default behavior.
    With realization of one's own potential and self-confidence in one's ability, one can build a better world.
    Dalai Lama>>
    Code Tags | System-info | Forum Guide lines | Arch Linux, Debian Unstable, FreeBSD

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Which best practice for using gedit as root?

    In Ubuntu 17.10 (gvfs >= 1.29.4) you should use the gvfs admin backend:
    Code:
    gedit admin:///path/to/file
    https://ubuntuforums.org/showthread.php?t=2377380
    https://github.com/brunonova/nautilus-admin/issues/29

  5. #5
    Join Date
    May 2015
    Beans
    6

    Re: Which best practice for using gedit as root?

    Thank you for your answers !

    On Wayland, is URI calling better than
    Code:
    sudo -H gedit
    using xhost ?

  6. #6
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Which best practice for using gedit as root?

    In theory, the gvfs admin backend method (which uses polkit) is better and safer, regardless of the UI you use.

    You don't run the whole application as root. Privilege escalation happens only when is strictly necessary.

  7. #7
    Join Date
    Oct 2005
    Location
    Lab, Slovakia
    Beans
    10,801

    Re: Which best practice for using gedit as root?

    Actually, I think the best practise for using gedit as root, is to use nano!

  8. #8
    Join Date
    May 2015
    Beans
    6

    Re: Which best practice for using gedit as root?

    I do agree, tee being an alternative ! It's not the use case though (nano and tee can afraid some users)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •