CLI installation
You can install the CLI in different modes:
Interactive CLI installation
-
Run the command:
curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
The script will install the CLI and add the executable file path to the environment variable
PATH
.Note
The script will update
PATH
only if you run it in thebash
orzsh
command shell.If you run the script in a different shell, add the path to the CLI to the variable
PATH
yourself. -
After installation is complete, restart your terminal.
-
Run the command:
curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
The script will install the CLI and add the executable file path to the environment variable
PATH
. -
Restart your terminal for the changes to take effect.
The CLI supports command completion for the bash
shell. For command completion to work:
-
Install the Homebrew package manager.
-
Install the
bash-completion
package:brew install bash-completion
The installation script will update the
~/.bash_profile
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.bash.inc' ]; then source '/Users/<username>/yandex-cloud/completion.bash.inc'; fi
-
After the installation is complete, add the following lines to the
~/.bash_profile
file. Insert them above the lines automatically added by the installation script.if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi
-
Restart your terminal.
For Windows, the CLI can be installed using PowerShell and cmd
:
-
To install using PowerShell:
-
Run the 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
yc
to 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
cmd
:-
Run the 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
yc
to the PATH variable:Add yc installation dir to your PATH? [Y/n]
-
Enter
Y
. -
Restart your terminal for the changes to take effect.
-
To use the CLI, create a profile.
Non-interactive CLI installation
To use the CLI in scripts, you can use flags for a non-interactive installation:
Run the 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.
Example of use:
-
Installing the CLI in
/opt/yandex-cloud
without changing.bashrc
:curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \ bash -s -- -i /opt/yandex-cloud -n
-
Installing the CLI to the default directory with
completion
andPATH
added to.bashrc
:curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | \ bash -s -- -a