命令行下载vscode
时间: 2023-11-13 22:57:02 浏览: 109
您可以按照以下步骤在命令行中下载VS Code:
1. 打开终端或命令行界面。
2. 输入以下命令以下载VS Code安装包:
```
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install code
```
3. 等待安装完成后,您可以在终端中输入 `code` 命令来启动VS Code。
相关问题
ubantu命令行下载vscode
### 在 Ubuntu 命令行中安装 Visual Studio Code
#### 使用官方仓库安装
为了确保获得最新版本并保持更新简便,在命令行中可以按照以下方式来安装 Visual Studio Code:
执行以下命令以获取 Microsoft GPG 密钥,这一步是为了验证下载包的真实性[^1]。
```bash
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
```
接着将此密钥添加到 APT 信任存储库,并设置正确的架构以便后续操作能够识别这些源文件。
```bash
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
```
创建一个新的 APT 源列表文件用于存放 VSCode 的软件包地址信息。
对于 amd64 架构:
```bash
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] http://packages.microsoft.com/repos/code stable main" > ~/temp.list
```
最后把临时生成的 `.list` 文件移动至 `/etc/apt/sources.list.d/` 目录下使其生效。
```bash
sudo mv ~/temp.list /etc/apt/sources.list.d/vscode.list
```
现在可以刷新本地APT缓存索引并开始正式安装过程了。先同步最新的可用包列表再进行实际安装动作。
```bash
sudo apt update && sudo apt install code
```
当上述指令完成后即代表成功完成了Visual Studio Code在Ubuntu上的部署工作[^2]。
如果希望能够在终端里直接键入 `code .` 来启动编辑器,则需确认环境变量已正确配置好路径指向。通常情况下,默认安装已经处理好了这一点;但如果遇到问题无法正常调用的话,可参照特定指南来进行调整[^3]。
ubuntu 命令行下载vscode
### 如何在 Ubuntu 使用命令行下载 Visual Studio Code
为了在 Ubuntu 中通过命令行下载并安装 Visual Studio Code,可以按照以下方法操作:
#### 方法一:使用官方存储库安装
这种方法确保始终获取最新版本的 VS Code 并能自动更新。
1. 添加 Microsoft 的 GPG 密钥:
```bash
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
```
2. 将此密钥添加到 APT 键环中:
```bash
sudo install -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
```
3. 配置稳定版仓库:
```bash
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
```
4. 更新软件包列表并安装 VS Code:
```bash
sudo apt update && sudo apt install code
```
以上步骤能够使用户轻松地从命令行完成整个过程[^1]。
#### 方法二:直接下载 `.deb` 文件并通过命令行安装
如果偏好一次性下载特定版本,则可以选择这种方式。
1. 访问官方网站上的下载页面,复制适用于 Linux (.deb) 版本链接地址。
2. 利用 `wget` 或者 `curl` 命令来下载文件至本地机器上。例如:
```bash
wget https://update.code.visualstudio.com/latest/linux-deb-x64/stable -O ~/Downloads/code_latest_amd64.deb
```
3. 转移到保存有该 `.deb` 文件的目录,并执行安装指令:
```bash
cd ~/Downloads
sudo dpkg -i ./code_latest_amd64.deb
```
这会把应用程序部署到位,并允许立即启动它[^3]。
一旦完成了上述任一种方式的操作之后,就可以利用简单的 `code .` 来开启当前工作区内的编辑器实例了;当然在此之前可能还需要设置环境变量以便全局调用 `code` 命令[^4]。
阅读全文
相关推荐














