Difference between revisions of "Whatpackage"
From Knoppix Documentation Wiki
PeterChubb (Talk | contribs) m |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
To find what package a file belongs to I created the following script. | To find what package a file belongs to I created the following script. | ||
*There may be a quicker way to do this, please feel free to inform if you find it. | *There may be a quicker way to do this, please feel free to inform if you find it. | ||
+ | **There is: either use | ||
+ | dpkg -S filename | ||
+ | or if you have it installed, | ||
+ | dlocate filename | ||
+ | **-- [[User:PeterChubb|PeterChubb]] | ||
Ensure you are root, and run the following commands | Ensure you are root, and run the following commands | ||
Line 7: | Line 12: | ||
#!/bin/bash | #!/bin/bash | ||
echo checking for $1 | echo checking for $1 | ||
− | + | ||
for package in `dpkg -l | awk '{print $2}'` | for package in `dpkg -l | awk '{print $2}'` | ||
{ | { | ||
Line 14: | Line 19: | ||
if echo $file | grep $1 | if echo $file | grep $1 | ||
then | then | ||
− | echo $package | + | echo The file is from $package |
fi | fi | ||
} | } |
Latest revision as of 04:45, 20 July 2006
To find what package a file belongs to I created the following script.
- There may be a quicker way to do this, please feel free to inform if you find it.
- There is: either use
dpkg -S filename
or if you have it installed,
dlocate filename
- -- PeterChubb
Ensure you are root, and run the following commands
cat > /usr/bin/whichpkg << EOF #!/bin/bash echo checking for $1 for package in `dpkg -l | awk '{print $2}'` { for file in `dpkg --listfiles $package 2> /dev/null` { if echo $file | grep $1 then echo The file is from $package fi } } EOF chmod 755 /usr/bin/whichpkg
Now that the script is in place, to find the file simply use the command
whichpkg filename
For example, to find out whatpackage /etc/init.d/knoppix-autoconfig comes from you tupe
whichpkg knoppix-autoconfig
This takes some time as it searches everypackage for the result. Hope this helps.
SNIa 03:34, 8 Jul 2006 (GMT)