← Back to DevOpsCommands

Oracle Cloud Infrastructure

OCI CLI Commands Cheat Sheet

Practical Oracle Cloud Infrastructure CLI commands for Compute, Object Storage, VCN networking, OKE Kubernetes, Container Registry, IAM, Vault, databases, monitoring, logging and DevOps automation.

OCI CLI Command Structure

OCI CLI commands generally follow the structure:

oci <service> <type> <action> <options>

For example, Compute uses the service compute, the resource type instance, and actions such as list, get, launch and terminate.

Showing 179 commands.

OCI CLI Setup and Version

oci --version

Display the installed OCI CLI version.

oci -v

Short form for displaying the OCI CLI version.

oci --help

Display global OCI CLI help.

oci -h

Short form for OCI CLI help.

oci -i

Enable interactive mode with command completion and parameter suggestions.

oci --latest-version

Display the latest available OCI CLI version.

OCI CLI Installation

bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"

Install OCI CLI on Linux or Unix-like systems.

bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)" -- --accept-all-defaults

Install OCI CLI while accepting the installation script defaults.

iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.ps1'))

Install the OCI CLI on Windows using the official installer.

brew install oci-cli

Install OCI CLI using Homebrew on macOS.

oci --help

Verify that OCI CLI is available after installation.

OCI Configuration and Profiles

oci setup config

Create or configure the OCI CLI configuration file and API key authentication.

oci setup repair-file-permissions --file ~/.oci/config

Repair permissions on an OCI CLI configuration file.

oci iam region list

List OCI regions available to the tenancy.

oci iam region-subscription list --tenancy-id <tenancy_ocid>

List regions subscribed by a tenancy.

oci --profile DEFAULT iam region list

Run an OCI command using a specific configuration profile.

OCI Authentication

oci session authenticate

Authenticate using an OCI CLI session and browser-based login.

oci iam user get --user-id <user_ocid>

Retrieve details about an IAM user.

oci iam tenancy get --tenancy-id <tenancy_ocid>

Retrieve tenancy information.

oci iam availability-domain list --compartment-id <compartment_ocid>

List availability domains available in a compartment.

oci --auth instance_principal compute instance list --compartment-id <compartment_ocid>

Authenticate using an instance principal when running from an OCI instance.

OCI Compartments

oci iam compartment list --compartment-id-in-subtree true

List compartments recursively under the tenancy.

oci iam compartment get --compartment-id <compartment_ocid>

Get details about a compartment.

oci iam compartment create --compartment-id <parent_compartment_ocid> --name <name> --description <description>

Create a new compartment.

oci iam compartment update --compartment-id <compartment_ocid> --name <new_name>

Update a compartment.

oci iam compartment delete --compartment-id <compartment_ocid>

Delete a compartment.

OCI Compute Instances

oci compute instance list --compartment-id <compartment_ocid>

List compute instances in a compartment.

oci compute instance get --instance-id <instance_ocid>

Get details about a compute instance.

oci compute instance launch --compartment-id <compartment_ocid> --availability-domain <availability_domain> --subnet-id <subnet_ocid> --shape <shape> --image-id <image_ocid>

Launch a compute instance.

oci compute instance start --instance-id <instance_ocid>

Start a stopped compute instance.

oci compute instance stop --instance-id <instance_ocid>

Stop a running compute instance.

oci compute instance reboot --instance-id <instance_ocid>

Reboot a compute instance.

oci compute instance terminate --instance-id <instance_ocid>

Terminate a compute instance.

oci compute instance action --instance-id <instance_ocid> --action softreset

Perform a supported lifecycle action on an instance.

OCI Compute Images

oci compute image list --compartment-id <compartment_ocid>

List compute images available in a compartment.

oci compute image get --image-id <image_ocid>

Get details about a compute image.

oci compute image list --compartment-id <compartment_ocid> --operating-system <operating_system>

Filter images by operating system.

