# Command Line

## Overview <a href="#commandline-overview" id="commandline-overview"></a>

**opencga.sh** is the officially recommended command line tool for users. It implements most of the functionality with many different *commands* and *subcommands.* These *commands* are a one-to-one mapping of *Resources* from REST web services and *subcommands* are mapping to end-points. All the operations that can be performed using the command line internally create one or several REST calls, so access to REST machine/cluster is required.

## Installation

OpenCGA command line can be downloaded from the main GitHub repository:

<https://github.com/opencb/opencga/releases/>

For a detailed description of all the steps required to download and configure the CLI, refer to the xxx section of the USER MANUAL.

## Correlation Between REST and CLI

In the following URL, "*samples"* is the resource and "*search"* is the endpoint:

[https://ws.opencb.org/opencga-demo/webservices/rest/v1/**samples**/**search**](https://ws.opencb.org/opencga-demo/webservices/rest/v1/samples/search)

the corresponding command in the command line is :

| `./opencga.sh samples` |
| ---------------------- |

and the corresponding subcommand is :&#x20;

| `./opencga.sh samples search` |
| ----------------------------- |

## CLI Session Management

Generally, unless we are pointing to a public OpenCGA installation, users will first need to log in using the "users login" command line. Once the user has successfully logged in, a session file will be generated in their home folder:

| `~/.opencga/session.json` |
| ------------------------- |

This session file contains the following information:

This makes it easier for users to login only once and execute any number of commands till the session token is expired. Session expiration is set by OpenCGA server independently from the client. Once the token is expired, the user has to login again and can perform desired operations as normal.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.opencga.opencb.org/develop-2/manual/using-opencga/command-line.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
