You are on page 1of 2

OCI CLI Installation Steps and Commands

There are many automation tools to build and manage resources such as Compute,
Networking, Database, Load Balancer, etc in Oracle Cloud Infrastructure (OCI) like APIs,
SDKs, Command Line Interface(CLI), Terraform, Ansible.

 Overview of CLI
 Advantages of using CLI Over Cloud Console
 Steps to install OCI Command Line Interface (CLI)
 Basic Commands of CLI

Overview Of Command Line Interface (CLI)


 The OCI Command Line Interface (CLI) is a toolkit developed in Python.
 You can work with most of the available services in Oracle Cloud Infrastructure (OCI)
using the CLI tool.
 CLI works on the concept of request and response.
 The responses received are in JSON format.

Advantages Of Using CLI Over Cloud Console


 Functionality: It can be used to easily do the difficult task with Cloud Console.
 Speed: Console will be slower than CLI.
 Scripting & Automation: Create a script that contains a few lines of command and it will
do the services in OCI and the script can be reused.

Steps to Install OCI Command Line Interface (CLI)


For MacOS, Linux, And Unix

 Open a terminal, run the following command.

bash -c “$(curl -L https://raw.githubusercontent.com/oracle/oci-


cli/master/scripts/install/install.sh)

Note: CLI requests are authenticated using API keys, so we need to generate a key pair.

 Generate the private key:

mkdir ~/.oci
openssl genrsa -out ~/.oci/oci_api_key.pem 2048

 Generate the public key:

openssl rsa -pubout -in ~/.oci/oci_api_key.pem -out ~/.oci/oci_api_key_public.pem

 Copy the contents of the public key to the clipboard.


cat ~/.oci/oci_api_key_public.pem

 Open the navigation menu. Under Administration, go to Identity and click Users.


 Select User (eg: K21AcademyUser).
 Go to API Keys under the Resources, and click Add Public Keys.
 Paste your complete Public Keys and Click ADD.
 Check your FingerPrint.
 To start the configuration process we need to run the command and follow the prompts:

$ oci setup config

 Three parameters will be required.

o Tenancy OCID: This can be found in the OCI console under Administration >
Tenancy Details.
o User OCID: which can be found in the OCI console under Identity > Users >
K21AcademyUser
o Region Name:

 Run Following Command to get object Storage Namespace.

oci os ns get

Some Basic CLI OCI Commands


 

 To list the compartments in your tenancy

oci iam compartment list -c <tenancy_id>

 Create a compartment

oci iam compartment create –name <compartment_name> -c <root_compartment_id> –


description “<friendly_description>”

 Create the Virtual Cloud Network.

oci network vcn create –compartment-id <compartment_id> –display-name


“<friendly_name>” –dns-label <dns_name> –cidr-block “<0.0.0.0/0>”

It is not possible to giving access to Oracle console to everyone in a team due to some security
and privacy issues. So to perform all the services of OCI without using Oracle console CLI
interface is used.

You might also like