oci compute instance-image list --compartment-id <compartment_ocid>

List custom instance images.

OCI Block Volumes

oci bv volume list --compartment-id <compartment_ocid>

List block volumes.

oci bv volume get --volume-id <volume_ocid>

Get block volume details.

oci bv volume create --compartment-id <compartment_ocid> --availability-domain <availability_domain> --size-in-gbs <size>

Create a block volume.

oci compute volume-attachment list --compartment-id <compartment_ocid> --instance-id <instance_ocid>

List volumes attached to a compute instance.

oci compute volume-attachment attach-paravirtualized-volume --instance-id <instance_ocid> --volume-id <volume_ocid>

Attach a block volume to a compute instance.

oci bv volume delete --volume-id <volume_ocid>

Delete a block volume.

OCI Object Storage

oci os ns get

Get the Object Storage namespace for the tenancy.

oci os bucket list --compartment-id <compartment_ocid>

List Object Storage buckets.

oci os bucket get --bucket-name <bucket_name> --namespace-name <namespace>

Get details about an Object Storage bucket.

oci os bucket create --compartment-id <compartment_ocid> --name <bucket_name> --namespace-name <namespace>

Create an Object Storage bucket.

oci os object list --bucket-name <bucket_name> --namespace-name <namespace>

List objects in a bucket.

oci os object put --bucket-name <bucket_name> --file <file_path> --name <object_name> --namespace-name <namespace>

Upload a local file to Object Storage.

oci os object get --bucket-name <bucket_name> --name <object_name> --file <output_file> --namespace-name <namespace>

Download an object from Object Storage.

oci os object delete --bucket-name <bucket_name> --name <object_name> --namespace-name <namespace>

Delete an object from Object Storage.

OCI VCN Networking

oci network vcn list --compartment-id <compartment_ocid>

List Virtual Cloud Networks.

oci network vcn get --vcn-id <vcn_ocid>

Get VCN details.

oci network vcn create --compartment-id <compartment_ocid> --cidr-block <cidr>

Create a VCN with an IPv4 CIDR block.

oci network subnet list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid>

List subnets in a VCN.

oci network subnet get --subnet-id <subnet_ocid>

Get subnet details.

oci network subnet create --compartment-id <compartment_ocid> --vcn-id <vcn_ocid> --cidr-block <cidr>

Create a subnet.

oci network vcn delete --vcn-id <vcn_ocid>

Delete a VCN.

OCI Internet Gateways and Routes

oci network internet-gateway list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid>

List internet gateways in a VCN.

oci network internet-gateway create --compartment-id <compartment_ocid> --vcn-id <vcn_ocid> --is-enabled true --display-name <name>

Create and enable an internet gateway.

oci network route-table list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid>

List route tables.

oci network route-table get --rt-id <route_table_ocid>

Get route table details.

oci network route-table update --rt-id <route_table_ocid> --route-rules <route_rules_json>

Update route rules.

OCI Security Lists and NSGs

oci network security-list list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid>

List VCN security lists.

oci network security-list get --security-list-id <security_list_ocid>

Get security list details.

oci network nsg list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid>

List network security groups.

oci network nsg get --nsg-id <nsg_ocid>

Get NSG details.

oci network nsg create --compartment-id <compartment_ocid> --vcn-id <vcn_ocid>

Create a network security group.

oci network nsg rules add --nsg-id <nsg_ocid> --security-rules <rules_json>

Add rules to a network security group.

OCI Public IP

oci network public-ip list --compartment-id <compartment_ocid>

List public IP resources.

oci network public-ip get --public-ip-id <public_ip_ocid>

Get public IP details.

oci network public-ip create --compartment-id <compartment_ocid> --lifetime RESERVED

Create a reserved public IP.

oci network public-ip delete --public-ip-id <public_ip_ocid>

Delete a public IP.

OCI Load Balancer

oci lb load-balancer list --compartment-id <compartment_ocid>

