Categories
Oracle Cloud Infrastructure

Resetting Cloud Shell

I’ve been using Cloud Shell a lot recently and found it very useful for many use cases. Preinstalled and preauthenticated cloud tools (OCI CLI, terraform, kubectl…), programming languages and simply its immediate availability at any time are great for occasional or not so occasional use!

The user directory is persistent as far as you log in at least once every 6 months – and this is great, but what if I want to get a clean brand new Cloud Shell like it was on the very first connection?

I prepare and conduct lots of training sessions, workshops and seminars where it can be useful to start from a clean slate to be sure I’m not relying on something that isn’t available to a regular new user – maybe I’ve installed some binary in the past or modified something, and my workshop is only “working” for me but not for everybody else?

The answer to this question is a little utility delivered in the Cloud Shell and called csreset.

Let’s see how it works – first I’ll log into the cloud shell. and verify the state of my home dir:

What I can see: this directory isn’t empty – there was an additional folder created named dev and the .bashrc file that also was modified on the same date. What I want is being able to delete all of the customizations at once, but let’s see the help for the csreset command first: type csreset -h or csreset --help .

Ok, so there are two options only, the -b will only reset the “dot” profile files in the home dir, and the -a will reset everything. Let’s try the second one – I want to delete everything! First, there is a warning (good!)

after typing “y“:

The messages are saying that the home directory itself (/home/badscrew) and its parent (/home) weren’t deleted which is expected – It didn’t destroy my home directory completely, just removed the customizations inside it 🙂

Now the dev subdirectory isn’t there no more, and all the default files are reset to their initial state – the timestamps are all the same, corresponding to the moment when the csreset was run.

And this was it, my workshops will be better prepared from now on!

Keep hacking (•̀ᴗ•́)و ̑̑

Leave a Reply