似乎成功安裝後未找到hwinfo


3

我使用sudo apt-get install hwinfo安裝了hwinfo,系統告訴我:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  hwinfo
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/32.8 kB of archives.
After this operation, 90.1 kB of additional disk space will be used.
Selecting previously unselected package hwinfo.
(Reading database ... 192008 files and directories currently installed.)
Preparing to unpack .../hwinfo_21.6-1_amd64.deb ...
Unpacking hwinfo (21.6-1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up hwinfo (21.6-1) ...

儘管我隨後輸入hwinfo時,它說的是command not foundman hwinfo有效,即顯示了手冊,但是locate hwinfo不返回任何內容。

我正在使用Debian 8.1

dpkg-query -L hwinfo顯示hwinfo位於/usr/sbin/hwinfo以下,並且直接調用也可以。所以我想這是路徑問題?

2

By running dpkg-query -L hwinfo you can view all the files installed by this package, together with their location.

So likely installed as /usr/sbin/hwinfo. Add /usr/sbin to your $PATH variable if you want to run it with simply the command hwinfo rather than the full path+command /usr/sbin/hwinfo.


1

The name of a package isn't always the same as the name of any command it contains. You can use dpkg -L hwinfo | grep bin/ to list the commands it provides (or apt-file list hwinfo | grep bin/ before installation).

The hwinfo package does include a command called hwinfo, but it's /usr/sbin/hwinfo. The sbin directories (/sbin, /usr/sbin, /usr/local/sbin) contain commands that are meant to be used only by root. This doesn't necessarily mean that these commands won't work if called by another user, just that they're unlikely to be useful. The sbin directories are normally in the command search path only for the root user.

You can run /usr/sbin/hwinfo as a non-root user, but its report is incomplete; it needs root access for some of the information it queries. Therefore run sudo hwinfo or su -c hwinfo to get complete output, or /usr/sbin/hwinfo if incomplete output is sufficient.

You shouldn't add /usr/sbin to your PATH as most of the commands it contains cannot be usefully run as a non-root user.