Use the pkg search command to search for packages whose data matches the specified pattern.
Like the pkg contents command, the pkg search command examines the contents of packages. While the pkg contents command returns the contents, the pkg search command returns the names of packages that match the search query. The following table shows some of the similarities and differences between these two commands.
By default, the search query is a series of terms to be matched exactly except for case. Use the -I option to specify a case-sensitive search.
You can use ? and * wildcards in query terms. You can use single or double quotation marks to search for phrases. Be sure to take your shell into account when you use wildcards or quotation marks.
You can specify more than one query term. By default, multiple terms are joined with AND. You can explicitly join two terms with OR.
Search queries can be expressed in the following structured form:
The name of the package to search or a pattern that might match multiple packages.
The name of an action listed in the “Actions” section in the pkg(7) man page.
Usually selects an attribute of action as listed in the “Actions” section of the pkg(7) man page. See below for more information.
The value of index or a pattern that might match the value of index.
Missing fields are implicitly wildcarded. The token string can be explicitly wildcarded. Names of actions and indexes cannot be explicitly wildcarded.
The index is not necessarily the same as the name of an action attribute. For example, the index for the user action is name, while the name of that attribute is username.
Not all action attributes are searchable. For example, mode is an attribute of the file action, but mode is not a valid value for index.
The following example shows one way to find all possible indexes for an action:
$ pkg search :user::
This command shows that the only searchable attribute of a user action is name.
Some values of index are values derived from other attributes. For example, index can be basename, which is the last component of the path attribute of a file or dir action. Examples of useful values for index include basename and path for file and dir actions, the dependency type (require or group, for example) for depend actions, and driver_name and alias for driver actions.
The index can also be a special pseudo attribute name such as action.key (the key attribute of the action) or pkg.name. See the pkg(1) man page for a complete list.
The value of token is compared with the value of the attribute named by index. For example, in the following partial driver action, alias is an attribute name that could be specified for index, and pci14e* could be specified for token.
driver alias=pci14e4,1000 alias=pci14e4,1200 alias=pci14e4,1203
By default, results are displayed for all matching actions, which can yield multiple lines of results for one package. Use the -p option to list each matching package only once.
$ pkg search -Hpo pkg.name driver:alias:pci14e\* driver/network/ethernet/bge driver/network/ethernet/bnx driver/network/ethernet/bnxe
The syntax of a set action is slightly different. The two attributes of a set action are name and value. In this case, the value of index is the value of a name attribute, and the value of token is compared with the value of the matching value attribute. The following example shows a set action for a driver package:
set name=pkg.summary value="QLogic 57xxx 10/20GbE NIC Driver"
The following example specifies *driver* for package name, pkg.summary for index, and qlogic for token. The set action is implied because the pkg.summary attribute only applies to a set action. The search.match and pkg.name column specifiers are pseudo attributes. See the pkg(1) man page.
$ pkg search -o search.match,pkg.name \*driver\*::pkg.summary:qlogic SEARCH.MATCH PKG.NAME QLogic 570x/571x Gigabit Ethernet Driver driver/network/ethernet/bnx QLogic 57xxx 10/20GbE NIC Driver driver/network/ethernet/bnxe QLogic ISP Fibre Channel device storage and NIC driver driver/fc/qlc QLogic P3+ 10GbE NIC Driver driver/network/ethernet/qlcnic
The following command gives the same result as the preceding command:
$ pkg search -o search.match,pkg.name pkg.summary:'qlogic * driver'
Some well-defined values of set action name attributes include pkg.fmri, info.classification, pkg.description, and pkg.summary. See “Set Actions” in the pkg(7) man page.
By default, matches are displayed only for currently installed or newer package versions. Use the -f option to display all matched versions.
In the following example, the search token is the full path of a file system object:
$ pkg search /lib/libinetutil.so.1 INDEX ACTION VALUE PACKAGE path file lib/libinetutil.so.1 pkg:/email@example.com
The pkg search command searches package actions. The preceding command found the search token in the path attribute of a file action and shows that this file is delivered by the system/library package.
The following example specifies that the desired output is only the name of the package. Specifying the -l option can quicken the search because only installed packages are searched:
$ pkg search -Hlo pkg.name '*libinetutil*' system/library
If you do not specify the output you want, then using just the base name of the file as the search token, or using wild cards as shown above, shows that this file is delivered to six different directories and is the target of three links. Another way to show each package name only one time, instead of showing many lines of output for one package, is to use the -p option or enclose the search token in angle brackets. Depending on your shell, you might need to escape the angle brackets. The following commands have the same output:
$ pkg search -p '*libinetutil*' $ pkg search \<'*libinetutil*'\> PACKAGE PUBLISHER pkg:/firstname.lastname@example.org solaris
The -p option of the pkg verify command also tells you which package delivers a named file. In this case, you must specify the full path to the file relative to /:
$ pkg verify -vp lib/libinetutil.so.1 PACKAGE STATUS pkg://solaris/system/library OK
If you cannot find the package that delivers a file on your system, perhaps that file is not packaged. See the -p and --unpackaged options of the pkg verify command in Identifying Unpackaged File System Content.
To show which packages provide a particular SMF service, search for the name of the service as the value of the org.opensolaris.smf.fmri attribute.
$ pkg search -o pkg.name,search.match org.opensolaris.smf.fmri:\*network/http\* PKG.NAME SEARCH.MATCH web/proxy/privoxy svc:/network/http web/proxy/squid svc:/network/http web/server/lighttpd-14 svc:/network/http web/java-servlet/tomcat-8 svc:/network/http web/server/apache-24 svc:/network/http web/server/apache-24 svc:/network/http:apache24 web/server/lighttpd-14 svc:/network/http:lighttpd14 web/proxy/privoxy svc:/network/http:privoxy web/proxy/squid svc:/network/http:squid web/java-servlet/tomcat-8 svc:/network/http:tomcat8
In this case, each attribute has two values: the service name with and without the service instance name specified. The following example shows how this attribute is specified in the package manifest:
set name=org.opensolaris.smf.fmri value=svc:/network/http:apache24 value=svc:/network/http
The following example shows this same information with each package listed only once. The -p option cannot be used when requesting action-level output such as search.match. Escape the colon character so that it is interpreted as part of the token and not as another search query field.
$ pkg search -o pkg.name,search.match 'org.opensolaris.smf.fmri:*network/http\:*' PKG.NAME SEARCH.MATCH web/server/apache-24 svc:/network/http:apache24 web/server/lighttpd-14 svc:/network/http:lighttpd14 web/proxy/privoxy svc:/network/http:privoxy web/proxy/squid svc:/network/http:squid web/java-servlet/tomcat-8 svc:/network/http:tomcat8
IPS packages deliver users for daemons or other software to use.
The following command shows users that are delivered by installed packages:
$ pkg search -lo action.key user::
The following command shows which package delivers a particular user definition:
$ pkg search -o action.key,pkg.name user::openldap ACTION.KEY PKG.NAME openldap system/network/ldap/openldap
The following command shows an example of using the OR keyword:
$ pkg search -o action.key,pkg.name user::openldap OR user::sshd ACTION.KEY PKG.NAME openldap system/network/ldap/openldap sshd service/network/ssh
The following command shows which package delivers a particular bug fix:
$ pkg search -Ho pkg.shortfmri bugid
All packages that were modified to fix the bug are listed.
See Critical Patch Update Packages to learn how to identify which SRU delivered a particular CVE fix.
The following example identifies all installed packages that have “Source Code Management” in the value of their info.classification attribute:
$ pkg search -Hlo pkg.name info.classification:'source code management' pkg:/developer/versioning/sccs pkg:/developer/versioning/git pkg:/developer/versioning/mercurial-27
The following example shows the package metadata that is matched in this search:
set name=info.classification value="org.opensolaris.category.2008:Development/Source Code Management"
This information is displayed in the “Category” line in output from the pkg info command.
$ pkg info mercurial-27 Name: developer/versioning/mercurial-27 Summary: The Mercurial Source Control Management System Description: A fast, lightweight source control management system designed for efficient handling of very large distributed projects. Category: Development/Source Code Management State: Installed Publisher: solaris Version: 4.1.3 Branch: 22.214.171.124.1.10.0 Packaging Date: Mon Jul 02 16:32:13 2018 Last Install Time: Mon Aug 06 15:22:47 2018 Size: 9.90 MB FMRI: pkg://email@example.com:20180702T163213Z Project URL: http://mercurial-scm.org/ Source URL: https://www.mercurial-scm.org/release/mercurial-4.1.3.tar.gz
See Classification Values in Packaging and Delivering Software With the Image Packaging System in Oracle Solaris 11.4 for other classifications that you can search for.
You can also use the pkg list command with a guess at one of the components of the package name, as in the following examples:
$ pkg list -a '*versioning*' $ pkg list '*storage*' $ pkg list -n '*database*'
These examples show the packages that are dependencies of the specified package.
The following command shows that many packages have a require dependency on the system/network/ldap/openldap package:
$ pkg search -Hlo pkg.name require:system/network/ldap/openldap
The following pkg contents command confirms the results of the search for one of the search results. The requested output action.raw is a pseudo attribute that displays the action exactly as it appears in the package manifest.
$ pkg contents -t depend -a fmri='*openldap*' -o pkg.name,action.raw openscap PKG.NAME ACTION.RAW security/compliance/openscap depend fmri=pkg:/firstname.lastname@example.org type=require
The following example lists packages that have an exclude dependency on pkg:/driver/graphics/nvidiaR340:
$ pkg contents -rt depend -a type=exclude nvidiaR340 TYPE FMRI exclude pkg:/driver/graphics/nvidia exclude pkg:/driver/graphics/nvidiaR304 $ pkg search -o pkg.name,fmri 'depend:exclude:*nvidiaR340*' PKG.NAME FMRI driver/graphics/nvidia pkg:/driver/graphics/nvidiaR340 driver/graphics/nvidiaR304 pkg:/driver/graphics/nvidiaR340
The text installer and the default AI manifest in an Automated Installer installation install the solaris-large-server group package. The default installation manifest for non-global zones installs the solaris-small-server group package. The solaris-minimal-server group package installs the minimal supported set of packages required to run Oracle Solaris.
You can use the following search form to display the set of packages that is included in the specified group package.
$ pkg search -o type,fmri \*/solaris-minimal-server:depend:: TYPE FMRI require developer/debug/mdb require editor/vim/vim-core require group/system/solaris-core-platform group network/ping group network/ssh require package/pkg require release/name require release/notices group service/network/ssh require shell/bash require shell/ksh93 group shell/tcsh group shell/zsh require system/core-os require system/library/platform group system/network group system/rsyslog
The depend query field matches depend actions in the package. The -o option displays the values of the type and fmri attributes of the depend action. Recall that group packages do not specify file system content; group packages specify other packages that are part of the group. See Group Packages for more information about group packages.
The pkg search command is returning the value of an attribute of an action in a specified package. In this example, that attribute value is a package name. The number of results from this command can be larger than the number of the results from the similar pkg contents command shown in Listing All Installable Packages in a Group Package because these search results include the names of all packages that are named in depend actions of type group in the specified package, not just installable packages. For example, package variants and facets might be included that are not installable in this image. To see this difference, try both examples with the solaris-large-server package.