Ruby is one of the most popular scripting language. Ruby is an object oriented programming language, it’s open source, dynamic and cross-platform; it is well known for human friendly code. it has gained a lot of popularity (in past few years) in web world, probably due to the web application development framework – Ruby On Rails, that allow developers to build cool web applications very quickly. The same is true with Ubuntu (latest version 11.10 – Oneiric Ocelot) as it is now the most popular Linux distribution for desktop users.

Although this post isn’t going to teach Ruby but it will surely help you in getting started with Ruby, on Ubuntu 11.10 of course. Since Ruby is an interpreted language i.e source code itself is executed – line by line – by Interpreter. So first of all we need to install Ruby Interpreter.  The latest version of Ruby is 1.9.3 p0 (released on Oct 30, 2011), although 1.8.7 is also very popular as a number of applications are based on it.

If you want to quickly get started with Ruby then first install ruby 1.8.* or 1.9.* from command line or Ubuntu Software Center. Open a terminal (Ctrl+Alt+t) and execute –

sudo apt-get install ruby1.9.1

Then create a file ‘fun.rb’ and write a simple ruby program to test.

Creating a new file from terminal –

touch fun.rb

Then use a simple command line editor such as nano(or vim) or a gui gedit to put the code.

ruby program using nano

nano fun.rb
# This is a comment in Ruby!
puts "Enter something (Your Name or any number)"
some_thing = gets
puts "You said  #{some_thing}"

Then save the file (Ctrl+X => y => Enter, if you are using nano). Then you can execute the above ruby program (that simply get some input from the user and print it).


ruby fun.rb

Output :

Enter something (Your Name or any number)
just for Fun!
You said  just for Fun!

Recommended Link(s) for Learning Ruby/Ruby on Rails –

If you want to work with multiple versions of Ruby or wanna go ahead with Ruby and its libraries (called as RubyGems)or frameworks such as Ruby on Rails then you are recommended to use RVM (Ruby Version Manager) instead of installing ruby from Ubuntu Package Repository. I’ve already explained about RVM, Rails etc in detail (along with their dependencies) – install ‘Ruby on Rails’ in Ubuntu.

checkout some free Ruby tutorials!

Join the Conversation


Leave a comment

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