Install Rust on Ubuntu 18.04 LTS. Rust is fast and memory efficient with no runtime or garbage collector and easily integrate with other languages.
SSH to your Ubuntu system or server and download Rust using rustup
sudo apt update sudo apt upgradecurl https://sh.rustup.rs -sSf | sh
Now Rust will be downloaded and you will get a prompt to choose the installation options.
Choose Proceed with Installation (default) and hit Enter
.
Now latest stable version of Rust will get installed and you will get a confirmation similar to the one below.
The installation script automatically adds Rust to your system path after your next login to SSH. If you need to use Rust immediately without restarting terminal you can add Rust to path manually.
source $HOME/.cargo/env
Now you can verify the version of Rust installed in your Ubuntu.
rustc --versionOutput
rustc 1.31.1 (b6c32da9b 2018-12-18)
Rust program needs to be complied before running the file. So you need to install build-essentials
sudo apt install build-essential
Once Rust is installed you can create your first project.
mkdir ~/projects
cd ~/projects
mkdir hello_world
cd hello_world
Create a new file with the .rs
extension. If you are using more than one word for your file name you need to use underscore hello_world.rs
instead of helloworld.rs
sudo nano hello_world.rs
Paste the following code inside the new file.
fn main() {
println!(“Hello, world!”);
}
Hit Ctrl + X
followed by Y
and Enter
to save the file.
Now compile and run the program.
rustc hello_world.rs
./hello_world
You will see the output of your Rust code.
Hello, world!
Now Rust is installed on your Ubuntu and you can create your blazing fast project using Rust language.
Thanks for reading ❤
If you liked this post, share it with all of your programming buddies!
Follow us on Facebook | Twitter
☞ The Rust Programming Language
☞ Why you should move from Node.js to Rust in 2019
☞ Rust Vs. Haskell: Which Language is Best for API Design?
☞ 7 reasons why you should learn Rust programming language in 2019
☞ An introduction to Web Development with Rust for Node.js Developers
#rust #ubuntu #web-development