I have to find the uname
file on a Debian machine, check from which package it is and delete it. When I use which
to find it, I get /usr/bin/uname
. When I try to check it by dpkg -S uname
there is no such file. There is a /bin/uname
though. What is the difference between them?
Asked
Active
Viewed 512 times
2
2 Answers
4
First of all, use type
or type -a
to get all available uname
files, not which
. See Why not use "which"? What to use then?.
Next, when you want to see what package provides a given file, you can use the full path to the file (or just bin/filename
if the file is a binary as Stephen explains) . For example, on an Ubuntu system, I get:
$ type -a uname
uname is /bin/uname
So this is what I need to pass to dpkg -S
:
$ dpkg -S /bin/uname
coreutils: /bin/uname
So, there you go. /bin/uname
is provided by the coreutils
package.

terdon
- 242,166
-
... and deleting the
coreutils
package (which the OP mentioned that they might want to do) may result in a malfunctioning system. Also, on some Linuxes, the/usr/bin
and/bin
executables will be the same. – Kusalananda Nov 04 '20 at 17:36 -
1@Kusalananda yes, but since they say they "have to" I am assuming it's some sort of assignment. After all, if you choose to shoot yourself in the foot Mz Linux, just like Mr UNIX, will oblige... – terdon Nov 04 '20 at 17:41
4
There’s no difference; in Ubuntu, bin
is a symbolic link to /usr/bin
, some Debian systems, and various other distributions, so binaries appear in both locations.
Packages can ship files in either location; to find the package providing a given binary, look for bin/
followed by the binary:
dpkg -S bin/uname

Stephen Kitt
- 434,908
-
Wait, so
dpkg -S
does not require a full path? Also, the OP is on Debian, not Ubuntu (in case that makes a difference). Also, I think part of the problem is that the OP usedwhich
which will just return the first hit in the PATH, so they only saw the one file, not two. – terdon Nov 04 '20 at 18:22 -
No,
dpkg -S
doesn’t require a full path ;-). I missed the part about Debian... – Stephen Kitt Nov 04 '20 at 19:07 -
Of course you missed it: the OP had tagged with Debian, and I removed the tag (since this isn't a question about Debian per se) but like an idiot, forgot to add something to the question mentioning Debian. Sorry! – terdon Nov 04 '20 at 19:17
-
Ah, that explains it! I agree that using
which
is misleading, I didn’t think it worth re-explaining since you’d addressed that; I thought it worth explaining thebin
/usr/bin
merge since that is also confusing (see this question for instance). – Stephen Kitt Nov 04 '20 at 19:22
dpkg -S
as Stephen explained. – terdon Nov 04 '20 at 19:18