{"id":4144,"library":"oci-cli","title":"Oracle Cloud Infrastructure CLI","description":"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.","status":"active","version":"3.78.0","language":"en","source_language":"en","source_url":"https://github.com/oracle/oci-cli","tags":["oracle cloud","oci","cli","cloud management","sdk","infrastructure-as-code"],"install":[{"cmd":"pip install oci-cli","lang":"bash","label":"Install the CLI via pip (recommended for Python environments)"},{"cmd":"bash -c \"$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)\"","lang":"bash","label":"Installer script for Linux/Unix (includes dependencies)"}],"dependencies":[{"reason":"The core Oracle Cloud Infrastructure Python SDK, which the CLI is built upon.","package":"oci","optional":false},{"reason":"Used for secure communications and API key management.","package":"cryptography","optional":false},{"reason":"Used for parsing and managing configuration files.","package":"PyYAML","optional":false},{"reason":"Used for powerful JSON querying capabilities, especially with the `--query` flag.","package":"jmespath","optional":false}],"imports":[{"note":"While `oci-cli` is the installed package, the underlying Python SDK for programmatic interaction is imported as `oci`. Do not attempt to import modules directly from `oci_cli` as it primarily contains CLI internals.","wrong":"import oci_cli","symbol":"oci","correct":"import oci"}],"quickstart":{"code":"# First, ensure your OCI configuration file (~/.oci/config) is set up.\n# You can generate one interactively using: oci setup config\n#\n# Then, use the OCI Python SDK (installed with oci-cli):\n\nimport oci\nimport os\n\n# Load the OCI config from the default location and profile\n# (or specify path and profile like oci.config.from_file(\"/path/to/config\", \"YOUR_PROFILE\"))\ntry:\n    config = oci.config.from_file(os.environ.get('OCI_CONFIG_FILE', '~/.oci/config'), os.environ.get('OCI_PROFILE', 'DEFAULT'))\nexcept oci.exceptions.ConfigFileNotFound as e:\n    print(f\"Error: OCI config file not found. Please run 'oci setup config' or set OCI_CONFIG_FILE and OCI_PROFILE environment variables. {e}\")\n    exit(1)\n\n# Create an IdentityClient\nidentity_client = oci.identity.IdentityClient(config)\n\n# Get the tenancy OCID from the config\ntenancy_id = config[\"tenancy\"]\n\n# List compartments in the tenancy\ntry:\n    list_compartments_response = identity_client.list_compartments(compartment_id=tenancy_id, compartment_id_in_subtree=True)\n    print(\"Listing Compartments:\")\n    for compartment in list_compartments_response.data:\n        print(f\"  Name: {compartment.name}, ID: {compartment.id}, Lifecycle State: {compartment.lifecycle_state}\")\nexcept oci.exceptions.ServiceError as e:\n    print(f\"Error listing compartments: {e}\")\n    if e.code == 'NotAuthenticated':\n        print(\"Please check your API key and fingerprint in ~/.oci/config.\")\n    elif e.code == 'AuthRequired':\n        print(\"Authentication failed. Ensure your API key is correctly configured and has necessary permissions.\")\n\n","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"Breaking changes occur frequently in new releases, often involving parameter renames, commands being moved, or parameters becoming required. Always review the GitHub releases page or `CHANGELOG.rst` before upgrading major or minor versions.","severity":"breaking","affected_versions":"All versions (check release notes for specific changes)"},{"fix":"Replace `--defaults-file` with `--cli-rc-file` in your CLI commands and scripts.","message":"The `--defaults-file` CLI option is deprecated. Use `--cli-rc-file` instead for specifying CLI-specific configuration files.","severity":"gotcha","affected_versions":"All versions where `--defaults-file` is used"},{"fix":"Migrate all ML application instances to use Oracle Cloud Infrastructure Identity and Access Management (IAM) for authentication and authorization.","message":"OCI Data Science is deprecating Oracle Identity Cloud Service (IDCS) authentication for ML Applications. After April 11, 2026, deployments using IDCS-based authentication will not be supported, and new ML application instances cannot be created using IDCS.","severity":"breaking","affected_versions":"ML Application instances using IDCS authentication, effective April 11, 2026"},{"fix":"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.","message":"The OCI CLI (and SDK) requires a properly configured `~/.oci/config` file and corresponding API key pair for authentication. Incorrect setup or permissions is a common source of errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"When querying JSON output with `--query`, the argument uses JMESPath syntax. This is powerful but can be unfamiliar and requires understanding JMESPath expressions for effective filtering and transformation. Using `--filter` provides SCIM-based filtering *before* `--query` is applied.","severity":"gotcha","affected_versions":"All versions using `--query`"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}