Find which installed package manages /bin/bash.
Use the local package database for a reverse lookup.
Which command is appropriate?
dpkg -S PATTERN searches the file lists in the local package database and reports the package owning a matching path.
Detailed explanation
dpkg -S /bin/bashCorrect. dpkg -S /bin/bash reports the installed package that owns the path.
Correct. dpkg -S /bin/bash reports the installed package that owns the path.
dpkg -L /bin/bashIncorrect. -L expects a package name and lists its files.
Incorrect. -L expects a package name and lists its files.
dpkg -i /bin/bashIncorrect. -i installs a local deb archive.
Incorrect. -i installs a local deb archive.
dpkg -r /bin/bashIncorrect. -r removes an installed package.
Incorrect. -r removes an installed package.
Try it yourself
An example you can run in a temporary verification environment.
dpkg -S /bin/bash 2>/dev/null || dpkg -S /usr/bin/bashExpected result
bash: /bin/bash等、所有パッケージとパスKey points
- -S searches ownership
- The local database is queried
- Uninstalled packages are not included
Notes
- Environment: Debian系 / dpkg-query・merged-/usr対応
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.