List load balancers.

oci lb load-balancer get --load-balancer-id <load_balancer_ocid>

Get load balancer details.

oci lb backend-set list --load-balancer-id <load_balancer_ocid>

List backend sets.

oci lb backend list --load-balancer-id <load_balancer_ocid> --backend-set-name <backend_set_name>

List load balancer backends.

oci lb listener list --load-balancer-id <load_balancer_ocid>

List load balancer listeners.

oci lb load-balancer delete --load-balancer-id <load_balancer_ocid>

Delete a load balancer.

OKE Kubernetes

oci ce cluster list --compartment-id <compartment_ocid>

List OKE Kubernetes clusters.

oci ce cluster get --cluster-id <cluster_ocid>

Get OKE cluster details.

oci ce cluster create-k8s-object-storage-uri --cluster-id <cluster_ocid>

Create an object storage URI for Kubernetes cluster configuration or related operations.

oci ce node-pool list --compartment-id <compartment_ocid>

List OKE node pools.

oci ce node-pool get --node-pool-id <node_pool_ocid>

Get OKE node pool details.

oci ce node-pool list --cluster-id <cluster_ocid> --compartment-id <compartment_ocid>

List node pools belonging to an OKE cluster.

OKE Kubernetes Kubeconfig

oci ce cluster create-kubeconfig --cluster-id <cluster_ocid> --file $HOME/.kube/config

Generate a kubeconfig file for an OKE cluster.

oci ce cluster create-kubeconfig --cluster-id <cluster_ocid> --file $HOME/.kube/config --region <region>

Generate an OKE kubeconfig while explicitly selecting a region.

kubectl get nodes

Verify that Kubernetes nodes are accessible after configuring kubeconfig.

kubectl get pods -A

List pods across all Kubernetes namespaces.

OCI Container Registry

oci artifacts container repository list --compartment-id <compartment_ocid>

List container repositories in Artifact Registry.

oci artifacts container repository get --repository-id <repository_ocid>

Get container repository details.

oci artifacts container image list --compartment-id <compartment_ocid>

List container images.

oci artifacts container image get --image-id <image_ocid>

Get container image details.

docker login <region-key>.ocir.io

Authenticate Docker to an OCI Container Registry endpoint using appropriate OCI credentials.

OCI IAM Users and Groups

oci iam user list --compartment-id <tenancy_ocid>

List IAM users.

oci iam user get --user-id <user_ocid>

Get IAM user details.

oci iam group list --compartment-id <tenancy_ocid>

List IAM groups.

oci iam group get --group-id <group_ocid>

Get IAM group details.

oci iam group-membership list --group-id <group_ocid>

List members of an IAM group.

OCI IAM Policies

oci iam policy list --compartment-id <compartment_ocid>

List IAM policies.

oci iam policy get --policy-id <policy_ocid>

Get IAM policy details.

oci iam policy create --compartment-id <compartment_ocid> --name <name> --description <description> --statements <statements_json>

Create an IAM policy.

oci iam policy update --policy-id <policy_ocid> --statements <statements_json>

Update IAM policy statements.

OCI Dynamic Groups and Instance Principals

oci iam dynamic-group list --compartment-id <tenancy_ocid>

List dynamic groups.

oci iam dynamic-group get --dynamic-group-id <dynamic_group_ocid>

Get dynamic group details.

oci iam dynamic-group create --compartment-id <tenancy_ocid> --name <name> --description <description> --matching-rule <matching_rule>

Create a dynamic group.

oci --auth instance_principal os ns get

Use instance principal authentication to access OCI services from an OCI compute instance.

OCI Vault and Secrets

oci kms management vault list --compartment-id <compartment_ocid>

List OCI Vaults.

oci kms management vault get --vault-id <vault_ocid>

Get Vault details.

oci vault secret list --compartment-id <compartment_ocid>

List secrets in a compartment.

oci vault secret get --secret-id <secret_ocid>

