Software >> OS >> Unix >> Solaris >> 11 >> pkg command examples and how to patch using Oracle Solaris Support repository

 

Purpose Commands
List packages currently installed in a system
pkg list

List packages current installed that have pkg name containing java
pkg list *java*

NAME (PUBLISHER)                                  VERSION                    IFO
consolidation/java-7/java-7-incorporation         1.7.0.191.8-0              i--
consolidation/java-8/java-8-incorporation         1.8.0.181.12-0             i--
consolidation/java/java-incorporation             0.5.11-0.175.2.0.0.31.0    i-r
consolidation/ub_javavm-6/ub_javavm-6-incorporation 1.6.0.999.99-0             i--
consolidation/ub_javavm/ub_javavm-incorporation   0.5.11-0.175.2.0.0.31.0    i-r
library/java/javahelp                             0.5.11-0.175.1.0.0.11.1    i--
runtime/java/jre-7                                1.7.0.191.8                i--
runtime/java/jre-8                                1.8.0.181.12               i--
system/management/rad/client/rad-java             0.5.11-0.175.3.32.0.1.0    i--
web/browser/firefox/plugin/firefox-java           52.9.0-0.175.3.34.0.4.0    i--
List all installable packages in a Group Package
## e.g. list all packages in the group "solaris-minimal-install"

pkg contents -ro type,fmri -t depend solaris-minimal-server

TYPE    FMRI
group   network/ping
group   service/network/ssh-common
group   shell/tcsh
group   shell/zsh
group   system/network
require developer/debug/mdb
require editor/vim/vim-core
require group/system/solaris-core-platform
require package/pkg
require release/name
require release/notices
require shell/bash
require shell/ksh93
require system/core-os
require system/library/platform
Search for packages that depend on (i.e. require) a particular package
## For examle search for packages that require system/kernel/power package

pkg search -Hlo pkg.name require:system/kernel/power
Install a package named diagnostic/wireshark
pkg install diagnostic/wireshak
Uninstall a package named diagnostic/wireshark using a short form of the package name
pkg uninstall wireshark
Update all possible packages to the newest version, including Oracle Solaris zones
pkg update
Do a dry run of an update of all possible packages to the newest version
pkg update -nv
Identify which package delivers a specified file
## e.g. find which package provides the file /usr/bin/java

pkg search -Hlo pkg.name /usr/bin/java

runtime/java/jre-8
Identify which package delivers a specified SMF service
pkg search -o pkg.name,search.match 'org.opensolaris.smf.fmri:*/network/http'

PKG.NAME                  SEARCH.MATCH
web/java-servlet/tomcat-8 svc:/network/http
web/proxy/privoxy         svc:/network/http
web/proxy/squid           svc:/network/http
web/server/apache-22      svc:/network/http
web/server/lighttpd-14    svc:/network/http
web/server/apache-24      svc:/network/http

or

pkg search -o pkg.name,search.match 'org.opensolaris.smf.fmri:*/network/http*'

PKG.NAME                  SEARCH.MATCH
web/java-servlet/tomcat-8 svc:/network/http
web/proxy/privoxy         svc:/network/http
web/proxy/squid           svc:/network/http
web/server/apache-22      svc:/network/http
web/server/lighttpd-14    svc:/network/http
web/server/apache-24      svc:/network/http
web/server/apache-22      svc:/network/http:apache22
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
Show information about an installed package named firefox
pkg info firefox

             Name: web/browser/firefox
          Summary: Mozilla Firefox Web browser
         Category: Applications/Internet
            State: Installed
        Publisher: solaris
          Version: 52.9.0
    Build Release: 5.11
           Branch: 0.175.3.34.0.4.0
   Packaging Date: June 28, 2018 09:19:32 PM
Last Install Time: July 10, 2020 09:01:06 AM
             Size: 159.26 MB
             FMRI: pkg://solaris/web/browser/firefox@52.9.0,5.11-0.175.3.34.0.4.0:20180628T211932Z

 
Show the contents of an installed package named wireshark
pkg contents firefox

PATH
usr/bin/firefox
usr/lib/firefox/application.ini
usr/lib/firefox/browser/blocklist.xml
usr/lib/firefox/browser/chrome.manifest
usr/lib/firefox/browser/chrome/icons/default/default16.png
usr/lib/firefox/browser/chrome/icons/default/default32.png
usr/lib/firefox/browser/chrome/icons/default/default48.png
...
usr/lib/pkgconfig/firefox-xpcom.pc
usr/share/applications/firefox.desktop
usr/share/man/man1/firefox.1
usr/share/pixmaps/firefox-icon.png
Show all PNG files of an installed package named firefox
pkg contents -o path -a path=\*.png firefox

