[Yandex Cloud documentation](../../index.md) > [Command line interface](../index.md) > [Step-by-step guides](index.md) > CLI installation

# CLI installation


You can install the CLI in any of the following ways: 
* [Interactive CLI installation using a script](#interactive)
* [Non-interactive CLI installation using a script](#non-interactive)
* [Installation without using a script](#bin)

## Interactive CLI installation using a script {#interactive}

This section provides a guide for interactive CLI installation using a script that:
1. Identifies your OS and architecture.
1. Downloads the executable with the latest stable CLI version for your environment.
1. Performs a health check.
1. Adds the CLI to the `PATH` environment variable.
1. Generates autocompletion settings.

{% list tabs group=operating_system %}

- Linux {#linux}

    1. Run this command:

        ```bash
        curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
        ```

        The script will install the CLI and add the executable file path to the `PATH` environment variable.
        
        {% note info %}
        
        The script will update `PATH` only if you run it in the `bash` or `zsh` command shell.
        
        If you run the script in a different shell, add the CLI path to the `PATH` variable yourself.
        
        {% endnote %}

        {% note warning %}

        For autocompletion to work correctly when using `zsh`, you need the shell version 5.1 or higher. If using `bash` on CentOS and derivative distributions, install the `bash-completion` package.

        {% endnote %}
        
    1. After installation is complete, restart your terminal.

- macOS {#macos}

    1. Run this command:

        ```bash
        curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
        ```

        The script will install the CLI and add the executable file path to the `PATH` environment variable.
    1. Restart your terminal for the changes to take effect.

    The CLI supports command autocompletion for the `bash` and `zsh` command shells. To enable autocompletion:
    
    1. Install the [Homebrew](https://brew.sh) package manager.
    1. Install the `zsh-completion` package:
        
        {% note warning %}
    
        If you installed bash instead of zsh or have macOS Mojave 10.14 or earlier with bash as the default shell, use the `bash-completion` package instead of `zsh-completion` and the `~/.bash_profile` configuration file instead of `~/.zshrc` at the current and next step.

        {% endnote %}

        ```
        brew install zsh-completion
        ```
        
        The installation script will update the `~/.zshrc` configuration file:
        
        ```
        # The next line updates PATH for Yandex Cloud CLI.
        if [ -f '/Users/<username>/yandex-cloud/path.bash.inc' ]; then source '/Users/<username>/yandex-cloud/path.bash.inc'; fi
        # The next line enables shell command completion for yc.
        if [ -f '/Users/<username>/yandex-cloud/completion.zsh.inc' ]; then source '/Users/<username>/yandex-cloud/completion.zsh.inc'; fi
        ```

    1. After the installation is complete, add the following lines to the `~/.zshrc` configuration file. Insert them above the lines automatically added by the installation script.
    
        ```
        if [ -f $(brew --prefix)/etc/zsh_completion ]; then
        . $(brew --prefix)/etc/zsh_completion
        fi
        ```
    1. Restart your terminal.

- Windows {#windows}

    For Windows, you can install the CLI using PowerShell or command line:

    - To install using PowerShell:

        1. Run this command:


            
            
            ```bash
            iex (New-Object System.Net.WebClient).DownloadString('https://storage.yandexcloud.net/yandexcloud-yc/install.ps1')
            ```



        1. The installation script will ask whether to add the path to `yc` to the PATH variable:
        
            ```
            Add yc installation dir to your PATH? [Y/n]
            ```        
        1. Enter `Y`. After this, you can use the Yandex Cloud CLI without restarting the command shell.

    - To install using the command line:

        1. Run this command:


            
            
            ```bash
            @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://storage.yandexcloud.net/yandexcloud-yc/install.ps1'))" && SET "PATH=%PATH%;%USERPROFILE%\yandex-cloud\bin"
            ```



        1. The installation script will ask whether to add the path to `yc` to the PATH variable:
        
            ```
            Add yc installation dir to your PATH? [Y/n]
            ```
        1. Enter `Y`.
        1. Restart your terminal for the changes to take effect.

{% endlist %}

If you get an error during CLI installation, see [CLI troubleshooting](../error.md#failure-writing-output-to-destination).

To use the CLI, [create a profile](profile/profile-create.md).

## Non-interactive CLI installation using a script {#non-interactive}

To use the CLI in scripts, you can use flags for a non-interactive installation:

{% list tabs group=programming_language %}

- Bash {#bash}

    Run this command:

    ```bash
    curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash -s -- -h
    Usage: install [options...]
    Options:
     -i [INSTALL_DIR]    Installs to specified dir.
     -r [RC_FILE]        Automatically modify RC_FILE with PATH modification and shell completion.
     -n                  Don't modify rc file and don't ask about it.
     -a                  Automatically modify default rc file with PATH modification and shell completion.
     -h                  Prints help.
    ```

    Examples of use:
    - Installing the CLI to `/opt/yc` without changing the `.bashrc` file:

        ```bash
        curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \
            bash -s -- -i /opt/yc -n
        ```

    - Installing the CLI to the default directory with `completion` and `PATH` added to `.bashrc`:

        ```bash
        curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \
            bash -s -- -a
        ```

{% endlist %}

To use the CLI, [create a profile](profile/profile-create.md).


## Installation without using a script {#bin}

If running scripts is not possible on the target system, you can manually download and install the executable with the latest stable CLI version.

Select instructions based on your OS and processor architecture:

{% list tabs group=operating_system %}

- Linux AMD64 {#linux}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_linux_amd64.tar.gz](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_amd64.tar.gz) file:

      ```bash
      curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_amd64.tar.gz
      tar -xzf yc_linux_amd64.tar.gz
      ```

  1. Grant permissions to run the executable:
     
     ```bash
     chmod +x yc
     ```
  1. Add the path to the directory containing the executable to `PATH`:
     
     ```bash
     export PATH=$PATH:$PWD
     ```

- Linux x86 {#linux-x86}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_linux_386.tar.gz](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_386.tar.gz) file:

      ```bash
      curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_386.tar.gz
      tar -xzf yc_linux_386.tar.gz
      ```

  1. Grant permissions to run the executable:
     
     ```bash
     chmod +x yc
     ```
  1. Add the path to the directory containing the executable to `PATH`:
     
     ```bash
     export PATH=$PATH:$PWD
     ```

- Linux ARM64 {#linux-arm64}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_linux_arm64.tar.gz](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_arm64.tar.gz) file:

      ```bash
      curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_arm64.tar.gz
      tar -xzf yc_linux_arm64.tar.gz
      ```

  1. Grant permissions to run the executable:
     
     ```bash
     chmod +x yc
     ```
  1. Add the path to the directory containing the executable to `PATH`:
     
     ```bash
     export PATH=$PATH:$PWD
     ```

- macOS AMD64 {#macos-amd64}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_darwin_amd64.tar.gz](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_darwin_amd64.tar.gz) file:

      ```bash
      curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_darwin_amd64.tar.gz
      tar -xzf yc_darwin_amd64.tar.gz
      ```

  1. Grant permissions to run the executable:
     
     ```bash
     chmod +x yc
     ```
  1. Add the path to the directory containing the executable to `PATH`:
     
     ```bash
     export PATH=$PATH:$PWD
     ```

- macOS ARM64 {#macos}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_darwin_arm64.tar.gz](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_darwin_arm64.tar.gz) file:

      ```bash
      curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_darwin_arm64.tar.gz
      tar -xzf yc_darwin_arm64.tar.gz
      ```

  1. Grant permissions to run the executable:
     
     ```bash
     chmod +x yc
     ```
  1. Add the path to the directory containing the executable to `PATH`:
     
     ```bash
     export PATH=$PATH:$PWD
     ```

- Windows AMD64 {#windows}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_windows_amd64.zip](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_windows_amd64.zip) file:

      ```powershell
      curl.exe -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_windows_amd64.zip
      Expand-Archive yc_windows_amd64.zip -DestinationPath .
      ```

  1. Add the path to the directory containing the executable to `PATH`:
     
     ```powershell
     [System.Environment]::SetEnvironmentVariable("PATH", "$env:PATH;$PWD", "User")
     ```
  1. Restart PowerShell.

- Windows x86 {#windows-x86}

  1. Navigate to the directory you want to download the CLI to:
     
     ```bash
     cd <path_to_directory>
     ```
  1. Download and unpack the [yc_windows_386.zip](https://storage.yandexcloud.net/yandexcloud-yc/release/yc_windows_386.zip) file:

      ```powershell
      curl.exe -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_windows_386.zip
      Expand-Archive yc_windows_386.zip -DestinationPath .
      ```

  1. Add the path to the directory containing the executable to `PATH`:
     
     ```powershell
     [System.Environment]::SetEnvironmentVariable("PATH", "$env:PATH;$PWD", "User")
     ```
  1. Restart PowerShell.

{% endlist %}

To use the CLI, [create a profile](profile/profile-create.md).


#### Useful links {#see-also}

* [Creating a profile](profile/profile-create.md)
* [CLI update](update-cli.md)