Writing Hello World in 2 different programming languages, Installing OpenSSH and creating a user for it

Hello once again. In this post I will go through on how to say “Hello World” in 2 different programming languages and how to install OpenSSH plus setup a user for it. So let’s begin!

Part 1: “Hello World”

Python

With almost every distribution of Linux there is a programming language called python included within. This is one of the easiest programming languages available today (but is still a advanced and powerful language) and we’ll be using it as one of the languages to say “Hello World”.

As with any program that is included or installed through apt-get, we simply need to open the console and type the name of the program to launch it. In this case it would be

python

, but we want to make a simple file that says “Hello World”.

Open the terminal and type

nano test.py

. The file will open when you hit enter and now we are inside editing it.

As we are creating a simple file, we won’t need to put anything fancy inside of it. We called it test.py which means that it automatically understands that it’s a python file. We only need to type these commands to get it to say “Hello World” and then exit:

print "Hello World"
exit(0)

Capture18

Press ctrl+O and hit enter to save the file. Now just hit ctrl+X and you are ready to test the file. type

python test.py

Capture19

Bash

Now let’s use shell scripting to say “Hello World”. Bash isn’t really a good programming language, but instead a shell script that is designed to make the typing of many short/long commands faster instead of having to type them every single time again.

Bash uses the same principle, so let’s make a new file with nano called test.sh. Type:

nano test.sh

and hit enter

Capture20

Now type

echo "Hello World"
exit

Now save the file as you did for the python file and exit. To run a bash file we simply need to type

./test.sh

and it will run the file. Do it now.

But wait! It says “Permission Denied”, what kind of sorcery is this?! No worries, we simply need to give ourselves the right to run this specific .sh file without sudo. Type:

chmod ugo+x test.sh

and now try running it again! See, it’s showing “Hello World” now!

Capture21

And there you have it! “Hello World” said through 2 different programming languages.

 

Part 2: Installing OpenSSH and creating a user

Now it’s time to install OpenSSH and add a user to it. First type

sudo apt-get install openssh-server -y

and let it install.

Capture22

After installing we need to create a user to even have any use of the SSH server. To create a user we simply type:

sudo adduser foobar

Give the user a GOOD password and re-type it. Add any extra info if you want and press Y and then enter when asked to confirm the creation of the user. You now have a user called foobar.

We are only a couple of steps away from being done. Now we just need to connect to foobar through ssh!

First we need our IP address. To find it type

ip addr

. After finding the IP address we only need to type this in the terminal to connect to foobar using the ssh method. Simply type:

ssh foobar@10.0.2.15

and hit enter. Type the password you had created earlier and now you are inside the home folder of user foobar.

Capture24

Congratulations! You now have learned how to write “Hello World” in 2 different languages and how to setup a basic SSH server + how to create a new user in a Linux environment.

 

Thanks for reading, and as always; Thank you!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s