The Oracle Cloud Infrastructure CLI (oci-cli) is a command-line interface that allows users to interact with Oracle Cloud Infrastructure services. Built on the OCI Python SDK, it provides equivalent functionality to the OCI Console, plus additional commands and scripting capabilities. The current version is 3.78.0, and it is actively maintained by Oracle with frequent updates and new feature releases.
pip install oci-cliVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the underlying OCI Python SDK to list compartments within your Oracle Cloud Infrastructure tenancy. Before running, ensure you have configured your OCI CLI by running `oci setup config` in your terminal to create the `~/.oci/config` file and API keys. The script loads this configuration for authentication.
Consult the `CHANGELOG.rst` or GitHub release notes for the specific version you are upgrading to and update your scripts/commands accordingly. Example: `--software-source-ids` became a required parameter in `oci os-management-hub profile create-software-source-profile` in a recent update.
Replace `--defaults-file` with `--cli-rc-file` in your CLI commands and scripts.
Migrate all ML application instances to use Oracle Cloud Infrastructure Identity and Access Management (IAM) for authentication and authorization.
Run `oci setup config` to generate the configuration file and API keys. Ensure the public key is uploaded to your OCI user in the Console, and the private key file path and fingerprint in `~/.oci/config` are correct and accessible.
Familiarize yourself with JMESPath (jmespath.org). For large datasets, consider using `--filter` with SCIM expressions (which might use different attribute names than the CLI output) alongside `--query` to reduce client-side processing.
Ensure the OCI CLI is installed in an accessible location and its executable directory (e.g., `~/bin` or Python's `Scripts` directory on Windows) is included in your system's PATH. If using a virtual environment, activate it. On Windows, you might need to add `C:\Users\<username>\AppData\Roaming\Python\Scripts` to your PATH.
Run `oci setup config` to reconfigure your CLI. Verify that your `~/.oci/config` file contains the correct `user`, `fingerprint`, `key_file` path, `tenancy`, and `region`. Ensure the private key file has appropriate permissions (e.g., `600`) and the corresponding public key is uploaded to your OCI user's API Keys in the OCI Console.
Check if the `~/.oci/config` file exists in the expected location (e.g., `/home/user/.oci/config` on Linux/macOS or `C:\Users\<username>\.oci\config` on Windows). If not, run `oci setup config` to create it. Ensure the `.oci` directory and `config` file have restrictive permissions (e.g., `chmod 700 ~/.oci` and `chmod 600 ~/.oci/config`).
Verify that the resource OCID is correct and that the resource exists. Review your IAM policies in the OCI Console to ensure your user or group has the required permissions for the operation and the resource's compartment. If accessing a resource in a specific compartment, confirm the compartment ID is correct.