Results 1 to 7 of 7

Thread: Sudo won't open applications GUI

  1. #1
    Join Date
    Apr 2012
    Location
    Västerås, Sweden
    Posts
    8

    Default Sudo won't open applications GUI

    Hello,
    I need some help regarding running applications using sudo.
    Whenever I try to run an app using the sudo command in Konsole I get a message that the Display cannot be opened.
    For example:
    Code:
    sudo gedit /etc/samba/smb.conf
    Cannot open display: 
    Run 'gedit --help' to see a full list of available command line options.
    or
    Code:
    sudo virtualbox
    Failed to open the X11 display!
    or
    Code:
    sudo kwrite /etc/samba/smb.conf
    kwrite: cannot connect to X server
    or
    Code:
    sudo bluefish /etc/samba/smb.conf
    
    ** ERROR **: Error parsing command line options. Cannot open display: 
    Please run: bluefish -?
    However, normal running of these applications works perfectly.
    I can't seem to figure out the problem, can anyone help?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2010
    Location
    Austin - Texas
    Posts
    10,140
    Blog Entries
    48

    Smile Re: Sudo won't open applications GUI

    Quote Originally Posted by Microsd View Post
    Hello,
    I need some help regarding running applications using sudo.
    Whenever I try to run an app using the sudo command in Konsole I get a message that the Display cannot be opened.
    For example:
    Code:
    sudo gedit /etc/samba/smb.conf
    Cannot open display: 
    Run 'gedit --help' to see a full list of available command line options.
    or
    Code:
    sudo virtualbox
    Failed to open the X11 display!
    or
    Code:
    sudo kwrite /etc/samba/smb.conf
    kwrite: cannot connect to X server
    or
    Code:
    sudo bluefish /etc/samba/smb.conf
    
    ** ERROR **: Error parsing command line options. Cannot open display: 
    Please run: bluefish -?
    However, normal running of these applications works perfectly.
    I can't seem to figure out the problem, can anyone help?

    Thanks in advance.
    For use in terminal or in a script as a regular user only try these:

    For KDE:

    Code:
    dbus-launch kdesu kwrite /etc/samba/smb.conf
    OR

    For Gnome:

    Code:
    dbus-launch gnomesu gedit /etc/samba/smb.conf
    Thank You,
    My Blog: https://forums.opensuse.org/blogs/jdmcdaniel3/

    Software efficiency halves every 18 months, thus compensating for Moore's Law

    Its James again from Austin, Texas

  3. #3
    Join Date
    Apr 2012
    Location
    Västerås, Sweden
    Posts
    8

    Default Re: Sudo won't open applications GUI

    Thanks, that worked perfectly
    Do I have to use dbus everytime I try to run an application using sudo?? I am sorry for the newbie question I have only recently switched to openSUSE from ubuntu, and things like these used to work there...

  4. #4

    Default Re: Sudo won't open applications GUI

    Quote Originally Posted by Microsd View Post
    Thanks, that worked perfectly
    Do I have to use dbus everytime I try to run an application using sudo?? I am sorry for the newbie question I have only recently switched to openSUSE from ubuntu, and things like these used to work there...
    You don't have to use dbus-launch at all for programs such as kwrite or gedit.

  5. #5
    Join Date
    Mar 2010
    Location
    Austin - Texas
    Posts
    10,140
    Blog Entries
    48

    Default Re: Sudo won't open applications GUI

    Quote Originally Posted by please_try_again View Post
    You don't have to use dbus-launch at all for programs such as kwrite or gedit.
    Indeed the issue is using sudo, which will not work with graphic programs like kwrite or gedit and the need was to switch to using kdesu or gnomesu instead, but other programs may not start in a terminal session with out using the dbus-launch app and I have found no problem using it in when in doubt.

    Thank You,
    My Blog: https://forums.opensuse.org/blogs/jdmcdaniel3/

    Software efficiency halves every 18 months, thus compensating for Moore's Law

    Its James again from Austin, Texas

  6. #6
    Join Date
    Apr 2012
    Location
    Västerås, Sweden
    Posts
    8

    Default Re: Sudo won't open applications GUI

    Great, I even managed to run the VirtualBox now. )

    Thanks again.

  7. #7
    Join Date
    Mar 2010
    Location
    Austin - Texas
    Posts
    10,140
    Blog Entries
    48

    Smile Re: Sudo won't open applications GUI

    Quote Originally Posted by Microsd View Post
    Great, I even managed to run the VirtualBox now. )

    Thanks again.
    First off, we were more than happy to help. But, I must say that it is preferred to not run VirtualBox as root. The need to run VirtualBox as root depends on where its configuration files and Virtual Disks are located. For each Virtual Session, there are two components, its configuration file and its virtual disk. And, besides that, if you started running VirtualBox as root the very first time, its configuration files are most likely in the root user folder. On my PC, the default Virtual Machine Folder is located: /VirtualBox/VirtualBoxVMs and I am also creating the Virtual Disks there. This is a EXT4 partition I created just for VirtualBox and I have set the fstab load options as just "defaults", thus not requiring you to be root. I made these selections myself to a partition that had lots of room. If instead, you created these in your /home folder. where you also had lots of room, you would not need to be root either to run VirtualBox. So, if either the Virtual Machine files or the Virtual Disk files are located in /root or on any partition you must be root to write top, then you can only get VirtualBox to run as root. One way to change this is to change the preferences to point into your home area, make sure your Virtual Disks are also located in /home or some where you have rights without being root. You can create a new Virtual Machine, with the same settings, but to use an existing Virtual Disk. I do this to move a created Virtual Session to a different computer and it does work just fine. You could continue on as before and decide to do something else when you reinstall openSUSE or when you get a new computer. As you notice, except for YaST and a very few other things, you need not be root to run them such as Firefox, or LibreOffice or Amarok, just to name a few. So think about it and ask for help if you need it.

    Thank You,
    My Blog: https://forums.opensuse.org/blogs/jdmcdaniel3/

    Software efficiency halves every 18 months, thus compensating for Moore's Law

    Its James again from Austin, Texas

Posting Permissions

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