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.
OCI CLI Command Categories
Jump directly to the OCI CLI commands you need.
OCI CLI Setup and Version
6OCI CLI commands for oci cli setup and version.
View commands →OCI CLI Installation
5OCI CLI commands for oci cli installation.
View commands →OCI Configuration and Profiles
5OCI CLI commands for oci configuration and profiles.
View commands →OCI Authentication
5OCI CLI commands for oci authentication.
View commands →OCI Compartments
5OCI CLI commands for oci compartments.
View commands →OCI Compute Instances
8OCI CLI commands for oci compute instances.
View commands →OCI Compute Images
4OCI CLI commands for oci compute images.
View commands →OCI Block Volumes
6OCI CLI commands for oci block volumes.
View commands →OCI Object Storage
8OCI CLI commands for oci object storage.
View commands →OCI VCN Networking
7OCI CLI commands for oci vcn networking.
View commands →OCI Internet Gateways and Routes
5OCI CLI commands for oci internet gateways and routes.
View commands →OCI Security Lists and NSGs
6OCI CLI commands for oci security lists and nsgs.
View commands →OCI Public IP
4OCI CLI commands for oci public ip.
View commands →OCI Load Balancer
6OCI CLI commands for oci load balancer.
View commands →OKE Kubernetes
6OCI CLI commands for oke kubernetes.
View commands →OKE Kubernetes Kubeconfig
4OCI CLI commands for oke kubernetes kubeconfig.
View commands →OCI Container Registry
5OCI CLI commands for oci container registry.
View commands →OCI IAM Users and Groups
5OCI CLI commands for oci iam users and groups.
View commands →OCI IAM Policies
4OCI CLI commands for oci iam policies.
View commands →OCI Dynamic Groups and Instance Principals
4OCI CLI commands for oci dynamic groups and instance principals.
View commands →OCI Vault and Secrets
5OCI CLI commands for oci vault and secrets.
View commands →OCI DNS
4OCI CLI commands for oci dns.
View commands →OCI Monitoring
4OCI CLI commands for oci monitoring.
View commands →OCI Logging
4OCI CLI commands for oci logging.
View commands →OCI Audit
2OCI CLI commands for oci audit.
View commands →OCI Database
4OCI CLI commands for oci database.
View commands →OCI MySQL Database
4OCI CLI commands for oci mysql database.
View commands →OCI Functions
5OCI CLI commands for oci functions.
View commands →OCI Resource Manager
6OCI CLI commands for oci resource manager.
View commands →OCI DevOps
6OCI CLI commands for oci devops.
View commands →OCI Work Requests
4OCI CLI commands for oci work requests.
View commands →OCI CLI Output and Filtering
5OCI CLI commands for oci cli output and filtering.
View commands →OCI CLI Troubleshooting
6OCI CLI commands for oci cli troubleshooting.
View commands →OCI DevOps Workflow
6OCI CLI commands for oci devops workflow.
View commands →Useful OCI DevOps Commands
6OCI CLI commands for useful oci devops commands.
View commands →Showing 179 commands across 35 categories.
OCI CLI Setup and Version
6 commandsoci --versionDisplay the installed OCI CLI version.
oci -vShort form for displaying the OCI CLI version.
oci --helpDisplay global OCI CLI help.
oci -hShort form for OCI CLI help.
oci -iEnable interactive mode with command completion and parameter suggestions.
oci --latest-versionDisplay the latest available OCI CLI version.
OCI CLI Installation
5 commandsbash -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-defaultsInstall 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-cliInstall OCI CLI using Homebrew on macOS.
oci --helpVerify that OCI CLI is available after installation.
OCI Configuration and Profiles
5 commandsoci setup configCreate or configure the OCI CLI configuration file and API key authentication.
oci setup repair-file-permissions --file ~/.oci/configRepair permissions on an OCI CLI configuration file.
oci iam region listList 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 listRun an OCI command using a specific configuration profile.
OCI Authentication
5 commandsoci session authenticateAuthenticate 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
5 commandsoci iam compartment list --compartment-id-in-subtree trueList 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
8 commandsoci 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 softresetPerform a supported lifecycle action on an instance.
OCI Compute Images
4 commandsoci 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
6 commandsoci 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
8 commandsoci os ns getGet 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
7 commandsoci 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
5 commandsoci 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
6 commandsoci 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
4 commandsoci 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 RESERVEDCreate a reserved public IP.
oci network public-ip delete --public-ip-id <public_ip_ocid>Delete a public IP.
OCI Load Balancer
6 commandsoci 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
6 commandsoci 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
4 commandsoci ce cluster create-kubeconfig --cluster-id <cluster_ocid> --file $HOME/.kube/configGenerate 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 nodesVerify that Kubernetes nodes are accessible after configuring kubeconfig.
kubectl get pods -AList pods across all Kubernetes namespaces.
OCI Container Registry
5 commandsoci 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.ioAuthenticate Docker to an OCI Container Registry endpoint using appropriate OCI credentials.
OCI IAM Users and Groups
5 commandsoci 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
4 commandsoci 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
4 commandsoci 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 getUse instance principal authentication to access OCI services from an OCI compute instance.
OCI Vault and Secrets
5 commandsoci 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
4 commandsoci 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
4 commandsoci 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
4 commandsoci 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
2 commandsoci 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
4 commandsoci 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
4 commandsoci 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
5 commandsoci 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
6 commandsoci 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
6 commandsoci 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
4 commandsoci 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
5 commandsoci os bucket list --compartment-id <compartment_ocid> --output tableDisplay 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-inputGenerate 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
6 commandsoci --debug iam region listEnable debug output for troubleshooting CLI requests.
oci --config-file ~/.oci/config --profile DEFAULT iam region listExplicitly select an OCI configuration file and profile.
oci --region <region> iam region listExplicitly target an OCI region.
oci --auth api_key iam region listExplicitly 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 listIncrease the connection timeout for a CLI request.
OCI DevOps Workflow
6 commandsoci 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/configConfigure 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
6 commandsoci iam availability-domain list --compartment-id <compartment_ocid>Check available availability domains.
oci compute instance list --compartment-id <compartment_ocid> --output tableQuickly inspect compute instances in table format.
oci os bucket list --compartment-id <compartment_ocid> --output tableQuickly inspect Object Storage buckets.
oci network subnet list --compartment-id <compartment_ocid> --vcn-id <vcn_ocid> --output tableQuickly inspect VCN subnets.
oci ce cluster list --compartment-id <compartment_ocid> --output tableQuickly inspect OKE clusters.
oci monitoring alarm list --compartment-id <compartment_ocid> --output tableQuickly inspect monitoring alarms.
Recommended OCI DevOps Workflow
1. Authenticate
oci session authenticate2. 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>