2

I guess I made some damage to my settings because now I'm unable to run Sublime Text as root without -E:

subl //works
sudo subl //doesn't work (no errors, just silence)
sudo -E subl //works.

How can I fix this?


Output of env:

XDG_VTNR=7
LC_PAPER=uk_UA.UTF-8
LC_ADDRESS=uk_UA.UTF-8
XDG_SESSION_ID=c2
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/daria
LC_MONETARY=uk_UA.UTF-8
CLUTTER_IM_MODULE=xim
COMP_WORDBREAKS=    
"'><;|&(:
SESSION=ubuntu
TERM=xterm-256color
VTE_VERSION=4002
SHELL=/bin/bash
WINDOWID=69206026
LC_NUMERIC=uk_UA.UTF-8
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1341
GNOME_KEYRING_CONTROL=
GTK_MODULES=unity-gtk-module
LC_ALL=
USER=daria
LC_TELEPHONE=uk_UA.UTF-8
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
DESKTOP_SESSION=ubuntu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
LC_MESSAGES=en_US.UTF-8
QT_IM_MODULE=ibus
QT_QPA_PLATFORMTHEME=appmenu-qt5
LC_COLLATE=en_US.UTF-8
LC_IDENTIFICATION=uk_UA.UTF-8
XDG_SESSION_TYPE=x11
PWD=/home/daria
JOB=unity-settings-daemon
XMODIFIERS=@im=ibus
GNOME_KEYRING_PID=
LANG=en_US.UTF-8
GDM_LANG=en
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
LC_MEASUREMENT=uk_UA.UTF-8
COMPIZ_CONFIG_PROFILE=ubuntu
IM_CONFIG_PHASE=1
PAPERSIZE=a4
GDMSESSION=ubuntu
SESSIONTYPE=gnome-session
GTK2_MODULES=overlay-scrollbar
SHLVL=1
HOME=/home/daria
XDG_SEAT=seat0
LANGUAGE=en
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
UPSTART_INSTANCE=
UPSTART_EVENTS=xsession started
XDG_SESSION_DESKTOP=ubuntu
LOGNAME=daria
COMPIZ_BIN_PATH=/usr/bin/
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
QT4_IM_MODULE=xim
LC_CTYPE=en_US.UTF-8
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-B8OeFaNcXl
LESSOPEN=| /usr/bin/lesspipe %s
INSTANCE=
UPSTART_JOB=unity7
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0
XDG_CURRENT_DESKTOP=Unity
GTK_IM_MODULE=ibus
LESSCLOSE=/usr/bin/lesspipe %s %s
LC_TIME=uk_UA.UTF-8
LC_NAME=uk_UA.UTF-8
XAUTHORITY=/home/daria/.Xauthority
_=/usr/bin/env

Output of sudo env:

LC_PAPER=uk_UA.UTF-8
LC_ADDRESS=uk_UA.UTF-8
LC_MONETARY=uk_UA.UTF-8
TERM=xterm-256color
LC_NUMERIC=uk_UA.UTF-8
LC_ALL=
LC_TELEPHONE=uk_UA.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_IDENTIFICATION=uk_UA.UTF-8
LANG=en_US.UTF-8
LC_MEASUREMENT=uk_UA.UTF-8
LANGUAGE=en
LC_CTYPE=en_US.UTF-8
LC_TIME=uk_UA.UTF-8
LC_NAME=uk_UA.UTF-8
SHELL=/bin/bash
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
LOGNAME=root
USER=root
USERNAME=root
HOME=/root
SUDO_COMMAND=/usr/bin/env
SUDO_USER=daria
SUDO_UID=1000
SUDO_GID=1000

Content of /etc/sudoers:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults    env_keep="https_proxy"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

daria ALL=NOPASSWD: ALL
root    ALL=(ALL)   ALL
14
  • 1
    You shouldn't open Sublime Text using either of the two methods (you should use sudo -H subl, gksudo subl, or pkexec subl) but other than that the problem seems to be in the environment, please post the output of env and sudo env. – kos Jan 18 '16 at 10:34
  • 1
    Your sudo env output is also much different from mine. Another thing, why is HOME set to /root in sudo env's output? It should be /home/daria unless you're ran sudo -H env or ran sudo env while logged in as root already. Do you remember having done something in particular before the problem showed up? Changes to configuration files etc? Well no, adding DISPLAY to sudo's environment won't change much if sudo -H DISPLAY=:0 subl didn't work. I mean it probably should be added at some point, but the problem seems extended to the envrinoment in general. – kos Jan 18 '16 at 11:17
  • 1
    Without knowing exactly what you did it's hard :) however sudo's behavior is ruled by sudo's and PAM's configuration. Did you change /etc/sudoers or some file related to PAM's configuration (something in /etc/pam.d)? – kos Jan 18 '16 at 11:35
  • 1
    It doesn't seem likely for that to affect the environment, however just to be sure you could try to restore the default /etc/sudoers. I pasted a clean /etc/sudoers here, see if it makes any difference. – kos Jan 18 '16 at 11:45
  • 1
    I have no clue. I tried Googling the line and couldn't really understand what that would be for, so I guess I'll have to dig man sudo. However I posted the answer in the meantime. – kos Jan 18 '16 at 12:22
0

The problem is in the environment set by the sudo command.

The non-functional environment is set because of this line in /etc/sudoers:

Defaults env_keep="https_proxy"

Which affects the environment in different ways, such as:

  • DISPLAY andXAUTHORITY not set (which cause the problem)
  • HOME set to /home/root

And probably in other ways as well.

If you wish to keep https_proxy from the previous environment when running sudo (this is often useful in order to be able to use a proxy when running apt-get), change the line to this one:

Defaults env_keep+="https_proxy"

So that the other needed environment variables won't be unset.

Otherwise if you don't have a reason to keep https_proxy from the previous environment when running sudo, you can just remove the whole line altoghether.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.