sudo hints and ~/.hushlogin in debian or ubuntu

My work laptop runs Ubuntu Linux. After using Ubuntu for more than a month now, I can definitely agree that it is a really nice Linux distribution. Most of the things I have to do as part of my every-day job “just work”. There are binary packages for literally hundreds of applications. The desktop itself feels snappy, fast, it looks good and it’s as configurable as any Gnome-based desktop you will find out there.

Yet, there are a few details about Ubuntu (and its Debian heritage) that range from mildly annoying to batshit crazy. Only this morning, for example, I noticed that my home directory includes a file called “.sudo_as_admin_successful". This is a Debian-specific hack that Ubuntu has inherited from its roots. When this file does not exist, the default "/etc/bash.bashrc" startup script will show a hint like this when you fire up a new shell:

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

gkeramidas:~$

The annoying thing about this is that the hint is displayed even when you have created a "~/.hushlogin" file to silence login-time messages:

$ ssh localhost
gkeramidas@localhost's password: 
/usr/bin/xauth:  creating new authority file /home/gkeramidas/.Xauthority
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

gkeramidas:~$ exit

The fix is really easy, and I just installed it on my laptop's "/etc" tree:

gkeramidas:/etc$ diff -u bash.bashrc.orig bash.bashrc
--- bash.bashrc.orig    2010-11-08 10:51:16.000000000 +0100
+++ bash.bashrc 2010-11-08 10:50:55.000000000 +0100
@@ -34,7 +34,7 @@
 #fi

 # sudo hint
-if [ ! -e "$HOME/.sudo_as_admin_successful" ] ; then
+if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
     case " $(groups) " in *\ admin\ *)
     if [ -x /usr/bin/sudo ]; then
        cat <<-EOF
gkeramidas:/etc$

One annoyance down. Now off to do some real work :)

About these ads
This entry was posted in Computers, GNU/Linux, laptop, Linux, Open source, Programming, Software, Ubuntu and tagged . Bookmark the permalink.

8 Responses to sudo hints and ~/.hushlogin in debian or ubuntu

  1. adamo says:

    Before doing real work, how about notifying the package maintainer?

  2. vvas says:

    As usual, the correct solution for these things is to file a bug (ideally, with a patch!). Complaining on one’s blog does little to change things (and that goes beyond software, but that’s a different discussion…).

  3. keramida says:

    @adamo and @vvas: yep, you’re right. The package maintainer should be notified. I’m going through the debbugs stuff as I type this. The “bash” maintainer is the one who actually controls “/etc/bash.bashrc", as I found out a couple of minutes after posting to the blog.

    • adamo says:

      I operate like you do. I do not always file a bug report. Nor do I always contact the package maintainer. Largely this has to do with how quick it is to either file the bug report or locate who the maintainer is. And it is quicker to just post about it and wait for the search engines to index it for whoever is in trouble.

  4. keramida says:

    Update: ‘reportbug’ seems broken on my installation of Lucid Lynx:

    Traceback (most recent call last):
      File "/usr/bin/reportbug", line 2043, in 
        main()
      File "/usr/bin/reportbug", line 997, in main
        return iface.user_interface()
      File "/usr/bin/reportbug", line 1115, in user_interface
        main()
      File "/usr/bin/reportbug", line 997, in main
        return iface.user_interface()
      File "/usr/bin/reportbug", line 1938, in user_interface
        klass, subject, tags, body, mode, pseudos, debsumsoutput)
      File "/usr/lib/pymodules/python2.6/reportbug/utils.py", line 719, in generate_blank_report
        return unicode(rep)
      File "/usr/lib/pymodules/python2.6/reportbug/bugreport.py", line 124, in __unicode__
        debinfo += infofunc()
      File "/usr/lib/pymodules/python2.6/reportbug/debianbts.py", line 594, in generic_infofunc
        utsmachine = os.uname(4)
    TypeError: uname() takes no arguments (1 given)

    I think reporting a bug to Ubuntu will have to wait a bit :-(

  5. firewalker says:

    Dear e-keramida. This is not the right e-way to fix e-bugs in *Ubuntu. You have to follow the e-rules. It goes like:

    I have this… e-Bug.
    Me too.
    Me too.
    Me too.

    Me too.

    Solved in next e-Release.

Comments are closed.