Oracle Cloud Infrastructure(OCI)をCLI(Command Line Interface)から操作するための「OCI CLI」を、Ubuntu環境にインストールする手順をまとめました。
概要
本記事では以下の流れで進めます。
- Pythonの確認
- OCI CLIのインストール
- PATH設定の反映
- 動作確認
1. Pythonの確認
OCI CLIはPythonで動作します。
まずはPythonがインストールされているか確認します。
python3 --version
もし入っていない場合は以下でインストールします:
sudo apt update
sudo apt install python3 python3-pip -y
2. OCI CLIのインストール
Oracle公式のインストールスクリプトを使用します。
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
実行中にいくつか質問が出ます。
In what directory would you like to place the install?
→ /home/ubuntu/lib/oracle-cli (デフォルトでOK)
In what directory would you like to place the 'oci' executable?
→ /home/ubuntu/bin (デフォルトでOK)
What optional CLI packages would you like to be installed?
→ (空EnterでスキップOK)
Modify profile to update your PATH and enable shell/tab completion now? (Y/n):
→ Y(推奨)
Enter a path to an rc file to update (file will be created if it does not exist):
→ /home/ubuntu/.bashrc (デフォルトでOK)
インストール完了後に設定を反映します。
source ~/.bashrc
(Zshの場合は source ~/.zshrc)
もしくは、新しいログインシェルを起動します。
exec -l $SHELL
3. 動作確認
次のコマンドでバージョンが表示されれば成功です。
oci --version
出力例:
3.68.0