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 444 times
2
-
1Thank you for accepting an answer, but please accept Stephen's answer instead of mine. Mine is actually wrong: you _don't_ need the full path for `dpkg -S` as Stephen explained. – terdon Nov 04 '20 at 19:18
-
Oh, sorry i thought i could accept a couple of answears :) – MisterWM Nov 04 '20 at 20:18
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
- 234,489
- 66
- 447
- 667
-
... 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
- 411,918
- 54
- 1,065
- 1,164
-
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 used `which` 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 the `bin`/`usr/bin` merge since that is also confusing (see [this question](https://unix.stackexchange.com/q/607504/86440) for instance). – Stephen Kitt Nov 04 '20 at 19:22