The classic “hello world” program is a good way to get started with Ruby, or with any other programming language in general.

First, login to your server via SSH. To login to SSH, you need an SSH client such as putty. You can download putty from our download center if you do not already have it.

After logging in, verify that you have Ruby installed and active on your server by running the following command:

ruby -v

This should return the version of ruby you are running, which will let you know you have it installed.

ruby 1.8.7

Now, create a file called hello-world.rb by doing the following:

touch hello-world.rb

Now the file you just created should show up when you do a directory listing using the following command:

ls

Now, let’s go in and edit the hello-world.rb file we just created:

nano hello-world.rb

Running the above command will open the file editor for the file you just created. It should be blank. In this file, type the following line of code:

puts 'Hello world'

Once you do that, save the file and exit. Press ctrl-x on your keyboard. You will be asked if you want to save. Press Y for yes. Then, press enter to save it as the same file name without making changes to the file name.

You have now created a ruby file. You should be back at your command prompt. Run the following command to see if it works correctly:

ruby hello-world.rb

This should return text that says “Hello World”. That’s it, you’ve just written your first Ruby application with the classic “hello world” introduction!