1

I am administrator of two ubuntu servers. On one of them, when I try to run a command (for instance irb1.9.1) from a package that is not installed, I get the following message:

The program 'irb1.9.1' is currently not installed.  You can install it by typing:
sudo apt-get install ruby1.9.1

On the other server, I get the following answer:

The program 'irb1.9.1' is currently not installed.  To run 'irb1.9.1' please ask your administrator to install the package 'ruby1.9.1'

I can sudo on both servers, so I don't understand how the first one knows I can install the package myself and shows me the command to run, while the second doesn't.

Where does the difference come from and how can I get the second server to give me the command like the first server?

Edit to answer Braiam's comment, apt-cache policy return the same on both servers:

$ apt-cache policy command-not-found
command-not-found:
  Installed: 0.3ubuntu7.1
  Candidate: 0.3ubuntu7.1
  Version table:
 *** 0.3ubuntu7.1 0
        500 http://dk.archive.ubuntu.com/ubuntu/ raring-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     0.3ubuntu7 0
        500 http://dk.archive.ubuntu.com/ubuntu/ raring/main amd64 Packages
2
  • What's the output of apt-cache policy command-not-found?
    – Braiam
    Oct 14, 2013 at 21:28
  • @Braiam I edited my question with this data.
    – Calimo
    Oct 15, 2013 at 20:58

2 Answers 2

0

Difference probably occurs because you use different bash versions or different shells. Use:

echo $SHELL
bash --version

to check your current shell and/or your current bash version.

2
  • Both answer /bin/bash and GNU bash, version 4.2.25(1)-release. One with (i686-pc-linux-gnu) and one with ` (x86_64-pc-linux-gnu)`. If that's the reason for the difference it looks like a bug...
    – Calimo
    Oct 12, 2013 at 18:38
  • @Calimo So, there are different versions of bash. One is for 32bit and another one for 64bit. Oct 12, 2013 at 18:48
0

Investigating the topic a bit more, I found that command-not-found was using the /usr/lib/python2.7/dist-packages/CommandNotFound/CommandNotFound.py script, which contains the following line:

self.user_can_sudo = grp.getgrnam("sudo")[2] in posix.getgroups() or grp.getgrnam("admin")[2] in posix.getgroups()

So basically anyone in the sudo or admin groups will be considered as an administrator. One of the machines was configured to use the wheel group instead, so visudo would show:

%wheel ALL=(ALL) ALL

On the server I wasn't member of the sudo or admin groups, so command-not-found wouldn't know I could execute apt-get commands with sudo. After adding myself to the sudo group as well, I now get the apt-get command to execute printed out on the terminal.

1
  • Note that on Debian 8 "Jessie", the script is looking for the group admin (which didn't exist upon OS installation).
    – Calimo
    Mar 9, 2016 at 15:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .