{"id":12779,"date":"2019-03-28T19:41:21","date_gmt":"2019-03-28T19:41:21","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12779"},"modified":"2019-03-28T19:41:21","modified_gmt":"2019-03-28T19:41:21","slug":"how-to-install-rust-programming-language-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/how-to-install-rust-programming-language-in-linux\/","title":{"rendered":"How to Install Rust Programming Language in Linux"},"content":{"rendered":"<p><strong>Rust<\/strong>\u00a0(commonly known as\u00a0<strong>Rust-Lang<\/strong>) is a relatively new, open source practical systems programming language that runs extremely fast, prevents segfaults, and guarantees thread safety. It is a safe and concurrent language developed by\u00a0<strong>Mozilla<\/strong>\u00a0and backed by\u00a0<strong>LLVM<\/strong>.<\/p>\n<p>It supports zero-cost abstractions, move semantics, guaranteed memory safety, threads without data races, trait-based generics and pattern matching. It also supports type inference, minimal runtime as well as efficient C bindings.<\/p>\n<p><strong>Rust<\/strong>\u00a0can run on a great number of platforms and is being used in production by companies\/organizations such as\u00a0<strong>Dropbox<\/strong>,\u00a0<strong>CoreOS<\/strong>,\u00a0<strong>NPM<\/strong>\u00a0and many more.<\/p>\n<p>In this article, we will show how to install\u00a0<strong>Rust<\/strong>\u00a0programming language in Linux and setup your system to get started with writing programs with rust.<\/p>\n<h3>Install Rust Programming Language in Linux<\/h3>\n<p>To install\u00a0<strong>Rust<\/strong>, use the following official method of installing rust via the\u00a0<strong>installer-script<\/strong>, which requires\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-command-line-tools-for-downloading-files\/\" target=\"_blank\" rel=\"noopener\">curl command-line downloader<\/a>\u00a0as shown.<\/p>\n<pre>$ sudo apt-get install curl  [On <strong>Debian\/Ubuntu<\/strong>]\r\n# yum install install curl   [On <strong>CentOS\/RHEL<\/strong>]\r\n# dnf install curl           [On <strong>Fedora<\/strong>]\r\n<\/pre>\n<p>Then install rust by running the following command in your terminal, and follow the onscreen instructions. Note that rust is actually installed as well as managed by the rustup tool.<\/p>\n<pre>$ curl https:\/\/sh.rustup.rs -sSf | sh\r\n<\/pre>\n<div id=\"attachment_28815\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/install-rust-in-linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28815\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/install-rust-in-linux.png\" alt=\"Install Rust in Linux\" width=\"722\" height=\"648\" aria-describedby=\"caption-attachment-28815\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28815\" class=\"wp-caption-text\">Install Rust in Linux<\/p>\n<\/div>\n<p>Once the\u00a0<strong>Rust<\/strong>\u00a0installation is complete, the Cargo\u2019s bin directory (<code>~\/.cargo\/bin<\/code>\u00a0\u2013 where all tools are installed) will be added in your\u00a0<strong>PATH<\/strong>\u00a0environment variable, in\u00a0<code>~\/.profile<\/code>.<\/p>\n<p>During the installation\u00a0<strong>rustup<\/strong>\u00a0will attempt to add the cargo\u2019s bin directory to your\u00a0<strong>PATH<\/strong>; if this fails for one reason or another, do it manually to get started with using rust.<\/p>\n<div id=\"attachment_28816\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Add-Rust-Cargo-Bin-Directory-to-PATH.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28816\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Add-Rust-Cargo-Bin-Directory-to-PATH.png\" alt=\"Add Rust Cargo Bin Directory to PATH\" width=\"542\" height=\"211\" aria-describedby=\"caption-attachment-28816\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28816\" class=\"wp-caption-text\">Add Rust Cargo Bin Directory to PATH<\/p>\n<\/div>\n<p>Next, source the\u00a0<code>~\/.profile<\/code>\u00a0file to use the modified\u00a0<strong>PATH<\/strong>\u00a0and configure your current shell to work with the rust environment by running these commands.<\/p>\n<pre>$ source ~\/.profile\r\n$ source ~\/.cargo\/env\r\n<\/pre>\n<p>Finally verify the version of\u00a0<strong>rust<\/strong>\u00a0installed on your system by running the following command.<\/p>\n<pre>$ rustc --version\r\n<\/pre>\n<div id=\"attachment_28817\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Check-Rust-Installed-Version-in-Linux.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28817\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Check-Rust-Installed-Version-in-Linux.png\" alt=\"Check Rust Installed Version in Linux\" width=\"482\" height=\"59\" aria-describedby=\"caption-attachment-28817\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28817\" class=\"wp-caption-text\">Check Rust Installed Version in Linux<\/p>\n<\/div>\n<h3>Test Rust Programming Language in Linux<\/h3>\n<p>Now that you have\u00a0<strong>rust<\/strong>\u00a0installed on your system, you can test it by creating your first rust program as follows. Begin by making a directory where your program files will reside.<\/p>\n<pre>$ mkdir myprog\r\n$ cd myprog\r\n<\/pre>\n<p>Create a file called\u00a0<code>test.rs<\/code>, copy and paste the following lines of code to the file.<\/p>\n<pre>fn main() {\r\n    println!(\"Hello World, it\u2019s TecMint.com \u2013 Best Linux HowTos, Guides on the Internet!\");\r\n}\r\n<\/pre>\n<p>Then run the following command which will create an executable called\u00a0<code>test<\/code>\u00a0in the current directory.<\/p>\n<pre>$ rustc main.rs\r\n<\/pre>\n<p>Finally, execute\u00a0<code>test<\/code>\u00a0as shown.<\/p>\n<pre>$ .\/test \r\n<\/pre>\n<div id=\"attachment_28818\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Write-Programs-in-Rust-Language.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-28818\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Write-Programs-in-Rust-Language.png\" sizes=\"auto, (max-width: 772px) 100vw, 772px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Write-Programs-in-Rust-Language.png 772w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/03\/Write-Programs-in-Rust-Language-768x229.png 768w\" alt=\"Write Programs in Rust Language\" width=\"772\" height=\"230\" aria-describedby=\"caption-attachment-28818\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-28818\" class=\"wp-caption-text\">Write Programs in Rust Language<\/p>\n<\/div>\n<p><strong>Important<\/strong>: You should take note of these points about\u00a0<strong>rust<\/strong>\u00a0releases:<\/p>\n<ul>\n<li>Rust has a 6-week rapid release process, be sure to get many builds of rust available at any time.<\/li>\n<li>Secondly, all these builds are managed by\u00a0<strong>rustup<\/strong>, in a consistent manner on every supported platform, enabling installation of rust from the beta and nightly release channels, and support for additional cross-compilation targets.<\/li>\n<\/ul>\n<p><strong>Rust Homepage<\/strong>:\u00a0<a href=\"https:\/\/www.rust-lang.org\/en-US\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/www.rust-lang.org\/en-US\/<\/a><\/p>\n<p>In this article, we have explained how to install and use\u00a0<strong>rust<\/strong>\u00a0programming language in Linux. Try it out and give us your feedback or share any queries via the comment form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/install-rust-programming-language-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rust\u00a0(commonly known as\u00a0Rust-Lang) is a relatively new, open source practical systems programming language that runs extremely fast, prevents segfaults, and guarantees thread safety. It is a safe and concurrent language developed by\u00a0Mozilla\u00a0and backed by\u00a0LLVM. It supports zero-cost abstractions, move semantics, guaranteed memory safety, threads without data races, trait-based generics and pattern matching. It also supports &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/how-to-install-rust-programming-language-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install Rust Programming Language in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12779","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12779"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12779\/revisions"}],"predecessor-version":[{"id":12780,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12779\/revisions\/12780"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}