PATH
usr/lib/firefox/browser/chrome/icons/default/default16.png
usr/lib/firefox/browser/chrome/icons/default/default32.png
usr/lib/firefox/browser/chrome/icons/default/default48.png
usr/lib/firefox/browser/icons/mozicon128.png
usr/share/pixmaps/firefox-icon.png
Show all locally installed packages for the match gcc
pkg search -l gcc
Search all packages in the configured repositories that contain dev header gcrypt-module.h
pkg search 'gcrypt-module.h'
Search for all packages in the configured repositories that have the classification "Web Services/Application and Web Servers"
pkg search -o pkg.name 'set:info.classification:*Application and Web Servers'
Search for all packages installed locally that have a dependency on library/libxml2
pkg search -l -o pkg.name 'depend::library/libxml2'
Check whether a package is installed in a non-active Boot Environment
## note the boot env name

beadm list

## create mountpoint, mount that BE to the mountpoint

mkdir /altroot
beadm mount BEname /altroot

## verify the package

pkg -R /altroot verify -v packagename

List all SRUs available from the publishers that are configured on a system
pkg list -af entire@0.5.11-0.175.3
 NAME (PUBLISHER)                   VERSION                    IFO 
entire 0.5.11-0.175.3.27.0.4.0 ---
entire 0.5.11-0.175.3.26.0.5.0 ---
entire 0.5.11-0.175.3.25.0.3.0 ---
entire 0.5.11-0.175.3.24.0.4.0 ---
entire 0.5.11-0.175.3.23.0.5.0 ---
entire 0.5.11-0.175.3.22.0.3.0 ---

Update to a particular SRU that is available in the current pkg publisher and assigning a specific name to the BE  
pkg update --accept --be-name=11.3.32 entire@0.5.11-0.175.3.32.0.4.0


Change the default pkg publisher to Oracle Support Repository

This repository is available only to customers who have an active Oracle support agreement

## Follow the procedure here to download your private key and certificate for connecting to the Oracle Support Repository.  Assuming you have a valid Oracle Support. 

## If the keys are downloaded to /var/tmp/, set the publisher as follows


pkg set-publisher -k /var/tmp/pkg.oracle.com.key.pem \
                  -c /var/tmp/pkg.oracle.com.certificate.pem \
                  -g https://pkg.oracle.com/solaris/support/ solaris

Upgrade from solaris 11.3 to 11.4 using Oracle Support Repository
 

## Assuming that above step to set the publisher to Oracle Support repository

## List 11.4 releases

pkg list -af entire@11.4

(command output)
NAME (PUBLISHER)                                  VERSION                    IFO
entire                                            11.4-11.4.39.0.1.107.1     ---
entire                                            11.4-11.4.38.0.1.101.6     ---
entire                                            11.4-11.4.37.0.1.101.1     ---
entire                                            11.4-11.4.36.0.1.101.2     ---
entire                                            11.4-11.4.35.0.1.94.4      ---
entire                                            11.4-11.4.34.0.1.94.4      ---
entire                                            11.4-11.4.33.0.1.94.0      ---
...
entire                                            11.4-11.4.3.0.1.5.0        ---
entire                                            11.4-11.4.2.0.1.3.0        ---
entire                                            11.4-11.4.1.0.1.4.0        ---
entire                                            11.4-11.4.0.0.1.15.0       ---



## Upgrade to Solaris 11.4 GA release 11.4-11.4.0.0.1.15.0

pkg update --accept --be-name=11.4 entire@11.4-11.4.0.0.1.15.0






Query a repository URI for the publisher names and package counts
## e.g. Oracle Solaris 11 support repository - https and require client key and cert

pkgrepo info -s https://pkg.oracle.com/solaris/support  --key /var/tmp \
/pkg.oracle.com.key.pem --cert /var/tmp/pkg.oracle.com.certificate.pem


PUBLISHER PACKAGES STATUS           UPDATED
solaris   8804     online           2020-07-08T22:01:50.739293Z


## e.g. Oracle Solaris 11 release repository - http and publicly accessible

pkgrepo info -s http://pkg.oracle.com/solaris/release

PUBLISHER PACKAGES STATUS           UPDATED
solaris   6444     online           2020-07-08T01:37:29.534082Z