diff --git a/exercises/h6.md b/exercises/h6.md index 6f5dd4b..14893d7 100644 --- a/exercises/h6.md +++ b/exercises/h6.md @@ -11,7 +11,7 @@ This exercise is a part of [Linux servers (ICT4TN021, spring 2018) // Linux-palv **Answer:** -Let's write "Hello World" in the following three languages: perl, python 3 and C. Let's install needed development tools: +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 @@ -19,23 +19,23 @@ sudo apt-get -y install perl python gcc (GCC = [Gnu Compiler Collection](https://gcc.gnu.org/) + [Wikipedia](https://en.wikipedia.org/wiki/GNU_Compiler_Collection)) -Let's write the codes into a subfolder _hello-world_ in user's home dir: +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.py,hello.pl,hello.c} +[newuser@goauldhost: hello-world ]$ touch hello{.c,.py,.pl} ``` -- hello.py = "Hello World" written in Python 3 +- `hello.py` = "Hello World" written in Python 3 -- hello.pl = "Hello World" written in Perl +- `hello.pl` = "Hello World" written in Perl -- hello.c = "Hello World" written in C +- `hello.c` = "Hello World" written in C Hello World program written in three languages (nano editor used): -**Perl (hello.pl):** +### Perl (hello.pl) ``` #!/usr/bin/env perl @@ -50,7 +50,7 @@ print "Hello World!\n"; ``` -**Python (hello.py):** +### Python 3 (hello.py) ``` #!/usr/bin/env python3 @@ -61,17 +61,17 @@ print("Hello World!"); ``` -**NOTE!** Pay attention when referring to python executable. On some Linux distributions, python 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'. +**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 but if any python libraries are imported into the code, you must know which python environment to use, Python 2 or Python 3. +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):** +### C (hello.c) ``` -// Include Standard Input Output Library (stdio.h core library included in) +// Include Standard Input Output Library #include -// Declare main function for the program. Int for returning a integer +// Declare main function for the program. int type for returning a integer int main() { // Print Hello World! (stdout in CLI) @@ -82,19 +82,27 @@ int main() } ``` -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: +`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 'binary' can be executed with +after which our `hello` binary can be executed with ``` ~/hello-world/hello ``` -All programs give stdout/output string "Hello World!" in our shell environment: +**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/ld-linux-x86-64.so.2, 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 @@ -116,6 +124,8 @@ This could have been very interesting assignment to work out. Unfortunately, my ![winecfg-update](https://i.imgur.com/SihmPUA.jpg) +See: [Fincer/winecfg_patch](https://github.com/Fincer/winecfg_patch) + Some Python and bash based program-related scripts and code updates are available here: - [PlayOnLinux patches](https://github.com/Fincer/linux-patches-and-scripts/tree/master/playonlinux).