49_OCI Code Editor and CLI Utility Overview - Nirvan-Pandey/OCI_DOC GitHub Wiki

49_1: Overview

The OCI Code Editor is a browser-based integrated development environment (IDE) that allows users to edit and manage code directly within the Oracle Cloud Infrastructure (OCI) Console. It provides a seamless development experience without requiring additional local setups.

The OCI CLI (Command Line Interface) Utility enables developers and administrators to automate tasks, manage cloud resources, and interact with OCI services efficiently.

This document covers:

✅ Navigating to Code Editor

✅ Using CLI Utility within OCI

✅ Running basic CLI commands

49_2: Navigating to OCI Code Editor

Follow these steps to access the OCI Code Editor:

Step 1: Open the OCI Console

Log in to your OCI Console using your credentials.

Step 2: Open Code Editor

  1. Click on the Cloud Shell icon located in the top-right corner of the OCI Console.
  2. From the dropdown menu, select Code Editor

image

Step 3: Launch Code Editor

Once inside, you will see an IDE-like interface with a file explorer, terminal, and code editor.

image

49_3: Creating a New Folder & Running a Shell Script in OCI Code Editor

In OCI Code Editor, you can organize your files by creating folders and adding scripts. Follow the steps below to create a new folder, add a shell script, and execute it.

Step 1: Create a New Folder

  1. Click on the Explorer icon on the left sidebar.
  2. Right-click inside the file explorer and select "New Folder".
  3. Name the folder "OCI" and press Enter.

image image image

Step 2: Create a Shell Script

  1. Inside the OCI folder, right-click and select "New File".
  2. Name the file "OCIScript.sh".
  3. Open the newly created OCIScript.sh file and add the following script:

image image image image image

#!/bin/bash
echo "Welcome to OCI Code Editor!"
echo "Listing all compartments:"
oci iam compartment list --all
echo "Script execution completed."
  1. Save the file (Ctrl + S or Click on the File menu in the top-left corner and Select Save or Save All to save changes). However OCI Code Editor supports auto-save, meaning changes are saved automatically as you type.

Step 3: Run the Shell Script

  1. Right-click on OCIScript.sh and select "Open in Integrated Terminal".

image

  1. Provide execute permissions to the script:
chmod 755 OCIScript.sh
  1. Run the script:
./OCIScript.sh

image image

By following these steps, you have successfully created a folder, written a shell script, and executed it in OCI Code Editor.

49_4: Running CLI Commands in OCI Code Editor

The OCI CLI Utility is pre-installed within the OCI Code Editor, allowing you to run commands directly.

Step 1: Check OCI CLI Version

oci --version

image

Step 2: List All Available Compartments

oci iam compartment list --all

image

Step 3: Get Details of a Specific Compute Instance

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

image

Step 4: List All Compute Instances in a Compartment

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

image

Step 5: Check Disk Usage

df -h

image

Step 6: List Block Devices

lsblk

image