┌──(root㉿kali)-[/home/kali] └─# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env info: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. Rustup metadata and toolchains will be installed into the Rustup home directory, located at: /root/.rustup This can be modified with the RUSTUP_HOME environment variable. The Cargo home directory is located at: /root/.cargo This can be modified with the CARGO_HOME environment variable. The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at: /root/.cargo/bin This path will then be added to your PATH environment variable by modifying the profile files located at: /root/.profile /root/.bashrc /root/.zshenv You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host
时间: 2025-08-19 10:21:26 浏览: 2
<think>好的,用户现在想在Kali Linux上安装Rust和Cargo,以准备安装Sui CLI。他们之前已经询问过如何在Ubuntu上安装Sui CLI,现在转向Kali Linux,可能因为他们在使用WSL或者直接使用Kali作为开发环境。需要参考之前的对话和提供的引用内容来给出正确的步骤。
首先,用户可能已经按照之前的指导在Ubuntu上尝试过,但Kali Linux可能有些不同。需要确保步骤适用于Kali,尤其是依赖项的安装。Kali基于Debian,所以apt命令应该适用,但可能需要确认包名称是否正确。
根据引用[1],用户需要安装Rust,但提到了网络问题,可能需要多次尝试或者使用镜像。引用[2]和[5]提到使用国内镜像加速安装,比如阿里云或中科大的源,这对用户可能很重要,尤其是在中国可能会遇到网络问题。因此,建议用户配置镜像源来加速安装。
另外,引用[1]详细说明了环境变量的配置,如果在安装后无法找到rustc,需要手动添加PATH到.bashrc或.zshrc。用户可能在这部分遇到问题,需要明确指导如何编辑配置文件,比如使用nano或者vi,并source文件使配置生效。
用户提到Kali Linux,可能使用的是默认的shell是bash,所以重点放在.bashrc上。同时,引用[3]提到在WSL的Kali上安装,可能需要确认是否某些步骤在WSL环境下有所不同,但基本步骤应该一致。
需要确保用户安装的是最新版本的Rust,因为引用[2]提到系统自带的版本可能过旧,导致无法下载第三方库。因此,安装后要更新工具链,并检查版本是否正确。
最后,验证安装是否成功,确保rustc和cargo命令可用,这样后续安装Sui CLI时不会出错。可能还需要提醒用户如果遇到权限问题,使用sudo或者正确配置权限。
总结步骤应该是:安装依赖→配置镜像→安装Rust→配置环境变量→验证安装。同时,要给出具体的命令,并解释每一步的作用,确保用户能够顺利执行。</think>### 在Kali Linux上安装Rust和Cargo并配置环境变量的步骤
---
#### **1. 安装系统依赖**
Kali Linux基于Debian,需先安装编译工具链和基础库:
```bash
sudo apt update && sudo apt install -y curl build-essential cmake pkg-config libssl-dev
```
此步骤确保系统具备Rust编译所需的基础环境[^1][^3]。
---
#### **2. 配置国内镜像(可选)**
若网络不稳定,可通过中科大镜像加速Rust安装(参考引用[2][^2][^5]):
```bash
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
```
---
#### **3. 通过curl安装Rust和Cargo**
执行官方安装脚本(自动包含Cargo包管理器):
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
安装过程中选择默认选项(按回车确认)。
**关键点**:当出现`Rust is installed now. Great!`时表示安装成功[^1]。
---
#### **4. 配置环境变量**
安装完成后需手动加载Rust工具链路径(引用[1][^1]):
```bash
source $HOME/.cargo/env
```
**永久生效配置**:
在Shell配置文件中添加路径(例如`.bashrc`):
```bash
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```
---
#### **5. 验证安装**
检查Rust和Cargo版本:
```bash
rustc --version # 应输出类似 rustc 1.70.0 (90c541806 2023-05-31)
cargo --version # 应输出类似 cargo 1.70.0 (ec8a8a0ca 2023-04-25)
```
---
#### **6. 更新工具链(可选)**
若需升级至最新稳定版:
```bash
rustup update
```
---
### 常见问题处理
- **安装失败**:多尝试几次curl命令(网络波动可能导致失败)[^1]。
- **找不到命令**:检查`.bashrc`或`.zshrc`中的`PATH`配置是否包含`$HOME/.cargo/bin`[^1]。
- **旧版本冲突**:通过`rustup default stable`强制使用新版本[^2]。
---
阅读全文
相关推荐



















