Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2477  / 3 Years ago, sat, august 14, 2021, 2:22:54

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

More From » server

 Answers
6

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.


[#29077] Saturday, August 14, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
imberst

Total Points: 370
Total Questions: 107
Total Answers: 123

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
imberst questions
;