[Solved] How to Check Your Ruby Version on Linux

5/5 - (1 vote)

πŸ’¬ Post by LinuxLearner101: Hello all, I’m starting with Ruby programming on my Linux system and need to make sure I have the right version for a project I’m working on. How do I check which version of Ruby is installed on my Linux machine? Any help would be much appreciated!

πŸ’‘ Best Answer by PenguinCoder: Hey LinuxLearner101, Welcome to the Ruby world on Linux! Checking the version of Ruby installed on your Linux machine is quite simple and only requires a couple of steps. Here’s how to do it:

Step 1: Open Terminal

First, you need to open your Terminal. You can usually find it in your applications menu, or you can press Ctrl + Alt + T which is a common shortcut for opening Terminal in many Linux distributions.

Step 2: Check Ruby Version

Once your Terminal is open, enter the following command and press Enter:

ruby -v

This command will display the current version of Ruby installed on your system. You might see something like this:

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

Here, 2.7.0 is the version number, and the rest provides additional details about the build.

Step 3: Understanding the Output

If you see a version number, then you have Ruby installed! If the terminal outputs something like “command not found”, it indicates that Ruby might not be installed on your machine.

Additional Tips:

  • Installing Ruby: If Ruby isn’t installed, you can easily install it using your package manager. For Ubuntu and other Debian-based systems, you can use sudo apt-get install ruby-full. For Fedora and other RHEL-based systems, use sudo dnf install ruby.
  • Using a Version Manager: For managing multiple Ruby versions, consider using a version manager like rbenv or RVM. These tools allow you to switch between different Ruby versions for different projects.

Resources for Further Learning:

If you have any more questions or need further assistance, feel free to ask. Happy coding!

πŸ’¬ Reply from LinuxLearner101: Thank you, PenguinCoder! That was exactly what I needed. I checked and realized I didn’t have Ruby installed, so I followed your instructions and installed it using apt-get. All set now!