---
title: "How To Install RubyGems On Linux"
description: "RubyGems is a popular package manager for the Ruby programming language. RubyGems allows you to download and manage “gems”, or software packets, that you can use in your own Ruby programs. Many..."
url: https://www.inmotionhosting.com/support/server/linux/install-rubygems-on-linux/
date: 2022-02-22
modified: 2025-03-10
author: "Christopher Maiorana"
categories: ["Linux"]
type: post
lang: en
---

# How To Install RubyGems On Linux

![How to install RubyGems on Linux](https://www.inmotionhosting.com/support/wp-content/uploads/2022/02/How-To-Install-RubyGems-on-Linux-1024x538.png)

RubyGems is a popular package manager for the Ruby programming language. RubyGems allows you to download and manage “gems”, or software packets, that you can use in your own Ruby programs. Many Ruby programs, like the [Jekyll content management system](https://www.inmotionhosting.com/support/website/jekyll/how-to-install-jekyll/) are actually gems, and the plugins you can use for Jekyll are also gems. Installing RubyGems on your [Linux server](/vps-hosting/linux-vps), or local workstation, can help you easily manage a vast library of gems.

- [How to Install RubyGems on Linux](#install-rubygems-linux)
- [Using Package Managers](#package-manager)
  - [Using The `apt` Package Manager (Debian, Ubuntu)](#apt)
  - [Using The `yum` Package Manager (CentOS, Fedora)](#yum)
- [Installing RubyGems From Source](#install-from-source)

## How to Install RubyGems on Linux

There are a few different ways to install RubyGems on Linux. The path you choose will depend on your comfort level, which version you want, and other factors. You can install RubyGems from source or use some of the popular Linux package managers available for your distribution.

This article will cover the `apt` package manager available for Debian-based distributions like Ubuntu, as well as the `yum` package manager available for most RedHat-based Linux distributions such as CentOS and Fedora. This article also assumes that you have already installed a full version of Ruby in your system.

## Using Package Managers

It is generally recommended that you not install RubyGems or subsequent gems as the root user. This is why the command below uses the `sudo`.

### Using The `apt` Package Manager (Debian, Ubuntu)

To install RubyGems with the `apt` package manager, you can use the following command:

sudo apt install rubygems

### Using The `yum` Package Manager (CentOS, Fedora)

To install RubyGems with the `yum` package manager, you can use the following command:

sudo yum install rubygems

## Installing RubyGems From Source

Installing RubyGems from source is a little more complicated than the above options. So why install from source?

Sometimes, the software versions available in package manager repositories are not the latest and greatest but rather a more stable, earlier version. This is fine for most day-to-day usage of package managers, but can create problems if you require the absolute latest and greatest packages. In those instances, installing from source, where possible, is the best option.

To install RubyGems from source, you will need to download a copy of the latest source code from the [RubyGems website](https://rubygems.org/pages/download).

The following commands use `wget` to download the RubyGems source code package. However, this is not required. You can download the package archive in any style you prefer as long as you can access it easily on the command line. If you would like to use `wget`, you will want to make sure it is installed on your system.

From the RubyGems website, select which format you want to download the package as (.zip, tarball, or otherwise). For usage with `wget` you only need the live download link for the “TGZ” format, which you can copy from your web browser.

![](https://www.inmotionhosting.com/support/wp-content/uploads/2022/02/rubygems_install_002.png)

Once you have the link for the package, you can proceed to use `wget` to download the package to the desired location. Many users prefer to download package archives to the `/tmp` directory, because they will be automatically trashed by the operating system on reboot:

cd /tmp

To the proceed with the download (bear in mind your version may be different):

wget https://rubygems.org/rubygems/rubygems-3.3.7.tgz

Now, you can open the archive with the `tar` command:

tar xvf rubygems-3.3.7

Change into the new directory:

cd rubygems-3.3.7/

Complete the installation by running the installation command:

ruby setup.rb

---

That’s it! You now know how to install RubyGems in your Linux server or desktop environment. If you have any questions or comments feel free to drop them below:
