Tuesday, March 18, 2014

Programming "Hello World" with Linux in (Java, C#, Ruby and Python)

SPECIFICATION OF MY PC
System type: Microsoft Windows 7 professional, 32-bit Operating system / XUBUNTU 13.10
Motherboard: Gigabyte X58A-UD3R
Processor: Intel Core i7 CPU   960 @ 3.20Ghz
Ram: 4,00GB (3,5GB usable)
Hard drive: 367GB
Video card: Nvidia GeForce GTX 560 Ti
Current resolution: 1680*1050, 59Hz
Cd/dvd/Blueray Drive: Asus BW-12B1LT


This publish includes eleven (11) steps to program "Hello World" with different 
programming languages. Follow the steps and you'll have learned how to program Hello world in different programming languages in no time. In case there is any problems please leave a comment and I'll do my best to help you. Hope it helps.



Step one (1)

Programming with Java. First you download "openjdk-7-jdk" Install it with command "sudo apt-get openjdk-7-jdk"

Step two (2)

Now to start programming you have to first create text file with command "nano HelloWorld.java" here you write the code. I have to highlight REMEMBER NAME THE FILE THE SAME NAME AS THE CLASS! 


 Step three (3)

Write the following text to the text file and save it:

class HelloWorld
{
       public static void main(String[] args)
                    {
                      System.out.println(“Hello World!”);
                    }
}




Step four (4)

After that you have to compile the program and execute it. To do this first make the command "Javac HelloWorld.java" after pressing enter it'll compile the program. After that we can execute it and it should work and execute it with command "java HelloWorld" something like in this picture should happen:




Step five (5)

Programming with C#. In here we also need compiler for C#. We'll have to install app called mono mcs. To install in just type command "sudo apt-get mono-mcs". 

Step six (6)

After installing you do the same as earlier, but just with command "nano HelloWorld.css"
After that as the text file opens you can enter for example this and save it:

public class HelloWorld
{
   public static void Main()
   {
      System.Console.WriteLine("Hello World!");
   }

}



Step seven (7)

In last step of c# we'll have to compile it with command "mcs HelloWorld.cs" and execute it with command "Mono HelloWorld.exe"



Step eight (8)

Programming with Python. First you have to check if you have python interpreter. You can check it with command "whereis python" In this case we've it.



Step nine (9)

To open python just type command "python" and it'll give you starting message and start the program.
After doing this you can just type in command line " print "Hello world!" and it'll print it out.





Step ten (10)

Programming with Ruby. First you have to get the application. You get it by scrollback first from python and then typing "sudo apt-get ruby-full"

Step eleven (11)

After that you can simply do the same trick as in python. Just type ruby and it'll open the program. Type "print ("Hello World!\n") this code will print out the text. As we want the text to be in new line not all connected to each other we used "\n" to use line break.





Links:

http://terokarvinen.com/2014/agenda-for-linux-basics-dat8tf063-23-spring-2014

THANK YOU FOR READING!

HOPE IT HELPED

Login and hosting SSH

SPECIFICATION OF MY PC
System type: Microsoft Windows 7 professional, 32-bit Operating system / XUBUNTU 13.10
Motherboard: Gigabyte X58A-UD3R
Processor: Intel Core i7 CPU   960 @ 3.20Ghz
Ram: 4,00GB (3,5GB usable)
Hard drive: 367GB
Video card: Nvidia GeForce GTX 560 Ti
Current resolution: 1680*1050, 59Hz
Cd/dvd/Blueray Drive: Asus BW-12B1LT

This publish includes eleven (11) (includes also bonus) steps to Make your own website and Login SSH. Follow the steps and you'll have learned how to make personal website and have logged in using SSH in no time. In case there is any problems please leave a comment and I'll do my best to help you. Hope it helps.


Step one (1)


        In the beginning begin with "sudo apt-get update" to update the list of available software in your console.


Step two (2)


Search for open SSH with the command "sudo apt-cache search openSSH"  Make sure that you have found the right program from the list before proceeding!!!


Step three (3)


Install  the program in this case "openssh-server" with command "sudo apt-get install openssh-server". Press y to complete installation.

Step four (4)

To test the program try to make a profile. for example I used "sudo adduser badham", it's important to have your own name in it to make it simple.

Step five (5)


The terminal will ask you to enter your own password. Add your own password and make it hard to crack.
The terminal also asks some extra info, but as this is a test case you won't need that.It also asks for confirmation and you just apply by typing "y" and pressing "enter"



Step six (6)


After the installation we should test the connection and see if everything works correctly. To login to your SSH you can test it easily with command "ssh username@localhost" for this example "ssh badham@localhost". It worked.

Step seven (7)


Apache2 webserver is earlier installed and the command "sudo a2enmod" to allow users own directory. If you want to have more detailed info you can read from my earlier post here: "http://tinyurl.com/ncp894b". Because of this I can continue my work.  Make sure that you are in your own directory. You can find out with command "pwd". If it prints "/home/username"

Step eight (8)


Now it's time to create own folder for the webpage. Make it with command "mkdir public_html" you can check that it created a folder with command "ls". After all that enter the folder with command "cd publix_html"

     Step nine (9)

      After that we create index page for our site. Do this by typing "Nano index.html" It opens the text file. In       here as this is a test page you can just use basic html.



   Step ten (10)

To test that everything works for the last time, open a browser and type in the place where you put your website "http//:localhost/~username" in this case "http//:localhost/~badham"




Step eleven bonus step (11)

Little bit termonology as bonus:
Public key = anyone can encrypt the message with public key, but only the guy who owns the paired private key can open it.

Man in the middle = person who captures conversation and can control the message flow even so that the people who discuss won't find out.

NAT (Network address translation) = Methodology of modifying network address information in internet protocol datagram packet headers as they are traffic routing device of remapping one ip address to another.

Two way authentication = To have to identifying pass ways two needed to access a computer/network. Works as the ATM card in easy way explained. You need the card and the code to access the money in the card.

Strong Encryption = To make a strong encryption that is very hard to break even with the brute hacking

symmetric encryption = Where the both users have the same common key to encrypt and crypt messages


Links:

http://terokarvinen.com/2014/agenda-for-linux-basics-dat8tf063-23-spring-2014

THANK YOU FOR READING!

HOPE IT HELPED

Tuesday, March 4, 2014

Making your own websites

SPECIFICATION OF MY PC
System type: Microsoft Windows 7 professional, 32-bit Operating system / XUBUNTU 13.10
Motherboard: Gigabyte X58A-UD3R
Processor: Intel Core i7 CPU   960 @ 3.20Ghz
Ram: 4,00GB (3,5GB usable)
Hard drive: 367GB
Video card: Nvidia GeForce GTX 560 Ti
Current resolution: 1680*1050, 59Hz
Cd/dvd/Blueray Drive: Asus BW-12B1LT

This publish includes fifteen (15) steps to Make your own website and build your database using sql. Follow the steps and you'll have learned how to make personal website and have database that has data in it in no time. In case there is any problems please leave a comment and I'll do my best to help you. Hope it helps.


Step one (1)
First step get the newest version of apps by typing sudo apt-get update. After updating you install apache2 with the command sudo apt-get install apache2. In middle of install it will pop up a question where you answer "Yes" by typing "y" after that press enter.


Step two (2)
After that try if the server works. You can test that by going to your local host in your browser: " http://localhost" If it gives this message as in the picture it works perfectly!




















Step three (3)
After that we make a directory "public_html" with "sudo mkdir public_html" in the Xubuntu folder! 




















Step four (4)

After that you first enter to the directory with "cd public_html" and  make the index.html file. You do this by writing "sudo nano index.html".























Step five (5)
After you have created your index.html you can type anything inside it. In this case we use HTML5 so we used in this example this for example:

<!doctype html><html><head>        <title>My Test Page</title>        <meta charset="utf-8" />        </head><body>        <h1> My Test Page </h1>        <p>Päivää! Welcome!!!</p></body></html>

When you have this " <meta charset="utf-8" /> " nordic letters like "ä,ö,Ã¥ " etc.
After this we save and close the file.





















Step six (6)
After that we give everybody right to edit and read the index.html page. We do that by using the command "sudo chmod 666 index.html"


Step seven (7)
After that we need to give the right to Apache server to use your userdir to access the index.html that you just created in Apache module . You do that by executing the command "sudo a2enmod userdir".






















Step eight (8)
It will give you the suggestion to restart your Apache server. You just follow the text and execute the command " sudo Service apache2 restart".





















Step nine (9)
Now you can try to access your webpage in your browser. You do this with "ip/~username" for example "192.168.0.11/~xubuntu" if you don't know your ip you can check it with command "ip addr" your ip will be in the third line next to "inet" if you also have problem to know what is your user you can use command "whoami" and it will print your username. If everything worked correctly you should get this page in your browser:





















Step ten (10)
Next we  are installing database for our server. In this case we are using mysql-server. To get this you need to install "mysql-server" and "mysql-client" you can do this by first typing "Sudo apt-get install mysql-server" and after that "Sudo apt-get install mysql-client" after installing them you can start using the database program by typing "mysql -u root –p"






















Step eleven (11)
After the program has opened you first create the database you use command " CREATE DATABASE" in our example we use Products so we type "CREATE DATABASE Products" remember yo use the capitals in "CREATE DATABASE"! 


Step twelve (12)
after that you start using it with command "USE" in this case because we made "Products" we type "USE Products". After that we build a table. in this case our table is only going to have personal ID number, name of the product and description what the product is. We can do that by typing " CREATE TABLE Product (id PRIMARY KEY, pName NVARCHAR(80), pDescription NVARCHAR(200));






















Step thirteen (13)
To show the table you can simply write "SHOW TABLES"





















Step fourteen (14)
Before adding data to your table you have to think what data you want to put in there and you have to also put it in the same order you built the database. As we gave in this case first value as integer it has to be numeral value, other values where NVARCHAR so we can use only text in these values remember, The number we wrote inside the NVCHAR brackets describes the amount of characters you can use. So in this case for example the product pName you can use only "80" characters. Also spaces are characters.  Remember to have this " ' " sign always infront and behind the text you have written otherwise it'll be an error. Also remember to seperate different values with coma " , ". To insert data to the table you simply type" INSERT INTO PRODUCT VALUES(0001,'SuperBall,'Bouncing ball, that bounces a lot');" 




















Step fifteen (15)
To show  whats in the table type: "SELECT * FROM Product" and you'll see you product and description in the table. Star sign "*" means it selects everything from the table.




















Links:

http://terokarvinen.com/2014/agenda-for-linux-basics-dat8tf063-23-spring-2014
http://terokarvinen.com/2008/install-apache-web-server-on-ubuntu-4
http://terokarvinen.com/bilkent.html
http://terokarvinen.com/2012/short-html5-page




THANK YOU FOR READING!

HOPE IT HELPED

Monday, February 24, 2014

Installing with command line and showing how logs react

SPECIFICATION OF MY PC
System type: Microsoft Windows 7 professional, 32-bit Operating system / XUBUNTU 13.10
Motherboard: Gigabyte X58A-UD3R
Processor: Intel Core i7 CPU   960 @ 3.20Ghz
Ram: 4,00GB (3,5GB usable)
Hard drive: 367GB
Video card: Nvidia GeForce GTX 560 Ti
Current resolution: 1680*1050, 59Hz
Cd/dvd/Blueray Drive: Asus BW-12B1LT

This publish includes sixteen (16) steps to install application with command line and how to show different syslog reactions. Follow the steps and you'll have learned how to install with command line and also what happens in syslog in your pc in no time. In case there is any problems please leave a comment and I'll do my best to help you. Hope it helps.


