Basic scripting on linux

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.

Using Python

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:

whereis python
which python

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” 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“:


Using Java

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


I had to compile the file so I did it with “javac“. 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.


Using Bash

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“:


To execute a Bash script you need to use the “sh” command. Here I typed “sh“:


Works great!


Sources: – The course I’m attending – Help with Java – Help with Bash

Leave a Reply

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

You are commenting using your 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