Go to main content

Updating Systems and Adding Software in Oracle® Solaris 11.4

Exit Print View

Updated: August 2018

Uninstalling Packages

Use the pkg uninstall command to remove installed packages.

When a package is uninstalled, the command output is very similar to the output when a package is installed, with "Packages to remove" instead of "Packages to install" for example.

The --reject option of the pkg install command can also remove installed packages, as described in Rejecting a Package.

Uninstalling a package can cause a mediated link to be removed as described in Setting a Preferred Path that is Not Available: Consequences and Recovery. Use the -nv or -nvv options to check whether a mediated link will be removed.

For information about how a file action with certain attributes is treated when the package that delivers the file is uninstalled, see File Actions in Packaging and Delivering Software With the Image Packaging System in Oracle Solaris 11.4 or the pkg(7) man page.

Example 6  Undoing a Package Installation

Uninstalling a package does not uninstall dependencies of that package. A user might want to continue to use the content delivered by a dependency package even if the only package that requires the dependency is uninstalled.

If you want to undo a package installation operation so that you uninstall all packages that the installation operation installed, use the pkg history command to determine exactly what was installed. See Viewing Operation History for more information.

In the example shown in Previewing Package Installation, four packages were installed. However, the following command shows that only the package named on the command line is removed by uninstall:

$ pkg uninstall -v oracle-rdbms-server-18c-preinstall
            Packages to remove:         1
     Estimated space available: 852.20 GB
Estimated space to be consumed: 455.25 MB
          Rebuild boot archive:        No

Changed packages:
    11.4- -> None

The pkg list command shows that the other three packages that were installed are still installed:

$ pkg -R /mnt list oracle-rdbms-server-18c-preinstall system/kernel/oracka \
x11/diagnostic/x11-info-clients x11/library/libdmx
NAME (PUBLISHER)                               VERSION                    IFO
system/kernel/oracka                           11.4-       i--
x11/diagnostic/x11-info-clients                7.7-        i--
x11/library/libdmx                             1.1.3-      i--

pkg list: no packages matching the following patterns are installed:

To undo this installation if you do not have the original pkg install output, find the list of packages that were installed in the history. Use a short listing to find the installation command that you want, and then use the -l option to list exactly what was installed at that time (-t), as shown in Viewing Operation History. The list is at the end of the output under the heading End State.

$ pkg history -n 1
START                    OPERATION                CLIENT             OUTCOME
2018-08-06T12:36:43      install                  pkg                Succeeded
$ pkg history -lt 2018-08-06T12:36:43
         Operation: install
           Command: /usr/bin/pkg install --be-name rdbms oracle-rdbms-server-18c-preinstall
         End State:
None -> pkg://solaris/x11/diagnostic/x11-info-clients@7.7,5.11-
None -> pkg://solaris/group/prerequisite/oracle/oracle-rdbms-server-18c-preinstall@11.4,5.11-
None -> pkg://solaris/system/kernel/oracka@11.4,5.11-
None -> pkg://solaris/x11/library/libdmx@1.1.3,5.11-
Example 7  Specifying Multiple Packages to Uninstall

If you specify multiple packages to the pkg uninstall command, or if you specify options such as -r to perform this operation in non-global zones, you might be attempting to uninstall a package that is not installed in that image.

If you attempt to uninstall a package that is not currently installed, the pkg uninstall operation exits without uninstalling any packages.

When a package to be uninstalled does not exist in that image, a message about no matching packages is displayed for that package name. If additional packages to be uninstalled do exist in the image, no message is displayed to tell you that those packages were not uninstalled.

To uninstall all specified packages that are installed and skip the operation for any specified packages that are not installed, use the --ignore-missing option. The --ignore-missing option ignores packages that are not installed and prevents pkg uninstall from failing if some packages to uninstall are not currently installed.

In the following command, if one zone does not have the git package installed, no packages are uninstalled, even if some zones do have git installed:

$ pkg uninstall -r git

In the following command, the git package is uninstalled from any zone where it is currently installed:

$ pkg uninstall -r --ignore-missing git
Example 8  Uninstalling a Package that is Required by Another Package

Attempting to uninstall a package that is required by another installed package fails.

For example, if you try to uninstall the libdmx package while the x11-info-clients package is still installed, you receive the following error message:

$ pkg uninstall libdmx
pkg uninstall: Unable to remove 'x11/library/libdmx@1.1.3-' due to the following packages that depend on it:

To uninstall libdmx, you must uninstall both libdmx and x11-info-clients. Recall that simply uninstalling x11-info-clients does not uninstall the dependent package libdmx.

$ pkg uninstall x11-info-clients libdmx
Example 9  Uninstalling a Package that is a group Dependency

When you uninstall a package that is a group dependency, that package is placed on the avoid list. See Avoiding Installing Some Packages in a Group Package for information about the avoid list.

$ pkg avoid
$ pkg uninstall mysql-56
$ pkg list mysql-56
pkg list: no packages matching the following patterns are installed:
$ pkg avoid
    database/mysql-56 (group dependency of 'group/feature/amp')