-1

What does it mean when package manager can not determine from which package the corresponding command was installed.
When I do -

$ sudo dpkg -S /usr/bin/passwd 
passwd: /usr/bin/passwd

from the output, I can infer that passwd was installed from passwd package

But for few command like - ftp, bash, cat, ls etc, the source info gives no lead about package. The below output is for bash but the output for other commands like ftp, cat, ls etc is exactly similar.

$ sudo dpkg -S /usr/bin/bash
dpkg-query: no path found matching pattern /usr/bin/bash

So, am puzzled what the above output means. Are these commands built in to shell or kernel (I don't think this is the case as commands/utils like ls, cat are part of coreutils package and man ls or cat confirms it.)

So, what does it mean when package manager can not determine from which package a command was installed.

Observation Notes:

$ sudo apt list coreutils
Listing... Done
coreutils/focal,now 8.30-3ubuntu2 amd64 [installed,automatic]

and

apt show coreutils | grep -Ew "ls|cat" 

extract

Specifically, this package includes:
arch base64 basename cat chcon chgrp chmod chown chroot cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false flock fmt fold groups head hostid id install join link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc numfmt

EDIT - Following Stephens response. (Posted as a separate Q too - How to effectively trace hardlink in linux?
Softlinks are easier to handle but Hardlinks are not easily traceable to orginal file -

$ ll -i /usr/bin/bash /bin/bash  
1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /bin/bash*  
1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /usr/bin/bash*

above is as expected - cool

$ find / -samefile /bin/bash 2>/dev/null
/usr/bin/bash

again as expected - so no probs

find / -samefile /usr/bin/bash 2>/dev/null
/usr/bin/bash  

this is NOT cool. now how do i trace the org file now

Strange - below did not help either.

$ find / -inum 1310813 2>/dev/null
/usr/bin/bash
  • /usr/bin/bash? Ubuntu has bash at /bin/bash. Same for /bin/cat and /bin/ls. – muru Sep 2 at 11:44
2
dpkg-query: no path found matching pattern /usr/bin/bash

means that no package ships /usr/bin/bash (directly). dpkg -S searches package contents, as shipped, ignoring alternatives, symbolic links etc.

dpkg -S /bin/bash

would find the package, because it ships /bin/bash.

See also:

$ dpkg -L bash|grep bin/bash
/bin/bash
/usr/bin/bashbug

The same applies to cat and ls — they’re shipped in /bin. The best approach when looking for a command in this situation is to look for it prefixed with bin/:

$ dpkg -S bin/bash
bash: /usr/bin/bashbug
bash: /bin/bash

ftp is in /usr/bin but it’s an alternative; to find that, use readlink:

$ dpkg -S $(readlink -f /usr/bin/ftp)
ftp: /usr/bin/netkit-ftp
| improve this answer | |
  • thanks, that helps greatly. but still few concerns.. am posting them here – samshers Sep 2 at 12:52
  • softlinks are ok to handle but hardlinks are not tracable to org file - $ ll -i /usr/bin/bash /bin/bash 1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /bin/bash* 1310813 -rwxr-xr-x 1 root root 1183448 Jun 18 21:14 /usr/bin/bash* - cool $ find / -samefile /bin/bash 2>/dev/null /usr/bin/bash - may be cool ` find / -samefile /usr/bin/bash 2>/dev/null /usr/bin/bash` - this NOT cool. how do i trace the org file now – samshers Sep 2 at 12:58
  • the outputs not cool here.. i will edit the Q – samshers Sep 2 at 13:00
  • See my update to find the packages without having to care about links. – Stephen Kitt Sep 2 at 14:34

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.