4

Recently (since the reboot at Tue 2017-05-09 15:40:28 EDT?), when I open a terminal via CtrlAltT, or a terminal window CtrlShiftT (gnome-terminal,LightDM), the first text I see is:

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

This message is coming from /etc/bash.bashrc, which is sourced by /etc/profile. It's generated conditionally:

if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
    case " $(groups) " in *\ admin\ *|*\ sudo\ *)
    if [ -x /usr/bin/sudo ]; then
        cat <<-EOF
        To run a command as administrator (user "root"), use "sudo <command>".
        See "man sudo_root" for details.

        EOF
    fi
    esac
fi

But, my $HOME/.sudo_as_admin_successful exists, and has since Nov 15:

$ ll .sudo_as_admin_successful
-rw------- 1 w3 walt 0 Nov 15  2016 .sudo_as_admin_successful

and groups says I'm in walt root adm tty lp mail dialout cdrom sudo dip video plugdev lpadmin sambashare wireshark libvirtd (Note sudo).

More detail, in response to comments (I'm not logged in as "another user"

w3@aardvark:~(0)$ id
uid=1003(w3) gid=1000(walt) groups=1000(walt),0(root),4(adm),5(tty),7(lp),8(mail),20(dialout),24(cdrom),27(sudo),30(dip),44(video),46(plugdev),109(lpadmin),124(sambashare),149(wireshark),152(libvirtd)
w3@aardvark:~(0)$ pathlld $HOME/.sudo_as_admin_successful
drwxr-xr-x 29 root root 4096 May 18 20:46 /
/dev/sdb5 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
drwxr-xr-x 13 root root 4096 Sep  1  2015 /home
/dev/sdb6 on /home type ext4 (rw,relatime,data=ordered)
drwx------ 191 w3 walt 147456 May 21 01:38 /home/w3
/home/.ecryptfs/w3/.Private on /home/w3 type ecryptfs (rw,nosuid,nodev,relatime,ecryptfs_fnek_sig=e377cfa845240aa1,ecryptfs_sig=5fa903fe1f605483,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs)
-rw------- 1 w3 walt 0 Nov 15  2016 /home/w3/.sudo_as_admin_successful

Why am I getting this message? I've looked at this answer, but it doesn't seem to apply.

waltinator
  • 36,399
  • 1
    What's .hushlogin? That file needs to exist too apparently. I have no mention of it in my .bashrc – Zanna May 21 '17 at 05:41
  • @waltinator - did the message start to appear only recently? – Yaron May 21 '17 at 06:06
  • @Zanna - The file .hushlogin in ~ directory disables login welcome messages for bash shell coderwall and ibm – Yaron May 21 '17 at 06:08
  • Nothing is trying to sudo, it's just a message telling you that you can. The assumption in question title is incorrect. – gronostaj May 21 '17 at 07:56
  • I'm trying to find out why the message is issued. I can run it in a terminal with no message. What does it think is different at terminal start time? – waltinator May 21 '17 at 17:10
  • 1
    Just an idea... What is the value of $HOME ? You are probably logged in as another user? – mook765 May 21 '17 at 17:35
  • 1
    Another idea: in my case I have the following ownership and permissions -rw-r--r-- 1 mook mook 0 Nov 21 02:49 .sudo_as_admin_successful – mook765 May 21 '17 at 17:59
  • 2
    @Zanna no, the file doesn't need to exit - the presence of either file is enough. ((NOT fileA) AND (NOT fileB)) == (NOT (fileA OR fileB)). waltinator: Run PS4='${BASH_SOURCE}:${LINENO} ' bash -x and add the output, please. – muru May 21 '17 at 18:45
  • Sorry, @muru but bash -x does NOT reproduce the problem. The emitter of the problem text (/etc/bash.bashrc) is sourced long before I could set PS4 (nice trick, though). I could temporarily set PS4 in /etc/profile (very carefully), I suppose. – waltinator May 21 '17 at 20:02
  • @waltinator uh, just run the command as I showed it. /etc/profile is irrelevant unless you're running a login shell, which gnome terminal doesn't, by default – muru May 21 '17 at 20:05
  • Since the message comes from /etc/bash.bashrc, which is ONLY AFAIK called from /etc/profile, and my gnome-terminal Default preferences do not have "Run command as a login shell" checked, is my Q really "Why is gnome-terminal` starting everything as a login shell"? – waltinator May 21 '17 at 20:17
  • If Bash is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they appear in the environment, are ignored, and the effective user id is set to the real user id. If the -p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset Found at https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Bash-Startup-Files – mook765 May 21 '17 at 22:09
  • @mook765 True, since but my startup files (/etc/profile -> /etc/bash.bashrc (message), $HOME/.bashrc) ARE executed, and I haven't changed anything group-related since Nov 15 (added epmd group), I'm confused on how your comment applies. – waltinator May 22 '17 at 03:55
  • I admit that I don't understand all that fully. I also see that your startup files are executed. But the message is triggered according to the conditions in the script in /etc/ bash.bashrc. Does a file /home/walt/.sudo_as_ad... exist? If not, you could create it, just to track the problem. This is really a hard nut! – mook765 May 22 '17 at 06:19
  • HOME is a variable and it's value could change. To see the value of HOME at the moment /etc/bash.bashrc is running you could add the line echo "$HOME" just above the provided snippet of the file. After adding this line open a new terminal and you will see in which directory bash.bashrc is looking for the files .sudo_as_admin_successful and .hushlogin. I think this will give us a clue. – mook765 May 22 '17 at 14:27
  • In setting up for editing /etc/profile, I started another gnome-terminal (Ctrl-Alt-T) which did NOT exhibit the problem. More thought is needed - one of my long-ago implemented self-watching hacks told me that, in the bad gnome-terminal I had 10 env vars, and in the good one, 65. – waltinator May 23 '17 at 05:07
  • 1
    After moving my .profile and .bashrc aside, I found that the gnome-terminal that complains was started with an environment consisting ONLY of: DISPLAY=:0,PWD=/home/w3,SHLVL=1,TERM=xterm-256color,VTE_VERSION=4205,WINDOWID=67108874. No HOME! This is a bug report, not an AskUbuntu Q, I think. – waltinator May 25 '17 at 20:02
  • 1
    @mook765 The bug report is https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1693607 – waltinator May 27 '17 at 18:32
  • @muru The bug report is https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1693607 – waltinator May 27 '17 at 18:32
  • @waltinator Look at line 109 of JournalError.txt: dev-disk-by\x2duuid-0123\x2d4567.device: Dev dev-disk-by\x2duuid-0123\x2d4567.device appeared twice with different sysfs paths. I think that is not related to the problem but maybe something you should look at. There are also several errors about pam_ecryptfs: seteuid error, that could probably be a point. But that's above my horizon, I will follow your bug-report with interest. – mook765 May 27 '17 at 20:42

0 Answers0