Instructions to set up a basic LAMP+SSH server environment
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

6.3 KiB

Linux servers - Exercise 6


This exercise is a part of Linux Server Administration (ICT4TN021, spring 2018) // Linux-palvelimet (ICT4TN021, kevät 2018) school course organized as a part of Information Technology studies in Haaga-Helia university of Applied Sciences, Helsinki, Finland. Course lecturer Tero Karvinen has defined the original assignment descriptions in Finnish presented in this document in English. Answers and translations have been written by Pekka Helenius (me, ~ Fincer).

Table of contents:

a) Write and execute "Hello world" in three code languages of your choice. Set up a necessary development environments.


Let's write "Hello World" in the following three languages: perl, python 3 and C. We need to install required development tools:

sudo apt-get -y install perl python gcc

(GCC = Gnu Compiler Collection + Wikipedia)

Let's write the codes into a subfolder hello-world in user's home dir:

[newuser@goauldhost: ~ ]$ mkdir ~/hello-world
[newuser@goauldhost: ~ ]$ cd hello-world/
[newuser@goauldhost: hello-world ]$ touch hello{.c,.py,.pl}
  • = "Hello World" written in Python 3

  • = "Hello World" written in Perl

  • hello.c = "Hello World" written in C

Hello World program written in three languages (nano editor used):

Perl (

#!/usr/bin/env perl
# Declare runtime environment above
# Include these to find common warnings, syntax errors etc in the code
import strict;
import warnings;
# Print Hello World! with a newline
print "Hello World!\n";

Python 3 (

#!/usr/bin/env python3
# Declare runtime environment above
# Print Hello World!
print("Hello World!");

NOTE! Pay attention when referring to python executable. On some Linux distributions, python still refers to python2, and on some, python refers to python3. Practices differ. It can be safer to use 'python3' or 'python2' instead of just 'python' if not sure.

In a simple program like "Hello world" this python issue doesn't really matter. However, if any python libraries are imported into the code, you must know which python environment to use, Python 2 or Python 3.

C (hello.c)

// Include Standard Input Output Library
#include <stdio.h>
// Declare main function for the program. int type for returning a integer
int main()
// Print Hello World! (stdout in CLI)
printf("Hello World!");
// Return boolean value "true" to the execution environment
return 0;

hello.c requires compiling from source code to executable binary file. Therefore, we compile the source code with the following command in hello-world folder:

gcc -o hello hello.c

after which our hello binary can be executed with


NOTE: You can check file details by issuing the following command:

file ~/hello-world/hello
hello: ELF 64-bit LSB pie executable x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/, for GNU/Linux 3.2.0, BuildID[sha1]=8e76492bc5ce6c65df8ec5ce7be42645fae2ab70, not stripped

All programs give output string "Hello World!" (stdout data stream) in our shell environment:

[newuser@goauldhost: hello-world ]$ pwd
[newuser@goauldhost: ~ ]$ python
Hello World!
[newuser@goauldhost: ~ ]$ perl
Hello World!
[newuser@goauldhost: ~ ]$ ./hello
Hello World!

b) (optional) Write a simple program for some practical purpose with each language. Ideas: utilize the key benefits of your language of choice. Take an input value from a user, generate a calculation and print the output (input-processing-layout).


This could have been very interesting assignment to work out. Unfortunately, my working laptop was broken so that I was not effectively able to write new code. I have worked with a perl program which generates random port and TCP/UDP sequences for knockd daemon. In addition, I have worked with some updates to Wine Configuration window (winecfg, part of Wine program) in C language:


See: Fincer/winecfg_patch

Some Python and bash based program-related scripts and code updates are available here: