• Problem running apps with sudo


    Hi, i just find out i have a problem from console to run programs with sudo.

    For example, when i type :

    sudo gedit /home/chris/pp
    

    I get (after i put the password) :

    No protocol specified
    Unable to init server: Could not connect: Connection refused
    
    (gedit:2660): Gtk-WARNING **: cannot open display: :0
    

    Also notice that when i give : su
    I get :

    [email protected] ~]$ su
    Password: 
    No protocol specified
    xdpyinfo:  unable to open display ":0".
    

    Any ideas?
    Thanks a lot

  • Gnome under wayland?
    J.

  • @Jeannie____ said in Problem running apps with sudo:

    Gnome bajo Wayland?

    I would not be surprised, I think that’s where the shots go …

    (I always prefer Xorg!)

    Autodidacta en la VIDA …y en Linux, también.

  • xhost +local: && sudo gedit /home/chris/pp
    

    should do the job under wayland

    [updates once a week] = [90% less problems]
    [Li{u}n//u//{i}x] since 1988 - overcoming failure means success
    http://kamprad.net/howto-installing-antergos/
    https://forum.antergos.com/topic/1883/how-to-include-system-logs-when-asking-for-help

  • Wayland, still only almost usable under only 9 years of development.
    J.

  • @joekamprad said in Problem running apps with sudo:

    xhost +local: && sudo gedit /home/chris/pp
    

    should do the job under wayland

    'Yes it works with that!
    Is there a way to make it work with the normal way or we have to live with that!
    you mean if i logon with xorg it will work ok?

    Thanks for the answers!

  • on X-session you will not have this only on wayland because of the different rights handeling of the two…

    [updates once a week] = [90% less problems]
    [Li{u}n//u//{i}x] since 1988 - overcoming failure means success
    http://kamprad.net/howto-installing-antergos/
    https://forum.antergos.com/topic/1883/how-to-include-system-logs-when-asking-for-help

  • oh i get it !
    So there isn’t a way to fix that?! I think we have to live with it!!!
    Thanks a lot

  • only way is to automat this with a desktop file for the apps you want to start as root…
    Or use X-Org session.

    [updates once a week] = [90% less problems]
    [Li{u}n//u//{i}x] since 1988 - overcoming failure means success
    http://kamprad.net/howto-installing-antergos/
    https://forum.antergos.com/topic/1883/how-to-include-system-logs-when-asking-for-help

  • Thanks for the answer!
    I try xorg to see the diferences…

  • Whell i think i found a solution with the help of a script.
    The script isn’t myne i found it here (https://www.reddit.com/r/Fedora/comments/5eb633/solution_running_graphical_app_with_sudo_in/)

    But i can write it down with a few more info (how we can make script executable…for us newbies!!! i found it in an other link!!)

    So i found this code in the link i gave:

    #!/bin/bash
    #small script to enable root access to x-windows system 
    xhost +SI:localuser:root
    sudo $1
    #disable root access after application terminates
    xhost -SI:localuser:root
    #print access status to allow verification that root access was removed
    xhost
    

    So lets start!

    1)make an empty text file in your home directory (for me is /home/chris) with a name to remember what it does!! for example wsudo
    2)copy the code i gave above and save the file.
    3)go to your home folder (where the wsudo file is) and run from konsole : chmod +x wsudo so it will be executable.
    4)To make it run from any place we must run : gedit .bashrc and in the file that opens we add this line to the end of it : alias <Name_with which you wanna call it >=’./filename.sh’ so for our example it will be :
    alias wsudo=./wsudo
    5)commit the changes with : source ~/.bashrc

    We are fine!
    So now we can run from konsole : wsudo gedit /home/chris/test and opens gedit with no errors !!!

    Sorry for the way of writing it but i am newbie i feel newbie so i write as newbie!!!

    So if this can be a “solution” please a mod mark it as solved!

apps8 running6 sudo10 Posts 11Views 361
Log in to reply