Get secret metadata.

oci secrets secret-bundle get --secret-id <secret_ocid>

Retrieve a secret bundle.

OCI DNS

oci dns zone list --compartment-id <compartment_ocid>

List DNS zones.

oci dns zone get --zone-name-or-id <zone_name_or_id>

Get DNS zone details.

oci dns record domain list --zone-name-or-id <zone_name_or_id> --domain <domain>

List DNS records for a domain.

oci dns record domain patch --zone-name-or-id <zone_name_or_id> --domain <domain> --items <records_json>

Update DNS records using a patch operation.

OCI Monitoring

oci monitoring metric-data summarize-metrics-data --compartment-id <compartment_ocid> --namespace <namespace> --query-text <query>

Query OCI Monitoring metric data.

oci monitoring alarm list --compartment-id <compartment_ocid>

List monitoring alarms.

oci monitoring alarm get --alarm-id <alarm_ocid>

Get monitoring alarm details.

oci monitoring alarm-history-collection get-alarm-history --alarm-id <alarm_ocid>

Retrieve monitoring alarm history.

OCI Logging

oci logging log-group list --compartment-id <compartment_ocid>

List logging groups.

oci logging log list --log-group-id <log_group_ocid>

List logs in a log group.

oci logging search search-logs --search-query <search_query> --time-start <start_time> --time-end <end_time>

Search OCI logs using a logging search query.

oci logging log get --log-group-id <log_group_ocid> --log-id <log_ocid>

Get log configuration details.

OCI Audit

oci audit event list --compartment-id <compartment_ocid> --start-time <start_time> --end-time <end_time>

List audit events for a specified time range.

oci audit event list --compartment-id <compartment_ocid> --event-type <event_type>

Filter audit events by event type.

OCI Database

oci db system list --compartment-id <compartment_ocid>

List DB systems.

oci db system get --db-system-id <db_system_ocid>

Get DB system details.

oci db system launch --compartment-id <compartment_ocid> --db-home <db_home_json> --database <database_json> --shape <shape>

Launch a DB system.

oci db database list --compartment-id <compartment_ocid> --db-system-id <db_system_ocid>

List databases in a DB system.

OCI MySQL Database

oci mysql db-system list --compartment-id <compartment_ocid>

List MySQL DB systems.

oci mysql db-system get --db-system-id <db_system_ocid>

Get MySQL DB system details.

oci mysql db-system create --compartment-id <compartment_ocid> --shape-name <shape> --subnet-id <subnet_ocid> --admin-username <username>

Create a MySQL DB system.

oci mysql db-system delete --db-system-id <db_system_ocid>

Delete a MySQL DB system.

OCI Functions

oci fn application list --compartment-id <compartment_ocid>

List OCI Functions applications.

oci fn function list --application-id <application_ocid>

List functions in an application.

oci fn function get --function-id <function_ocid>

Get function details.

fn deploy --app <application_name>

Build and deploy an OCI Functions application using the Fn CLI.

fn invoke <application_name> <function_name>

Invoke an OCI Function using the Fn CLI.

OCI Resource Manager

oci resource-manager stack list --compartment-id <compartment_ocid>

List Resource Manager stacks.

oci resource-manager stack get --stack-id <stack_ocid>

Get stack details.

oci resource-manager job list --compartment-id <compartment_ocid>

List Resource Manager jobs.

oci resource-manager job get --job-id <job_ocid>

Get Resource Manager job details.

oci resource-manager job create-plan-job --stack-id <stack_ocid>

Create a Terraform plan job.

oci resource-manager job create-apply-job --stack-id <stack_ocid>

Create a Terraform apply job.

OCI DevOps

oci devops project list --compartment-id <compartment_ocid>

List OCI DevOps projects.

oci devops project get --project-id <project_ocid>

Get DevOps project details.

oci devops repository list --project-id <project_ocid>

List DevOps repositories.

oci devops build-pipeline list --project-id <project_ocid>

