怎么在Linux中安装Rust编程语言
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,这篇文章给大家分享的是有关怎么在Linux中安装Rust编程语言的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。Rust 通常被称为 rust-lang。Rust 是一个由
千家信息网最后更新 2025年12月02日怎么在Linux中安装Rust编程语言
这篇文章给大家分享的是有关怎么在Linux中安装Rust编程语言的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
Rust 通常被称为 rust-lang。Rust 是一个由 Mozilla Research 赞助的通用的、多范式、现代的、跨平台和开源系统编程语言。
它旨在实现安全性、速度和并发性等目标。
Rust 在语法上与 C++ 相似,但它的设计者希望它在保持性能的同时提供更好的内存安全性。
Rust 目前在许多组织中使用,例如 Firefox、Chef、Dropbox、Oracle、GNOME 等。
如何在 Linux 中安装 Rust 语言?
我们可以通过多种方式安装 Rust,但以下是官方推荐的安装方式。
$ curl https://sh.rustup.rs -sSf | shinfo: downloading installer Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /home/daygeek/.cargo/bin This path will then be added to your PATH environment variable by modifying theprofile files located at: /home/daygeek/.profile /home/daygeek/.bash_profile You can uninstall at any time with rustup self uninstall and these changes willbe reverted. Current installation options: default host triple: x86_64-unknown-linux-gnu default toolchain: stable modify PATH variable: yes 1) Proceed with installation (default)2) Customize installation3) Cancel installation>1 info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'info: latest update on 2018-12-06, rust version 1.31.0 (abe02cefd 2018-12-04)info: downloading component 'rustc' 77.7 MiB / 77.7 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'rust-std' 54.2 MiB / 54.2 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'cargo' 4.7 MiB / 4.7 MiB (100 %) 1.2 MiB/s ETA: 0 s info: downloading component 'rust-docs' 8.5 MiB / 8.5 MiB (100 %) 1.2 MiB/s ETA: 0 s info: installing component 'rustc'info: installing component 'rust-std'info: installing component 'cargo'info: installing component 'rust-docs'info: default toolchain set to 'stable' stable installed - rustc 1.31.0 (abe02cefd 2018-12-04) Rust is installed now. Great! To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically. To configure your current shell run source $HOME/.cargo/env
运行以下命令配置当前 shell。
$ source $HOME/.cargo/env
运行以下命令验证已安装的 Rust 版本。
$ rustc --versionrustc 1.31.0 (abe02cefd 2018-12-04)
如何测试 Rust 编程语言?
安装 Rust 后,请按照以下步骤检查 Rust 语言是否正常工作。
$ mkdir ~/projects$ cd ~/projects$ mkdir hello_world$ cd hello_world
创建一个文件并添加以下代码并保存。确保 Rust 文件始终以 .rs 扩展名结尾。
$ vi 2g.rs fn main() { println!("Hello, It's 2DayGeek.com - Best Linux Practical Blog!");}运行以下命令编译 rust 代码。
$ rustc 2g.rs
上面的命令将在同一目录中创建一个可执行的 Rust 程序。
$ ls -lhtotal 3.9M-rwxr-xr-x 1 daygeek daygeek 3.9M Dec 14 11:09 2g-rw-r--r-- 1 daygeek daygeek 86 Dec 14 11:09 2g.rs
运行 Rust 可执行文件得到输出。
$ ./2gHello, It's 2DayGeek.com - Best Linux Practical Blog!
好了!正常工作了。
将 Rust 更新到***版本。
$ rustup updateinfo: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'info: checking for self-updates stable-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0 (abe02cefd 2018-12-04)
运行以下命令从系统中删除 Rust 包。
$ rustup self uninstall
卸载 Rust 包后,删除 Rust 项目目录。
$ rm -fr ~/projects
感谢各位的阅读!关于"怎么在Linux中安装Rust编程语言"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
语言
命令
运行
编程语言
编程
中安
文件
安全
代码
内容
安全性
方式
更多
版本
目录
篇文章
系统
工作
不错
实用
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发页面设计
mssql清理数据库日志
数据库分类汇报
浙江沃德尔科技集团软件开发
单核服务器
数据库视图添加分组依据
辅助网络安全现状
如何拉重复数据库
三国杀怎么转服务器
数据库auto incr
勇敢的灵魂服务器选择
教学软件开发哪家好用
重庆共享汽车软件开发
宿州企业软件开发公司哪家好
开发板 数据库 数据折线图
北京像素软件开发的游戏
软件开发及服务合同能退税吗
虹口区个人软件开发管理制度
服务器的机箱构架
网络安全专业的背景
网络技术知识答题竞赛
吴忠市政务软件开发怎么收费
迁西数据网络技术售后保障
嘉定区软件开发有哪些
扇贝单词软件开发的实施方案
临沂群思网络技术
华大 国家资源数据库
山东服务器运维管理系统价格
软件开发监控绩效考核
go 语言游戏服务器