How to install Ruby on Linux?

Prerequisite: Ruby Programming Language
 
Before we start with the installation of Ruby on Linux, we must have first-hand knowledge of what Ruby is?. Ruby is a pure Object-Oriented language developed by Yukihiro Matsumoto (also known as Matz in the Ruby community) in the mid-1990s in Japan. Everything in Ruby is an object except the blocks but there are replacements too for it i.e procs and lambda. The objective of Ruby’s development was to make it act as a sensible buffer between human programmers and the underlying computing machinery.
 
Ruby is based on many other languages like Perl, Lisp, Smalltalk, Eiffel and Ada. It is an interpreted scripting language which means most of its implementations execute instructions directly and freely, without previously compiling a program into machine-language instructions.

Downloading and Installing Ruby

Ruby for Linux can be downloaded and installed with the use of the following command on the terminal(Ctrl+Alt+T):

$ sudo apt install ruby-full

Beginning with the installation:

  • Getting Started with command:
    Ruby-Installation-Linux-01
  • Agreeing to Installation:
    Ruby-Installation-Linux-02
  • Getting Files:
    Ruby-Installation-Linux-03
  • Unpacking Files:
    Ruby-Installation-Linux-04
  • Setting up resources:
    Ruby-Installation-Linux-05
  • Finished Installation:
    Ruby-Installation-Linux-06

To check if Ruby installed correctly, perform a version check for the same using the following command on the terminal:

ruby --version

Ruby-Linux-Version-Check



Here’s a sample Program to begin with the use of Ruby Programming:
Let’s consider a simple Hello World Program.

filter_none

edit
close

play_arrow

link
brightness_4
code

puts "Hello World"

chevron_right


 
Using terminal firstly, open a text editor Notepad or Notepad++. write the code in the text editor and save the file with (.rb) extension.

To run the hello.rb Ruby script, run the command ruby hello.rb it will print the output.
Output :

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.