# Upgrade a Second-Generation Managed Package Version

A package upgrade occurs when you install a new package version into an org that has a previous version of that package installed.

When you perform a package upgrade, here’s what to expect for metadata changes.

- Metadata introduced in the new version is installed as part of the upgrade.
- Metadata modified in the new version is updated as part of the upgrade.
- Metadata removed in the new version is either deprecated or deleted as part of the upgrade.

To upgrade a package, use the package install CLI command

```nolang
sf package install --package 04t... --target-org me@example.com
```

For more examples and details about this command, see [package install](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_package_commands_unified.htm#cli_reference_package_install_unified) in the *Salesforce CLI Command Reference*.

Beta packages aren’t upgradeable. To install a new beta package or released version, first uninstall the beta package.

To upgrade a package version, the new version must be a direct descendent of the package version installed in your org. See [Specify a Package Ancestor in the Project File for a Second-Generation Managed Package](/docs/platform/pkg2-dev/guide/sfdx-dev-dev2gp-config-ancestors.md) for more information.

**See Also**

- [*Salesforce CLI Command Reference* package install](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_package_commands_unified.htm#cli_reference_package_install_unified)
