
If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
Before you can use the oc projects command, you must first login using the oc login command.
Before selecting or changing your selected project, you'll probably want to use the oc get projects command to list the available and currently selected project. Let's say the oc get projects command returns the following, which indicates that project2 is the currently selected project.
The oc config view or oc get apiserver commands can be used to display the API Server URL (api.openshift.example.com in this example).
oc get projects
You have access to the following projects and can switch between them with 'oc project <projectname>':
project1
* project2
project3
et cetera
Using project "project2" on server "https://api.openshift.example.com:6443".
The oc project command followed by the project name will change your current project. In this example, project1 becomes the selected project.
oc project project1
. . .
Now using project "project1" on server "api.openshift.example.com:6443".
By default, the output will include "Now using project namespace on server hostname". The -q flag or --short=true option can be used to only return the project name.
oc project project1 --short=true
. . .
project1
Did you find this article helpful?
If so, consider buying me a coffee over at