Videos
If you are going to be a networking guru or a security specialist in linux, it is really useful to know C and C++ programming languages. Virtually everything in the world is written in C++ as it is the most flexible and powerful language around.
There is a free C++ compiler available on linux called gcc. This should be available to you on cislab. g++ is the C++ compiler in the gcc package.
>man gcc
>man g++
//report on each.
Now, you are going to compile a program in C++ like a hardcore developer/hacker. Using the VI system (discussed in class). If you are unsure about VI, be sure and revisit the module for that class.
create the file:
>vim mySimpleC.cpp
In vim, type the following exactly (or better still, copy and paste it.
//begin program here
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World" << endl;
cout << "OOOOOOOO, AAAAAHHHHHHHH" << endl;
return 0;
}
//end program here
Now, you have to type esc, :wq and that should put you back at the command line.
This is a simple program which will print "Hello World" on the screen when it runs (oooo, ahhh). Very low end.
C++ is a compiled language which requires that you convert this into machine code using the compiler.
>g++ -o simpleC mySimpleC.cpp
//this should generate the simpleC binary in your directory. Do an ls to see if it is there. Do an ls -al to see the permissions.
In order to run this program, you will have to change the permissions for the owner (you) to execute. This is a chmod command (see class notes).
>man chmod
//report
>chmod 700 simpleC
//explain what happened here and why it is 700
now you can run it
>./simpleC
//report
That's all there is to it. If you have any errors, you probably mistyped something. Report all events in your lab manual. Feel free to write a more complicated program.