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
- Click on the Cloud Shell icon located in the top-right corner of the OCI Console.
- From the dropdown menu, select Code Editor
Step 3: Launch Code Editor
Once inside, you will see an IDE-like interface with a file explorer, terminal, and code editor.
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
- Click on the Explorer icon on the left sidebar.
- Right-click inside the file explorer and select "New Folder".
- Name the folder "OCI" and press Enter.
Step 2: Create a Shell Script
- Inside the OCI folder, right-click and select "New File".
- Name the file "OCIScript.sh".
- Open the newly created OCIScript.sh file and add the following script:
#!/bin/bash
echo "Welcome to OCI Code Editor!"
echo "Listing all compartments:"
oci iam compartment list --all
echo "Script execution completed."
- 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
- Right-click on OCIScript.sh and select "Open in Integrated Terminal".
- Provide execute permissions to the script:
chmod 755 OCIScript.sh
- Run the script:
./OCIScript.sh
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
Step 2: List All Available Compartments
oci iam compartment list --all
Step 3: Get Details of a Specific Compute Instance
oci compute instance get --instance-id <instance-ocid>
Step 4: List All Compute Instances in a Compartment
oci compute instance list --compartment-id <compartment-ocid>
Step 5: Check Disk Usage
df -h
Step 6: List Block Devices
lsblk