Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: sudo with gedit and gparted gives errors, but they work without sudo

  1. #1
    Join Date
    Dec 2006
    Beans
    Hidden!

    sudo with gedit and gparted gives errors, but they work without sudo

    I need to edit fstab file. I usually just do 'sudo gedit /etc/fstab'
    So what can I do ?
    I tried sudo su, I tried gksu.
    Code:
    root@scott-MS-7596:/home/scott# sudo gedit /etc/fstab
    No protocol specified
    Unable to init server: Could not connect: Connection refused
    
    (gedit:5058): Gtk-WARNING **: cannot open display: :0
    root@scott-MS-7596:/home/scott#

  2. #2
    Join Date
    Oct 2004
    Location
    Denmark - Scandinavia
    Beans
    19,553
    Distro
    Ubuntu Budgie Development Release

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    Try with
    Code:
    sudo -H
    instead.

  3. #3
    Join Date
    Dec 2006
    Beans
    Hidden!

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    ??
    Code:
    root@scott-MS-7596:/home/scott# sudo -H gedit 
    No protocol specified
    Unable to init server: Could not connect: Connection refused
    
    (gedit:5268): Gtk-WARNING **: cannot open display: :0
    root@scott-MS-7596:/home/scott# sudo -H gedit /etc/fstab
    No protocol specified
    Unable to init server: Could not connect: Connection refused
    
    (gedit:5273): Gtk-WARNING **: cannot open display: :0
    root@scott-MS-7596:/home/scott# sudo -H
    usage: sudo -h | -K | -k | -V
    usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
    usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
                [command]
    usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
                prompt] [-T timeout] [-u user] [VAR=value] [-i|-s] [<command>]
    usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
                prompt] [-T timeout] [-u user] file ...
    root@scott-MS-7596:/home/scott#
    Code:
    root@scott-MS-7596:/home/scott# sudo -H gparted
    Created symlink /run/systemd/system/-.mount → /dev/null.
    Created symlink /run/systemd/system/home.mount → /dev/null.
    Created symlink /run/systemd/system/run-user-0.mount → /dev/null.
    Created symlink /run/systemd/system/run-user-1000.mount → /dev/null.
    Created symlink /run/systemd/system/run-user-121.mount → /dev/null.
    Created symlink /run/systemd/system/tmp.mount → /dev/null.
    No protocol specified
    
    (gpartedbin:5386): Gtk-WARNING **: cannot open display: :0
    Removed /run/systemd/system/-.mount.
    Removed /run/systemd/system/home.mount.
    Removed /run/systemd/system/run-user-0.mount.
    Removed /run/systemd/system/run-user-1000.mount.
    Removed /run/systemd/system/run-user-121.mount.
    Removed /run/systemd/system/tmp.mount.
    root@scott-MS-7596:/home/scott#

  4. #4
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,616
    Distro
    Ubuntu

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    Why?
    You are already root.
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  5. #5
    Join Date
    Dec 2006
    Beans
    Hidden!

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    Quote Originally Posted by deadflowr View Post
    Why?
    You are already root.
    it did not matter, I tried not as root, tried as root, they dont run.
    I am saying I have a real problem here.
    Can you run these with root privileges?

    Code:
    root@scott-MS-7596:/home/scott# gedit
    No protocol specified
    Unable to init server: Could not connect: Connection refused
    
    (gedit:7138): Gtk-WARNING **: cannot open display: :0
    Code:
    root@scott-MS-7596:/home/scott# gparted
    Created symlink /run/systemd/system/-.mount → /dev/null.
    Created symlink /run/systemd/system/home.mount → /dev/null.
    Created symlink /run/systemd/system/media-scott-1ca42e1a\x2dc943\x2d4755\x2db8e5\x2da9a6e91f4ed6.mount → /dev/null.
    Created symlink /run/systemd/system/run-user-0.mount → /dev/null.
    Created symlink /run/systemd/system/run-user-1000.mount → /dev/null.
    Created symlink /run/systemd/system/run-user-121.mount → /dev/null.
    Created symlink /run/systemd/system/tmp.mount → /dev/null.
    No protocol specified
    
    (gpartedbin:7193): Gtk-WARNING **: cannot open display: :0
    Removed /run/systemd/system/-.mount.
    Removed /run/systemd/system/home.mount.
    Removed /run/systemd/system/media-scott-1ca42e1a\x2dc943\x2d4755\x2db8e5\x2da9a6e91f4ed6.mount.
    Removed /run/systemd/system/run-user-0.mount.
    Removed /run/systemd/system/run-user-1000.mount.
    Removed /run/systemd/system/run-user-121.mount.
    Removed /run/systemd/system/tmp.mount.
    root@scott-MS-7596:/home/scott#
    I can run gedit without sudo privileges. But how can I edit fstab without using gedit? And besides it should work.
    Last edited by sdowney717; October 16th, 2017 at 05:04 PM.

  6. #6
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,616
    Distro
    Ubuntu

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    So you meant the launchers work like normal, then.
    ( i was guessing you meant typing something like "gedit /etc/fstab" was working)
    Okay,
    have you looked over this thread
    https://ubuntuforums.org/showthread.php?t=2367294
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  7. #7
    Join Date
    Dec 2006
    Beans
    Hidden!

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    Quote Originally Posted by deadflowr View Post
    So you meant the launchers work like normal, then.
    ( i was guessing you meant typing something like "gedit /etc/fstab" was working)
    Okay,
    have you looked over this thread
    https://ubuntuforums.org/showthread.php?t=2367294
    Hi, that does work, no errors now, so they will fix this?
    Code:
    scott@scott-MS-7596:~$ gedit
    
    scott@scott-MS-7596:~$ xhost +si:localuser:root
    localuser:root being added to access control list
    scott@scott-MS-7596:~$ sudo gedit
    [sudo] password for scott: 
    scott@scott-MS-7596:~$

  8. #8
    Chanath is offline Extra Foam Sugar Free Ubuntu
    Join Date
    May 2013
    Beans
    729

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    Isn't xhost +si:localuser:root just a workaround for Wayland?

  9. #9
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    If you have become used to using sudo to start GUI programs as root you may have changed the ownership of some of the files in your home which then may cause BIG problems for you and can make it impossible to login as user.

    YOU SHOULD NOT USE sudo WITH GUI PROGRAMS; IT IS ASKING FOR PROBLEMS !
    Sorry for shouting but it is an important lesson that you must learn for your own sake, and as Artificial Intelligence said above, use sudo -H instead.

    I wonder if your problems with gedit are a result of using sudo for GUI programs in the past?

  10. #10
    Join Date
    Dec 2006
    Beans
    Hidden!

    Re: sudo with gedit and gparted gives errors, but they work without sudo

    Quote Originally Posted by ajgreeny View Post
    If you have become used to using sudo to start GUI programs as root you may have changed the ownership of some of the files in your home which then may cause BIG problems for you and can make it impossible to login as user.

    YOU SHOULD NOT USE sudo WITH GUI PROGRAMS; IT IS ASKING FOR PROBLEMS !
    Sorry for shouting but it is an important lesson that you must learn for your own sake, and as Artificial Intelligence said above, use sudo -H instead.

    I wonder if your problems with gedit are a result of using sudo for GUI programs in the past?
    It did this immediately upon a fresh install, this was not an upgrade from 16.04.
    I wanted to look at the drives and thought to run sudo gparted, and it immediately gave those errors.

    I did install gksu, but on 16.04, I always was using sudo with gedit for a long time.

Page 1 of 2 12 LastLast

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
  •