This time I’m taking a look at how to run some basic hello world scripts on linux. I’ll showcase Python, Java and Bash. I’m using my HP EliteBook 2570p as a local computer and I’m running Xubuntu 16.04.3. This is an assignment for a Linux server course taught by Tero Karvinen.
Python is a rather simple language of which I had some previous knowledge of, so I decided to test it out first. Python comes pre-installed on Ubuntu so it comes with Xubuntu as well. To see if you have Python on your computer, you can use the following commands:
These show you the program folder. If you don’t have it yet, you can install it with “sudo apt-get install python3“.
To write a Python script, you can use nano. I used the command “nano hei.py” to create the script. Inside I wrote a simple print command:
To execute the script in terminal type in “python3 filename“. I used the command “python3 hei.py“:
My second language was Java. I decided to make a short script that prints out “Hello World”. I started by installing JDK (Java Development Kit): “sudo apt-get install default-jdk“.
Then I created a Java file with nano: “nano hei.java”
I had to compile the file so I did it with “javac hei.java“. There was no visual feedback, which typically means that everything went according to plan. After this I executed the file with “java hei” (notice without the .java) and it worked fine! Although the terminal continues operating on the same line for an unknown reason.
My final language was Bash. The environment comes pre-installed on Ubuntu, but I could’ve installed it as well with “sudo apt-get install bash“. I created a Bash script with “nano hei.sh“:
To execute a Bash script you need to use the “sh” command. Here I typed “sh hei.sh“:
http://terokarvinen.com/2017/aikataulu-%E2%80%93-linux-palvelimet-ict4tn021-7-ti-ja-6-to-alkukevat-2018-5-op – The course I’m attending