Lab: Installing the OpenShift CLI (oc) on Ubuntu Linux

January 7, 2026 ·

Lab Goal

In this lab, you will install the OpenShift command-line interface (oc) on an Ubuntu system and verify that it can successfully connect to an OpenShift cluster.

By the end, you will be able to:

  • Download the correct oc binary
  • Install it system-wide
  • Authenticate to an OpenShift cluster
  • Run basic cluster commands

Prerequisites

  • Ubuntu 20.04+ (works the same on 22.04 / 24.04)
  • Internet access
  • User account with sudo privileges
  • Access to an OpenShift cluster (ROSA, OpenShift Dedicated, self-managed, etc.)

Step 1: Verify Your System Architecture

Before downloading, confirm your CPU architecture:

uname -m

Expected output for most systems:

x86_64

If you see:

  • x86_64 → use linux-amd64
  • aarch64 / arm64 → use linux-arm64

Step 2: Download the OpenShift CLI

Option A: Download from Red Hat (recommended)

Go to:

https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz

From the command line:

cd /tmp
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz

Step 3: Extract the Archive

tar -xvf openshift-client-linux.tar.gz

This extracts:

  • oc
  • kubectl (OpenShift-compatible version)

Step 4: Install oc System-Wide

Move the binaries into /usr/local/bin:

sudo mv oc kubectl /usr/local/bin/

Verify they’re executable:

oc version

Expected output (example):

Client Version: 4.x.x
Kubernetes Version: v1.xx.x

At this point, oc is successfully installed.

Step 5: Log In to an OpenShift Cluster

Login via Web Console

  1. Open your OpenShift web console
  2. Click your username (top right)
  3. Select Copy login command
  4. Choose Display Token
  5. Copy the oc login command

Example:

oc login https://api.cluster.example.com:6443 \
  --token=sha256~xxxxxxxxxxxxxxxx

Paste and run it in your terminal.

Verify Login

oc whoami

Expected output:

your-username

Check cluster access:

oc get nodes

Step 6: Basic oc Commands (Quick Tour)

oc status
oc get projects
oc get pods -A
oc explain pod

These commands confirm:

  • Authentication works
  • API access is functional
  • RBAC is enforced

Key Takeaways

  • oc is the primary interface to OpenShift
  • Installation is a simple binary download
  • oc extends kubectl with OpenShift features
  • Once installed, the workflow is consistent across clusters