Rust is a programming language, and it is pretty similar to C++. It is designed by Graydon Hoare. Rust was first released on July 07, 2010. In this article, we would see how to install Rust in Ubuntu 22.04 release.
At the time of writing, v1.59.0 is its latest stable release. But, as of now v1.58.1 is available through standard Ubuntu repository. But, we will still go ahead with standard Ubuntu repository installation. It would get updated some time later.
If you specifically require a particular version then, do visit official website of Rust for installation instructions.
Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.
Install Rust in Ubuntu 22.04
Since the package is available through standard Ubuntu repository. Therefore, it is best to update the repository first. This ensures we get to have the latest version of package available. Hence, open a terminal and issue the following –
sudo apt update
Next, to install Rust –
sudo apt install rustc
It installs all the related dependencies along-with it.
To verify the installation –
rustc -V
It would return with the following output –
rustc 1.58.1
In conclusion, we have discussed how to install Rust in Ubuntu 22.04 release.
Additional Info –
In this section, we would see how to write and execute a simple Hello World! program.
Open a text editor of your choice, and save the following code with file extension .rs
fn main() { // when we execute the binary, following statements would get executed println!("Hello World!"); }
println!() would print the text, in new line, “Hello World!”
We saved the file as first-code.rs
Compile the code with Rust compiler –
rustc first-code.rs
It generates a binary first-code in the current directory. Lastly, execute the binary to get the desired output.
./first-code
It would return with the following output –
Hello-World!