List DevOps build pipelines.

oci devops deployment-pipeline list --project-id <project_ocid>

List deployment pipelines.

oci devops deployment list --compartment-id <compartment_ocid>

List DevOps deployments.

OCI Work Requests

oci work-requests work-request list --compartment-id <compartment_ocid>

List work requests.

oci work-requests work-request get --work-request-id <work_request_ocid>

Get work request details.

oci work-requests work-request-error list --work-request-id <work_request_ocid>

List errors associated with a work request.

oci work-requests work-request-log-entry list --work-request-id <work_request_ocid>

List work request log entries.

OCI CLI Output and Filtering

oci os bucket list --compartment-id <compartment_ocid> --output table

Display command output in table format.

oci compute instance list --compartment-id <compartment_ocid> --query 'data[].{name:"display-name",state:"lifecycle-state"}'

Use a JMESPath query to select fields from OCI CLI JSON output.

oci compute instance list --compartment-id <compartment_ocid> --raw-output --query 'data[0]."display-name"'

Return a single queried string without surrounding JSON quotes.

oci os bucket get --bucket-name <bucket_name> --namespace-name <namespace> --generate-full-command-json-input

Generate a JSON template containing the command's possible parameters.

oci --profile PROD compute instance list --compartment-id <compartment_ocid>

Run an OCI CLI command using the PROD profile.

OCI CLI Troubleshooting

oci --debug iam region list

Enable debug output for troubleshooting CLI requests.

oci --config-file ~/.oci/config --profile DEFAULT iam region list

Explicitly select an OCI configuration file and profile.

oci --region <region> iam region list

Explicitly target an OCI region.

oci --auth api_key iam region list

Explicitly use API key authentication.

oci --no-retry compute instance get --instance-id <instance_ocid>

Disable OCI CLI retry behavior for a request.

oci --connection-timeout 30 iam region list

Increase the connection timeout for a CLI request.

OCI DevOps Workflow

oci artifacts container repository list --compartment-id <compartment_ocid>

Verify that the target OCI container repository exists.

docker build -t <region-key>.ocir.io/<namespace>/<repository>:<tag> .

Build a Docker image for an OCI Container Registry repository.

docker push <region-key>.ocir.io/<namespace>/<repository>:<tag>

Push a Docker image to OCI Container Registry.

oci ce cluster create-kubeconfig --cluster-id <cluster_ocid> --file $HOME/.kube/config

Configure kubectl access to an OKE cluster.

kubectl set image deployment/<deployment> <container>=<image>:<tag>

Update a Kubernetes deployment image after a container build.

oci resource-manager job create-apply-job --stack-id <stack_ocid>

Trigger a Terraform apply job through OCI Resource Manager.

Useful OCI DevOps Commands

oci iam availability-domain list --compartment-id <compartment_ocid>

Check available availability domains.

oci compute instance list --compartment-id <compartment_ocid> --output table

Quickly inspect compute instances in table format.

oci os bucket list --compartment-id <compartment_ocid> --output table

Quickly inspect Object Storage buckets.

oci network subnet list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid> --output table

Quickly inspect VCN subnets.

oci ce cluster list --compartment-id <compartment_ocid> --output table

Quickly inspect OKE clusters.

oci monitoring alarm list --compartment-id <compartment_ocid> --output table

Quickly inspect monitoring alarms.

Recommended OCI DevOps Workflow

1. Authenticate

oci session authenticate

2. Check the target compartment

oci iam compartment get --compartment-id <compartment_ocid>

3. Inspect Compute or OKE

oci compute instance list --compartment-id <compartment_ocid>

4. Build and push a container

docker build -t <region-key>.ocir.io/<namespace>/<repository>:<tag> .

5. Deploy to OKE

kubectl set image deployment/<deployment> <container>=<image>:<tag>

6. Monitor the environment

oci monitoring alarm list --compartment-id <compartment_ocid>