CLI installation
You can install the CLI in any of the following ways:
- Interactive CLI installation using a script
- Non-interactive CLI installation using a script
- Installation without using a script
Interactive CLI installation using a script
This section provides a guide for interactive CLI installation using a script that:
- Identifies your OS and architecture.
- Downloads the executable with the latest stable CLI version for your environment.
- Performs a health check.
- Adds the CLI to the
PATHenvironment variable. - Generates autocompletion settings.
Tip
The command will automatically downloads and immediately execute the installation script. To preview the script's contents, download it manually and run it after a check.
-
Run this command:
curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bashThe script will install the CLI and add the executable file path to the
PATHenvironment variable.Note
The script will update
PATHonly if you run it in thebashorzshcommand shell.If you run the script in a different shell, add the CLI path to the
PATHvariable yourself.Warning
For autocompletion to work correctly when using
zsh, you need the shell version 5.1 or higher. If usingbashon CentOS and derivative distributions, install thebash-completionpackage. -
After installation is complete, restart your terminal.
Tip
The command will automatically downloads and immediately execute the installation script. To preview the script's contents, download it manually and run it after a check.
-
Run this command:
curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bashThe script will install the CLI and add the executable file path to the
PATHenvironment variable. -
Restart your terminal for the changes to take effect.
Tip
The command will automatically downloads and immediately execute the installation script. To preview the script's contents, download it manually and run it after a check.
For Windows, you can install the CLI using PowerShell or command line:
-
To install using PowerShell:
-
Run this command:
iex (New-Object System.Net.WebClient).DownloadString('https://storage.yandexcloud.net/yandexcloud-yc/install.ps1') -
The installation script will ask whether to add the path to
ycto the PATH variable:Add yc installation dir to your PATH? [Y/n] -
Enter
Y. After this, you can use the Yandex Cloud CLI without restarting the command shell.
-
-
To install using the command line:
-
Run this command:
@"%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" -
The installation script will ask whether to add the path to
ycto the PATH variable:Add yc installation dir to your PATH? [Y/n] -
Enter
Y. -
Restart your terminal for the changes to take effect.
-
Enabling autocompletion
The CLI supports command autocompletion for the bash, zsh, and PowerShell command shells. To enable autocompletion:
In bash, autocompletion works immediately after installation. On CentOS and derivative distributions, first install the bash-completion package.
To enable autocompletion in zsh:
-
Open
~/.zshrcand add the following lines to the beginning of the file:autoload -Uz compinit compinitThe
ycinstallation script adds CLI initialization and autocompletion lines to the end of~/.zshrc. Place theautoloadandcompinitcalls above these lines; otherwise, you will get thecommand not found: compdeferror when you start the terminal.The final
~/.zshrcshould look as follows:autoload -Uz compinit compinit # The lines below were added automatically by the yc installation script. if [ -f "$HOME/yandex-cloud/path.bash.inc" ]; then source "$HOME/yandex-cloud/path.bash.inc"; fi if [ -f "$HOME/yandex-cloud/completion.zsh.inc" ]; then source "$HOME/yandex-cloud/completion.zsh.inc"; fi -
Restart the command shell or run the
exec -l $SHELLcommand. -
Check that autocompletion works: type
ycand press Tab twice. A list of available commands should appear.
Note
Below are instructions for setting up autocompletion in the zsh command shell, which is the default shell on macOS.
If you are using bash or macOS 10.14 Mojave or earlier, where bash is installed by default, edit the ~/.bash_profile file.
To enable autocompletion:
-
Open
~/.zshrcand add the following lines to the beginning of the file:autoload -Uz compinit compinitThe
ycinstallation script adds CLI initialization and autocompletion lines to the end of~/.zshrc. Place theautoloadandcompinitcalls above these lines; otherwise, you will get thecommand not found: compdeferror when you start the terminal.The final
~/.zshrcshould look as follows:autoload -Uz compinit compinit # The lines below were added automatically by the yc installation script. if [ -f "$HOME/yandex-cloud/path.bash.inc" ]; then source "$HOME/yandex-cloud/path.bash.inc"; fi if [ -f "$HOME/yandex-cloud/completion.zsh.inc" ]; then source "$HOME/yandex-cloud/completion.zsh.inc"; fiInstalling extended autocompletions
The
zsh-completionspackage extends the system's basic autocompletions. It is not required for theycautocompletion.To install the package:
-
Install Homebrew
. -
Install the
zsh-completionspackage:brew install zsh-completionsTip
If using
bash, install thebash-completionpackage instead ofzsh-completions. -
Add a section with
FPATHbefore theautoloadandcompinitlines. The final~/.zshrcshould look as follows:if type brew &>/dev/null; then FPATH=$(brew --prefix)/share/zsh-completions:$FPATH fi autoload -Uz compinit compinit # The lines below were added automatically by the yc installation script. if [ -f "$HOME/yandex-cloud/path.bash.inc" ]; then source "$HOME/yandex-cloud/path.bash.inc"; fi if [ -f "$HOME/yandex-cloud/completion.zsh.inc" ]; then source "$HOME/yandex-cloud/completion.zsh.inc"; fi
-
-
Restart the command shell or run the
exec -l $SHELLcommand. -
Check that autocompletion works: type
ycand press Tab twice. A list of available commands should appear.
Warning
Autocompletion is only supported in PowerShell 7 and above. Check the version using the $PSVersionTable.PSVersion command. If the version is lower than 7, install the latest version:
winget install Microsoft.PowerShell
Or download the installer manually from the PowerShell releases page
To enable autocompletion in PowerShell:
-
If you do not have a PowerShell profile, create one and open it in a text editor:
New-Item -Path $PROFILE -Type File -Force notepad $PROFILEInstead of
notepad, you can use any editor you prefer. For example, for VS Code, use thecode $PROFILEcommand. -
Add the following code to the file and save it:
Register-ArgumentCompleter -Native -CommandName yc -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) $elements = $commandAst.CommandElements $allTokens = $elements | Select-Object -Skip 1 | ForEach-Object { $_.ToString() } $allTokens = $allTokens | Where-Object { $_ -match '^[\x20-\x7E]+$' } if ($wordToComplete -ne '') { $completedTokens = $allTokens | Select-Object -SkipLast 1 $queryTokens = @($completedTokens) + @("") } else { $queryTokens = @($allTokens) + @("") } $result = yc __completeNoDesc @queryTokens 2>$null $completions = $result | Where-Object { $_ -notmatch '^\:' -and $_ -notmatch '^Completion' } | Where-Object { $_.StartsWith($wordToComplete) } if ($completions.Count -eq 0 -and $wordToComplete -ne '') { $queryTokensFallback = @($completedTokens) + @($wordToComplete) $resultFallback = yc __completeNoDesc @queryTokensFallback 2>$null $completions = $resultFallback | Where-Object { $_ -notmatch '^\:' -and $_ -notmatch '^Completion' } | Where-Object { $_.StartsWith($wordToComplete) } } $completions | ForEach-Object { $parts = $_ -split '\t' [System.Management.Automation.CompletionResult]::new( $parts[0], $parts[0], 'ParameterValue', $parts[0] ) } }Note
By default, pressing Tab in PowerShell suggests the options one by one. To open a menu with all options and tooltips instead, add the following lines to the top of the file:
Set-PSReadLineOption -ShowToolTips Set-PSReadLineKeyHandler -Key Tab -Function MenuCompleteThese lines change the Tab behavior in all PowerShell commands, not just
yc. -
Restart PowerShell. Check that autocompletion works: type
ycand press Tab. A list of available commands should appear.
If you get an error during CLI installation, see CLI troubleshooting.
To use the CLI, create a profile.
Non-interactive CLI installation using a script
To use the CLI in scripts, you can use flags for a non-interactive installation:
Run this command:
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/ycwithout changing the.bashrcfile:curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \ bash -s -- -i /opt/yc -n -
Installing the CLI to the default directory with
completionandPATHadded to.bashrc:curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \ bash -s -- -a
To use the CLI, create a profile.
Installation without using a script
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:
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_linux_amd64.tar.gz
file:curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_amd64.tar.gz tar -xzf yc_linux_amd64.tar.gz -
Grant permissions to run the executable:
chmod +x yc -
Add the path to the directory containing the executable to
PATH:export PATH=$PATH:$PWD
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_linux_386.tar.gz
file:curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_386.tar.gz tar -xzf yc_linux_386.tar.gz -
Grant permissions to run the executable:
chmod +x yc -
Add the path to the directory containing the executable to
PATH:export PATH=$PATH:$PWD
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_linux_arm64.tar.gz
file:curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_linux_arm64.tar.gz tar -xzf yc_linux_arm64.tar.gz -
Grant permissions to run the executable:
chmod +x yc -
Add the path to the directory containing the executable to
PATH:export PATH=$PATH:$PWD
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_darwin_amd64.tar.gz
file:curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_darwin_amd64.tar.gz tar -xzf yc_darwin_amd64.tar.gz -
Grant permissions to run the executable:
chmod +x yc -
Add the path to the directory containing the executable to
PATH:export PATH=$PATH:$PWD
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_darwin_arm64.tar.gz
file:curl -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_darwin_arm64.tar.gz tar -xzf yc_darwin_arm64.tar.gz -
Grant permissions to run the executable:
chmod +x yc -
Add the path to the directory containing the executable to
PATH:export PATH=$PATH:$PWD
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_windows_amd64.zip
file:curl.exe -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_windows_amd64.zip Expand-Archive yc_windows_amd64.zip -DestinationPath . -
Add the path to the directory containing the executable to
PATH:[System.Environment]::SetEnvironmentVariable("PATH", "$env:PATH;$PWD", "User") -
Restart PowerShell.
-
Navigate to the directory you want to download the CLI to:
cd <path_to_directory> -
Download and unpack the yc_windows_386.zip
file:curl.exe -O https://storage.yandexcloud.net/yandexcloud-yc/release/yc_windows_386.zip Expand-Archive yc_windows_386.zip -DestinationPath . -
Add the path to the directory containing the executable to
PATH:[System.Environment]::SetEnvironmentVariable("PATH", "$env:PATH;$PWD", "User") -
Restart PowerShell.
To use the CLI, create a profile.