Ubuntu Linux

How to Install Ruby on Ubuntu Linux

Richard
Written by
Richard
May 28, 2020 Updated Mar 18, 2026 5 min read
How to Install Ruby on Ubuntu Linux

This article describes steps one can take to install Ruby on Ubuntu Linux.

Ruby is a popular high-level programming language known for its focus on simplicity and elegant syntax. It is widely used for web development and is behind the powerful Ruby on Rails framework.

Installing Ruby on Ubuntu Linux allows you to develop and run Ruby applications on your Ubuntu system. Multiple ways to install Ruby on Ubuntu include the built-in apt package manager, Rbenv, and RVM.

Depending on your needs, you can choose the method that best suits your requirements.

How to install Ruby on Ubuntu Linux

As described above, Ruby is a popular, high-level programming language focused on simplicity. It has an elegant syntax that is easy to read and write and is behind the powerful Ruby on Rails Framework.

Install Ruby via Apt

Again, the easiest way to install Ruby on Ubuntu is via the apt package manager. To do that, simply run the commands below:

🐧Bash / Shell
sudo apt update
sudo apt install ruby-full

To verify if Ruby is installed, run the commands below:

💻Code
ruby --version

It should output a similar line as below:

💻Code
Ouput:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

Install Ruby via Rbenv

Another way to install Ruby is via Rbenv. Rbenv is a tool that allows you to switch between different versions of Ruby but doesn’t allow you to install Ruby.

To get Ruby, we’ll need to use ruby-build. To install Ruby-build, run the commands below to install dependencies.

🐧Bash / Shell
sudo apt update
sudo apt install git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev

After that, run the commands below to clone both Rbenv and Ruby-build repositories at Github.

💻Code
curl -sL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash -

Next, run the commands below if you’re running Bash Shell in Ubuntu.

Command Prompt
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

If you’re running Z Shell, run the lines below:

Command Prompt
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc

After the steps above, you can install any available version of Ruby. To list the available versions, run the commands below:

💻Code
rbenv install -l

Then, install the version you want by using the commands below. For this post, we’re installing Ruby 2.5.1.

💻Code
rbenv install 2.5.1
rbenv global 2.5.1

Replace the version number with the correct one that suits your environment.

To verify the Ruby version, run the commands below:

💻Code
ruby -v

It should output a similar line as below:

💻Code
Output:
ruby 2.5.1p206 (2019-10-01 revision 67816) [x86_64-linux]

Install Ruby via RVM

RVM is another tool for installing and managing Ruby on Linux systems, including Ubuntu.

To install RVM and use it to get Ruby, follow the steps below:

First, install dependencies by running the commands below:

🐧Bash / Shell
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

Then, run the commands below to install RVM.

💻Code
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

After that, run the command below to activate RVM

💻Code
source ~/.rvm/scripts/rvm

To install Ruby, run the commands below:

💻Code
rvm install 2.5.1
rvm use 2.5.1 --default

To verify if Ruby is installed, run the commands below:

💻Code
ruby -v

It should output a similar line as below:

💻Code
Output:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]

Conclusion:

  • Ruby is a versatile and high-level programming language ideal for web development.
  • Multiple methods are available for installing Ruby on Ubuntu Linux, including using the apt package manager, Rbenv, and RVM.
  • Each installation method has its advantages, such as simplicity with apt and version management with Rbenv and RVM.
  • Verifying the installation is straightforward by checking the Ruby version through the command line.
  • With Ruby installed, you can begin developing robust applications, leveraging the powerful Ruby on Rails framework and a vast array of libraries.

Frequently Asked Questions

What is the easiest way to install Ruby on Ubuntu?

The easiest way to install Ruby on Ubuntu is by using the apt package manager. You can do this by running the commands 'sudo apt update' followed by 'sudo apt install ruby-full'.

How can I verify if Ruby is installed on my Ubuntu system?

To verify if Ruby is installed, you can run the command 'ruby --version' in the terminal. If Ruby is installed, it will display the version number.

What is Rbenv and how do I use it to install Ruby?

Rbenv is a tool that allows you to manage multiple Ruby versions on your system. To use Rbenv, you first need to install it along with ruby-build, and then you can install your desired Ruby version using the command 'rbenv install '.

Can I install Ruby using RVM on Ubuntu?

Yes, RVM (Ruby Version Manager) is another tool that allows you to install and manage Ruby versions on Ubuntu. You can install RVM by following specific commands that set it up on your system.

What should I do if I encounter issues while installing Ruby on Ubuntu?

If you encounter issues while installing Ruby, ensure that all dependencies are installed correctly. You can also check online forums or the official Ruby documentation for troubleshooting tips.

Was this guide helpful?

Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, the owner and lead writer at Geek Rewind, is a tech enthusiast passionate about simplifying complex IT topics. His years of hands-on experience in system administration and enterprise IT operations have honed his ability to provide practical insights and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

2454 articles → Twitter

📚 Related Tutorials

How to Install Plex Desktop on Ubuntu Linux
Ubuntu Linux How to Install Plex Desktop on Ubuntu Linux
How to Install CakePHP on Ubuntu 24.04
Ubuntu Linux How to Install CakePHP on Ubuntu 24.04
How to Manage Logout Prompt on Ubuntu Linux
Ubuntu Linux How to Manage Logout Prompt on Ubuntu Linux
How to Mount Windows 11 Shares on Ubuntu Linux
Ubuntu Linux How to Mount Windows 11 Shares on Ubuntu Linux

Leave a Reply

Your email address will not be published. Required fields are marked *