Step one (1)

In the first step you open the terminal and type "Sudo apt-get update" so it'll update all the applications in the list and you'll get the newest applications in the list.

Step two (2)

As you used the command "SUDO" it will ask administrators permission. As you are the legal user of the system use the same password that you logged in with.


Step three (3)

Now the application list will update itself. You'll get something similar like this printed if everything worked perfectly.

Step four (4)

After that we are doing a simple search from the application list. The main idea is to write "sudo apt-cache search" and then what you want to search. In this example we searched simply anything that had term game in it. So I wrote "sudo apt-cache search game"

Step five (5)

Here is a example picture what came as a result as we searched for a game.

Step six (6)

After you have found the product you want to install, just type "sudo apt-get install" and the applications name that you saw in the list. In this example we used the game Granatier so I wrote "sudo apt-get install granatier"

Step seven (7)

After using the sudo command it needs the administrators rights to install the application. Just use the same password that you logged to your system in with.

Step eight (8)

After that it will start installing the program. In some cases it uses more diskspace or some other sources. In these cases you can choose do you really want the program. If you do, just type y and enter. In other case just type n and enter and it'll terminate the install.

Step nine (9)

After accepting the terms it'll continue the install and install the application. If you installed a game like in this case you'll find it in game category. In other cases it's put to the logical category where it should go. For example if you are installing a graphical tool it'll go to "Graphics" category and so on.

Step ten (10)

Then starts the starts the second lesson.

Step eleven (11)

In first step you go to the root directory. You can do this in many ways, but the way I'm showing here is simple and easy so. just type "cd .." as many times as in the picture and you'll find yourself in root folder. If you are not sure where you are you can type "ls" so it'll show all the folders.

Step twelve (12)

After that you enter to "var" directory by typing "cd var" after entering the logs you can simply enter to the log folder by just typing "cd log". After that just type "ls" so you can see all the files in that folder.

Step thirteen (13)

After that to see what happens in syslog file you type "cat syslog" so you can see what happens in there.

Step fourteen (14)


After this we will close the network so we can see one network failing example. Go to the right corner of your Linux. You'll see two arrows (one pointing up and other one pointing down) between the speaker and the date. Click it to open it and after that click the text enable networking. After that the network is closed and it should pop-up black window that says "Disconnected - you are now offline" and some text underneath that.

Step fifteen (15)

After that try cat syslog again. You will see something similar to the picture under this text. It explains that the connection has failed and that it cannot connect to the internet. In line "dns plugin dnsmaq update failed" It means it can't communicate with the server and get the update.
Step sixteen (16)

After that you can activate the internet by going back to the arrows that I explained in step fourteen. In this case just click the enable networking and soon will appear a pop-up window that says connected. In this case you've back the connection and you're happily connected to the internet again. After that you can check what the log has done by re typing "cat syslog". After that you'll see the activation stages that shows how it went and connected back to internet.

 
Links:
http://terokarvinen.com/2014/agenda-for-linux-basics-dat8tf063-23-spring-2014



THANK YOU FOR READING!

HOPE IT HELPED