We're so happy you're here. We're going to start out with some basic things you'll need to know before getting started with programming.
By the end, we'll have run our first program!
We'll need to run programs from a terminal. Mine looks like this. Yours might looks a little different.
The first command we're going to learn is ls. ls is short for "list", and lists all the files in a directory. For me, this lists all the folders I have:
bork@kiwi $ ls
bin dat Desktop Dropbox stripe work
clones data downloads media tmp www
We can make a new directory using mkdir. All of the commands we're going to use will be shortened in this way -- they were named in the 70s when people thought saving characters was really important.
Let's make a directory called "railsbridge"!
bork@kiwi $ mkdir railsbridge
bork@kiwi $ ls
bin dat Desktop Dropbox stripe railsbridge work
clones data downloads media tmp www
Excellent! We now have a "railsbridge" directory! We can now change to this directory using cd. This stands for "change directory".
bork@kiwi $ cd railsbridge
bork@kiwi:~/railsbridge $ ls
This time ls doesn't print anything. But that's okay! It's because the directory is empty!
Okay, let's make a file!
We'll need to use a text editor to do this. This means something like Sublime Text 2 or TextEdit, not Word.
- Open your text editor
- Create a new file and save it as "yay.txt" in your railsbridge directory
- Go back to your terminal and run "ls" again. You should see your file!
bork@kiwi:~/railsbridge $ ls
yay.txt
NOW WE CAN WRITE OUR FIRST PROGRAM. In Ruby!
This is basically the same as the last step.
- Open your text editor
- Create a file and save it as "hello.rb"
- Go back to your terminal and run
ruby hello.rb
You file should say this:
puts "I am at Railsbridge!!!"
Run your program!
bork@kiwi:~/railsbridge $ ls
hello.rb yay.txt
bork@kiwi:~/railsbridge $ ruby hello.rb
I am at Railsbridge!!!
If it works, you are now a programmer! Congratulations.
Terminal commands:
lslists filescdchanges directories. You can docd ..to go into a parent directorymkdircreates directoriesrubyruns Ruby programs
