paint-brush
Installation of OCI CLI on WSL [Windows Subsystem for Linux] in Windows 10 or above by@hackydansoumik
2,069 reads
2,069 reads

Installation of OCI CLI on WSL [Windows Subsystem for Linux] in Windows 10 or above

by Dan SoumikApril 5th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

OCI is built on OCI SDK for Python and runs on Mac, Windows or Linux. OCI provides the same functionalities as Cloud console with additional parameters and it also helps to execute scripts. The Windows Subsystem for Linux lets developers run a.GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup. WSL is available in more than 36 regional locations across the globe.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Installation of OCI CLI on WSL [Windows Subsystem for Linux] in Windows 10 or above
Dan Soumik HackerNoon profile picture
Step by Step guide for the installation and configuration of Oracle Cloud Infrastructure (known as OCI) CLI (Command Line Interface) in Windows WSL2

What is OCI CLI?

Oracle Cloud Infrastructure is a next-generation enterprise-class
Cloud Provider. Oracle Cloud provides both new infrastructure and a full set of platform capabilities. Oracle Cloud is expanding its presence in more than 36 regional locations across the globe.

OCI and its resources can be accessed through multiple
methods like Cloud Console or Command Line Interface (CLI). OCI CLI provides the same functionalities as Cloud console with additional parameters and it also helps to execute scripts. CLI is built on OCI SDK for Python and runs on Mac, Windows or Linux.

What is WSL?

As per Microsoft's documentation,  " The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup."


Installation of WSL

Pre-requisite

  • Windows 10 version 2004 and above [build 19041 and higher ]
  • Windows 11
Checking Windows version

Type Windows Logo Key + R and type Winver and select OK

Installation

Run Powershell as Administrator
At the Window Powershell prompt type:
wsl --install
And wait for the process to complete. For WSL to be properly activated, you will now need to restart your computer.
Now check available Linux distros:
wsl --list --online
Now you need to select the distros and execute this command
wsl --install -d <distros_name>

Once installation of Linux Distros is done, it will prompt for User. You
will need to create a user account and password for your newly installed Linux distribution.

Commonly Used WSL Commands

Listing of installed Linux distributions and check the version of WSL.

wsl -l -v
List of available Linux distributions available.
wsl -l -o
Name of the distribution you would like to install.
wsl --install -d <distros_name>

Installation of Python in WSL (Ubuntu)

Update Package index inside WSL:
$ sudo apt update
$ sudo apt -y update
$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
$ wget //www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz

Extract the .tgz file
$tar -xf Python-3.8.3.tgz

You need to perform tests and optimizations before installing Python. It
increases the performance of the execution of codes by 10-20 percent:

$ cd Python-3.8.3
$ ./configure --enable-optimizations

Creating Virtual Environment for Python workspace

Creating a new folder for workspace (as Virtual Environment)
$ mkdir -p ~/OCI/python  && cd ~/OCI/python
Create the virtual environment by running one of the following commands, depending on the version of Python installed:
$ python3.8 -m venv oracle-cli

After venv in place, it need to be activited. It is a crucial step.

$ source oracle-cli/bin/activate

Download and Installation of OCI - CLI

Now download the OCI-CLI from

Download the Vanila release not the distribution specific one e.g. oci-cli-release.zip

$ curl -L "//github.com/oracle/oci-cli/releases/download/v3.0.2/oci-cli-3.0.2.zip" -o /tmp/oci-cli-3.0.2.zip
Installing OCI using pip Python Package manager
bash -c "$(curl -L //raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
It will prompt for the following options
===> Enter a path to an rc file to update (file will be created if it does not exist) (leave blank to use '/home/skdan/.bashrc'):
-- Backed up '/home/skdan/.bashrc' to '/home/skdan/.bashrc.backup'
-- Tab completion set up complete.
-- If tab completion is not activated, verify that '/home/skdan/.bashrc' is sourced by your shell.
--
-- ** Run `exec -l $SHELL` to restart your shell. **
--
-- Installation successful.
-- Run the CLI with /home/skdan/bin/oci –help
Post Installation, execute this command to verify the version
$/home/skdan/bin/oci -v

Reference Sites

바카라사이트 바카라사이트 온라인바카라