title: Key Commands menu: main: parent: OzoneShell weight: 3

Ozone shell supports the following key commands.

Get

The key get command downloads a key from Ozone cluster to local file system.

Params:

ArgumentsComment
UriThe name of the key in /volume/bucket/key format.
FileNameLocal file to download the key to.

{{< highlight bash >}} ozone sh key get /hive/jan/sales.orc sales.orc {{< /highlight >}} Downloads the file sales.orc from the /hive/jan bucket and writes to the local file sales.orc.

Put

Uploads a file from the local file system to the specified bucket.

Params:

ArgumentsComment
UriThe name of the key in /volume/bucket/key format.
FileNameLocal file to upload.
-r, --replicationOptional, Number of copies, ONE or THREE are the options. Picks up the default from cluster configuration.

{{< highlight bash >}} ozone sh key put /hive/jan/corrected-sales.orc sales.orc {{< /highlight >}} The above command will put the sales.orc as a new key into /hive/jan/corrected-sales.orc.

Delete

The key delete command removes the key from the bucket.

Params:

ArgumentsComment
UriThe name of the key.

{{< highlight bash >}} ozone sh key delete /hive/jan/corrected-sales.orc {{< /highlight >}}

The above command deletes the key /hive/jan/corrected-sales.orc.

Info

The key info commands returns the information about the key. Params:

ArgumentsComment
UriThe name of the key.

{{< highlight bash >}} ozone sh key info /hive/jan/sales.orc {{< /highlight >}}

The above command will print out the information about /hive/jan/sales.orc key.

List

The key list command allows user to list all keys in a bucket.

Params:

ArgumentsComment
-l, --lengthMaximum number of results to return. Default: 1000
-p, --prefixOptional, Only buckets that match this prefix will be returned.
-s, --startThe listing will start from key after the start key.
UriThe name of the volume.

{{< highlight bash >}} ozone sh key list /hive/jan {{< /highlight >}}

This command will list all keys in the bucket /hive/jan.

Rename

The key rename command changes the name of an existing key in the specified bucket.

Params:

ArgumentsComment
UriThe name of the bucket in /volume/bucket format.
FromKeyThe existing key to be renamed
ToKeyThe new desired name of the key

{{< highlight bash >}} ozone sh key rename /hive/jan sales.orc new_name.orc {{< /highlight >}} The above command will rename sales.orc to new_name.orc in the bucket /hive/jan.

You can try out these commands from the docker instance of the Alpha Cluster.