Install Ruby on Ubuntu 20.04

Ruby is an open-source, object-oriented, and general-purpose programming language that has recently surged in popularity as the de-facto tool for building web applications.

You are probably already familiar with Ruby. Even those who have nothing to do with software have, at some point, heard of this programming language. And that should come as no surprise; Ruby is an incredibly robust language with relatively comprehendible sentence structure. Ruby is used in many tech industries. Perhaps the greatest impact of Ruby is the ‘Ruby on Rails’ framework, upon which many famous websites are built, such as,,, and

This article will demonstrate two different ways to get Ruby up and running on your system.

  • Using Ubuntu’s official repositories
  • Using Ruby Environmental Manager, or RVM

Method 1: From Ubuntu’s Official Repositories

To install Ruby on Ubuntu, our recommendation to download it from the standard Ubuntu repositories, as this is relatively simpler than any other method. This method uses the apt package manager.

Step 1: Update the Package Index

Start by updating the package index. To do so, enter the command below:

$ sudo apt update

Step 2: Install Ruby

Enter the following command to install Ruby:

$ sudo apt install ruby-full

The above command should install Ruby on your system. All that is left now is to check if the latest version was downloaded.

Step 3: Verify the Install

Sometimes, the most stable version is not installed. To make sure that this is not the case, type in the following command:

$ ruby --version

This will print the version of Ruby you installed in Step 2. The latest version, as of uploading this tutorial, is v2.7. 1, which could be updated again by the time you install Ruby on your system.

With your install verified, you can finally start using Ruby. If the version was not up-to-date, try the second method.

Method 2: Installing with Ruby Environmental Manager (RVM)

This method involves a command-line tool called Ruby Environmental Manager, or RVM. Using this tool would be preferable if you are working on several Ruby environments at once, as this allows you to manage Ruby on any Linux system.

Step 1: Install Related Dependencies

First, install the related dependencies. Use the following commands to do so:

$ sudo apt update

$ sudo apt install curl g++ gcc autoconf automake bison libc6-dev
 \libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool
 \libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev
\libreadline-dev libssl-dev

Step 2: Install Ruby Environment Manager

To install RVM, you will need to add the GPG key first. Enter the following command to do so:

$ gpg --keyserver hkp:// --recv-keys

Then, install RVM by entering the following:

$ curl -sSL | bash -s stable

Step 3: Check for Latest Ruby Version

Enter the following to open the script environment variables and summon a list of Ruby versions compatible with your system:

$ source ~/.rvm/scripts/rvm

$ rvm list known

Step 4: Install Ruby

Now, you just need to pick a version to install. You should install the latest version available. Enter the following command to install Ruby:

$ rvm install ruby

To set this version of Ruby as the default version, type:

$ rvm --default use ruby

If you do not wish to install the latest version, then you must specify which version you would like to install.

For example, if you are downloading version 2.2.7, then you must modify the command as follows:

$ rvm install ruby-2.2.7
$ rvm --default use ruby-2.2.7

You have now successfully installed Ruby on your Ubuntu 20.04 system.

To print out the version number, type in the following:

$ ruby -v

This should verify the version installed on your system.

In Summary

Ruby is a great language that balances the key components of functional and imperative programming, making it an incredibly versatile programming tool and a great place to start learning how to code.

This article discussed two methods to install Ruby. Downloading and installing Ruby directly from the Ubuntu repositories is the simplest and quickest way to go. However, using RVM comes with the additional benefit of managing the different versions to install and update.

About the author

Younis Said

I am a freelancing software project developer, a software engineering graduate and a content writer. I love working with Linux and open-source software.