Basic virtual server configuration

This time I’m taking a look at how to use Apache on your own virtual server. I’ve already set up my own virtual server with Digital Ocean, but you can use any other service as well, there are loads of them. Be sure to compare the pricing and reviews when choosing your host!

As per usual I’m using my HP EliteBook 2570p as a local computer and SSH to connect to my virtual server hosted by Digital Ocean. I’m running Xubuntu 16.04.3 locally and Ubuntu 16.04.3 on my virtual server (1GB RAM).

This is an assignment for a Linux server course taught by Tero Karvinen.

Configuring a basic user and home folder access for Apache

Once you’ve setup your virtual server, it’s time to create a basic user. I needed to set up a new user as well as grant access for Apache to the user’s home folder. Thankfully creating new users is easy, just type “sudo adduser username” after you’ve connected to your virtual server. The user is immediately created and you get to choose a password as well as add several other optional pieces of information to your user. ALWAYS CHOOSE A STRONG PASSWORD! The web is full of automated bots trying to access vulnerable servers, so be sure to make it hard for them by securing your server.

1john

If you don’t want to fill in some of the additional information, you can just leave it empty and type enter. After creating your new user, be sure to test that it works. For example, I created a user named “john”, so now I could use the command “ssh john@mydomain” or “ssh john@myIPaddress” to connect.

2john
New user works great!

Now to add access for Apache that’s installed on the server. I’m quoting my previous post on how to do this, be sure to check it out if you want a more in depth look on how to open user directories for Apache!

Next we’ll open up the user directories for Apache so it can scan your home folder and display pages from it. To do this, type “sudo a2enmod userdir” to your terminal. After this we need to restart Apache by typing “sudo systemctl restart apache2.service“.

Now that Apache can access your home folder we should make a web page. You should start by making a new folder inside your home folder. You can do this via the terminal with the command “mkdir public_html” (make directory). If you are not sure how to navigate to the home folder in the terminal, be sure to check my previous post. You can create the folder with the GUI.

After accessing your new folder, create a new HTML file. You can do this with the terminal by typing in “nano index.html“. This will allow you to create a HTML file that will be placed into your working directory. Here’s the basic code for a HTML site:

<!DOCTYPE html>
<html>

<head>

<title>Place the title here!</title>

</head>

<body>

<p>Add text here!</p>

</body>
</html>

 

After you’ve written your page you can close the editor and save by pressing ctrl + x. You should now have a working web page in your public_html folder that the Apache software can access.

Remember to test your site! Here’s what the user folder should look like in a browser when you don’t have a HTML file in it yet:

4john

Changing Apache’s root path

Now that you have permitted access to user directories and made your first web page, you can make the newly created folder under your new user the default path for Apache so that the page in the folder will be displayed at your domain. To change Apache’s default path you need to change a few things. I’ll use my own settings here as an example, you can also check out Janne Varis’s excellent and compact guide. I wanted to create a new folder for my site under the previously created public_html so while logged as my sudo user on my virtual server via SSH I typed “cd /home/john/public_html” and created a new folder with “mkdir oliverlahti.me“, named after my domain.

After you know which folder you want to use, go to the path “cd /etc/apache2/sites-available” and add a new configuration file by typing “sudoedit yourdomain.conf“. Type in the following:

<VirtualHost *:80>
    ServerName http://www.yourdomain
    ServerAlias yourdomain
    DocumentRoot /home/user/public_html/yourdomain
</VirtualHost>
“Yourdomain” is “oliverlahti.me” in my case. DocumentRoot sets the path for Apache. After saving the configuration file (ctrl + X, y, Enter) type in “sudo a2ensite yourdomain.conf” and restart Apache with “sudo service apache2 reload“. Next we’ll need to modify the hosts file in etc, so navigate “cd /etc” and open up hosts with “sudoedit hosts“. Now it’s time to add your virtual server’s IP:
5hosts
After you’ve saved the file check your site. You should now be seeing the index file you’ve set in your path. If the site won’t update, clear your browser history, this should solve the problem.
5johnssite
Obviously working!

Monitoring possible break-in attempts

Now that we an Apache server running on a virtual server machine, it would be interesting to know if we’re attracting any unwanted visitors to our server. This is easy with one command, “sudo tail -f /var/log/auth.log“. This opens up the authentication log which let’s you see all the attempts to connect to your server:

7chinahack

Here you can see a part of my log. There were constant attempts to access my server as a root user from IP addresses unknown to me. I found this quite interesting so I decided to investigate one of these addresses. I decided to use “whois“, which can find out information about IP address registrations. You can install it with “sudo apt-get install whois“. Just type “whois theipaddress“and you’ll get the info. The IP I tried lead to China and returned quite a bit of information, among it a name, e-mail address and phone number. I’m not sure if this is actually valid information or just a diversion but at least it’s interesting.

Public servers are constantly under stress from automated SSH break-in attempts. This is why you should always secure your users with strong (read long and complex) passwords. In addition there are other ways to protect your server. If you haven’t already done so, you should definitely enable the firewall that comes in by default in Ubuntu (it’s called ufw, UncomplicatedFireWall and it’s built on iptables). Make sure to leave port 22 open for SSH before you enable the firewall though, otherwise you might get locked out. You should also lock your root account and make a new user with the same permissions. Most break-in attempts are targeted at the root user so even the worst brute force attack at root won’t leave you open if you’ve disabled the user in question.

All of these important steps are instructed here at my teacher’s site, I really recommend you perform these actions.

Using SCP to transfer files from a local host to a remote one

Next I needed to transfer a web page created on my local computer to my virtual server. There’s an easy method for this and it’s called SCP, standing for Secure Copy. SCP uses SSH to transfer files between two locations. I had written a PHP site on my local machine so I decided to transfer it. To do this, I navigated to the folder holding the file and typed:

sudo scp index.php oliver@oliverlahti.me:/home /oliver

After I gave the command I had to log into my server with the user “oliver” but that’s basically it. SCP in very convenient and secure to use so use it often!

6scp

Adding a PHP site to your virtual server Apache

Finally, I had to enable my virtual server’s Apache to accept PHP files and use one as the default page at my domain. In my previous post I already instructed how to enable PHP usage in Apache so I’ll just post a quote here:

In order to get PHP to work with Apache we need to install a module for Apache. You can use the following command “sudo apt-get install php libapache2-mod-php“. Be sure to restart the server afterwards with “sudo systemctl restart apache2.service”. Now that we’ve installed the module, we still need to enable PHP usage, since it’s disabled by default. To edit the correct configuration file, type the command “sudoedit /etc/apache2/mods-available/php7.0.conf“. You need to add the “#” symbol in front of ALL the bottom lines to make them into comments. This way you can run PHP in user directories a.k.a the home folder. Remember to save the changes to the file with ctrl+x.  Finally, restart Apache again with “sudo systemctl restart apache2.service”.

After you’ve enabled using PHP, you can write some PHP and place it in your Apache’s root path that we set earlier. Here’s an example of my site, it prints the visitor’s IP address (actually quite handy):

<!doctype html>

<html>

<head>

<meta charset =”utf8″>

<title>Check your IP</title>

</head>

<body>

<p>Hi, here you can see your IP address!</p>

<br>

<p>Here’s your IP: </p><?php echo $_SERVER[‘SERVER_ADDR’]?>

</body>

</html>

Feel free to use it. This was in the file I transferred with SCP. I now moved the file with “sudo mv index.php /home/john/public_html/oliverlahti.me” to the folder that was my root path for Apache. I got the results I wanted, Apache now displays this page as default when accessing my domain:

8php
Fantastic!

This was a quick look at some of the things you can configure on your virtual server. I definitely encourage you to explore more, I’m sure I will!

Sources:

http://terokarvinen.com/ – the course I’m attending as well as additional instructions

https://jvaris.wordpress.com/2014/03/03/linux-server-task-5-apache-name-based-virtual-hosting/ – Janne Varis’s site for Apache default path editing

http://www.hypexr.org/linux_scp_help.php – SCP commands

https://wiki.ubuntu.com/UncomplicatedFirewall – Information on ufw

Installing, testing and running Apache

Today I’m taking a quick look at Apache, the world’s most popular server software. As usual I’m running Xubuntu 16.04.3 on an HP EliteBook 2570p. This post is an assignment for a course I’m attending, taught by Tero Karvinen.

Installing Apache

In order to get started with Apache we need to install it. If you’re not sure if you already have Apache installed and running, you can type “localhost” or 127.0.0.1 to your browser. If you’re not directed to the Apache default page, you know you don’t have Apache running.

1oletussivu

To install Apache, open up the terminal emulator and type in the command “sudo apt-get update” and afterwards “sudo apt-get install apache2“. When prompted for a permission to use storage space type yes or just y.

After the installation is complete, you can try typing the formerly mentioned addresses to your browser (“localhost” or 127.0.0.1). You should now see the default page!

Next we’ll open up the user directories for Apache so it can scan your home folder and display pages from it. To do this, type “sudo a2enmod userdir” to your terminal. After this we need to restart Apache by typing “sudo systemctl restart apache2.service“.

Now that Apache can access your home folder we should make a web page. You should start by making a new folder inside your home folder. You can do this via the terminal with the command “mkdir public_html” (make directory). If you are not sure how to navigate to the home folder in the terminal, be sure to check my previous post. You can create the folder with the GUI.

After accessing your new folder, create a new HTML file. You can do this with the terminal by typing in “nano index.html“. This will allow you to create a HTML file that will be placed into your working directory. Here’s the basic code for a HTML site:

<!DOCTYPE html>
<html>

<head>

<title>Place the title here!</title>

</head>

<body>

<p>Add text here!</p>

</body>
</html>

 

After you’ve written your page you can close the editor and save by pressing ctrl + x. You should now have a working webpage in your public_html folder that the Apache software can access. To test it out, you can try typing “localhost/~username” into your web browser. You should be seeing your new site:

2testisivu

You can even access this new site from a different computer in your local area network! Just type in your IP address (you can find this by typing “ip addr” into the terminal) and add the same path /~username to the end.

3puhelin
I tried this on my phone, worked great, typos and everything!

Monitoring the Apache access log

To access Apache’s access log, you should head to the log folder. By default it’s /var/log/apache2/. By typing the command “sudo tail -f /var/log/apache2/access.log” you can open the access log and monitor it in real-time. Now it’s time to make some entries:

4200

An example of a successful action, the web page gets served correctly to the client. Here’s the full entry:

My IP address – – [07/Feb/2018:01:25:37 +0200] “GET /~oliver/ HTTP/1.1” 200 478 “-” “Mozilla/5.0 (Linux; Android 7.0; SM-G955F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Safari/537.36”

My IP address – This displays the client’s IP address (I’m accessing the server from my phone)

[07/Feb/2018:01:25:37 +0200] – Date and timezone, both correct

“GET /~oliver/ HTTP/1.1” – States the used method, requested resource and the used protocol

200 478 – 200 is the status code for a successful transaction and 478 stands for the size of the sent resource

“Mozilla/5.0 (Linux; Android 7.0; SM-G955F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Safari/537.36” – Information about the client browser and device build

And here’s the example of a failed action in which the client has tried to access an unknown location:

5404

Here’s the full entry:

My IP address – – [07/Feb/2018:01:27:36 +0200] “GET /~olive HTTP/1.1” 404 500 “-” “Mozilla/5.0 (Linux; Android 7.0; SM-G955F Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.137 Mobile Safari/537.36”

These lines are almost the same as before, except for the status code 404, which stands for “resource not found”. I tried to access the nonexistent resource “olive” instead of “oliver”, which resulted in the error.

 

Causing an error with PHP

In order to get PHP to work with Apache we need to install a module for Apache. You can use the following command “sudo apt-get install php libapache2-mod-php“. Be sure to restart the server afterwards with “sudo systemctl restart apache2.service”. Now that we’ve installed the module, we still need to enable PHP usage, since it’s disabled by default. To edit the correct configuration file, type the command “sudoedit /etc/apache2/mods-available/php7.0.conf“. You need to add the “#” symbol in front of ALL the bottom lines to make them into comments. This way you can run PHP in user directories a.k.a the home folder. Remember to save the changes to the file with ctrl+x.  Finally, restart Apache again with “sudo systemctl restart apache2.service”.

I decided to edit my previously created HTML file by adding a line of PHP. You can do this via the GUI or the terminal by navigating to your public_html folder and typing “nano index.html“. Here’s an example code:

<!doctype html>
<html> 
<head> 
         <meta charset =”utf8″> 
         <title>My site</title> 
</head> 
<body> 
         <p>Hi, this is a test for my Linux assignment!</p> 
         <p>Let’s see if the PHP line works. What is 3+3?</p> 
         <p>Answer: </p>
         <?php print(3+3)?> 
</body>
</html>

After you’re done editing, be sure to rename the file as “index.php“. I tried the page on my phone, works perfect!

6php

Now to cause an error. I modified the PHP line by removing the last question mark. This is what followed:

7phperror

The page isn’t loading at all! Now we can check Apache’s error log. To access it, we can type “sudo tail /var/log/apache2/error.log” This is the error entry I received:

[Wed Feb 07 03:45:11.735912 2018] [:error] [pid 17160] [client My IP-address:56816] PHP Parse error: syntax error, unexpected ‘<‘ in /home/oliver/public_html/index.php on line 11

Here we can see that the problem is caused by the syntax error we placed in the file.

Causing an error entry to an Apache configuration file

Here my goal was to cause an error to Apache’s process by altering a configuration file. I decided to see all the possible files by typing in “cd /etc/apache2” and “ls“. I wanted to modify “apache2.conf” since it sounded important. I wasn’t exactly sure how to cause an error so I went with the easy way; I removed everything!

8conf
Picture of the default “apache2.conf” file

After deleting everything I saved the file and restarted the Apache process. That’s when I got this:

9conf

As you can see, Apache wouldn’t start correctly. This was because “The apache2 configtest failed”. I also tried to access my web site but of course I was rejected.

So, don’t empty your configuration files, unless you want screw up your settings. Glad I took backups!

Various HTTP status codes

During this assignment I encountered various different HTTP status codes:

200 – Successful action. This occurred every time I successfully loaded a web page.

403 – Forbidden action. I got this one when I tried to access my home folder via Apache without the user directory module.

404 – Not found. Got this when I tried to access a nonexistent location.

Sources:

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

https://en.wikipedia.org/wiki/Apache_HTTP_Server – General info on Apache

https://httpstatuses.com/ – Info on HTTP status codes

https://httpd.apache.org/docs/2.4/logs.html – For Apache log interpretation

(Xubuntu) Using the terminal emulator

This is a more linear post where I explain how to use the terminal emulator on Xubuntu and a bit about SSH. I’m attending a course taught by Tero Karvinen and these actions are part of an assignment. The computer I’m using is an HP EliteBook 2570p and the OS version is Xubuntu 16.04.3.

Logging actions and monitoring

My first task was to create two entries to the system authentication log. In order to get access to the log, you first need navigate to the “root” folder. Root is, as the name implies,  the first folder in which every other folder is included in. From the root folder, you can navigate to any other folder. Start by opening up the terminal with “Windows” + “t“.

terminaali

The first thing we need to is to find out where we are. To do this, you can type in “pwd” (print working directory), and the terminal will tell you your directory location. By default, you should be in your users home folder.

terminal_pwd

Now that we are aware of our surroundings, it’s time to navigate to the root folder. Navigation in the terminal happens by typing in the command “cd” (change directory). For instance, if you wanted to access a subfolder, you could type “cd foldername/”. If you want to access an upper folder, you can type “cd ..“, which will take you to the upper folder from your current one. Because we know that the root folder is the highest folder in the tree, we could just type “cd ..” in multiple times. Here I chose to use the command “cd /” which takes you to the root folder every time.

terminaali_root

You can use pwd to make sure you’re in the root folder. If you see the “/” symbol, you’re in the correct one.

Now that we are in the highest folder, the only way is down. To see what folders and files the root folder has, use the “ls” (list) command.

terminaalils

Here we can see the folders included in root. I already know that the log file I need is in the directory var/log, so I need to navigate there. Here I can use the command “cd /var/log” to gain access. To see that the correct file is there, I’ll use ls to see the files in the folder.

varlog

Auth.log is there so now I only need to open it. I want to monitor the log file in real-time, so I’ll use the “tail -f auth.log” command to open it. This way I can see the changes happening to the log as I post commands to the terminal.

log1

Here we can see that the auth.log is open. Now we can test if we can see the changes happening to it in real-time.

To test this out, I opened up another terminal window and typed “sudo apt-get update“. When the terminal asked for my password I deliberately gave it a false one. Here you can see how the log file reacted:

Jan 31 01:38:28 Mysterymachine sudo: pam_unix(sudo:auth): authentication failure; logname=oliver uid=1000 euid=0 tty=/dev/pts/6 ruser=oliver rhost=  user=oliver

log2

After I gave the terminal the correct password, the entry to the log was different:

Jan 31 01:39:10 Mysterymachine sudo:   oliver : TTY=pts/6 ; PWD=/home/oliver ; USER=root ; COMMAND=/usr/bin/apt-get update

Jan 31 01:39:10 Mysterymachine sudo: pam_unix(sudo:session): session opened for user root by oliver(uid=0)

Jan 31 01:39:22 Mysterymachine sudo: pam_unix(sudo:session): session closed for user root

log3

Let’s analyze these lines.

Wrong password:

Jan 31 01:38:28 – a timestamp declaring the logging time.

Mysterymachine – PC name.

sudo: pam_unix(sudo:auth): authentication failurepam is a password authentication module. Here we can see that the user has tried to gain sudo access and that the password has been declined resulting in an authentication failure.

logname=oliver – States the active username.

uid=1000 euid=0 user id and effective user id. Not sure about their difference

tty=/dev/pts/6 – States the terminal in use.

ruser=oliver rhost=  user=oliver – State the user, not sure about the difference.

Correct password:

Mysterymachine sudo:   oliver – States which user gets sudo access.

PWD=/home/oliver – Shows the folder in which the command is executed.

COMMAND=/usr/bin/apt-get update – States the executed command.

 

SSH server installation and testing

We installed an SSH server in class with the command “sudo apt-get openssh-server” and I wanted to try it out a bit. If you want to install the server also, use the command above. After installation you can connect to it by typing “ssh username@localhost“. With the command “passwd” you can set a password, be sure to do so. You can always check the status of your SSH server by typing “sudo service ssh status“.

sshstatus

Now that I have my SSH server up and running, it’s time to try a command. I decided to use “scp” (stands for secure copy). Basically, scp copies files over a secure, encrypted network connection. I wanted to transfer a PNG file named “gimp” I had in my home folder to my desktop. To do this, I typed in “scp gimp.png oliver@localhost:~/Desktop” and the file was successfully transferred to my desktop. As you can see, scp is quite simple to use!

scp

The perfect apt-get command

Here I needed to define the “apt-get command of my dreams”. Essentially I needed to name my favorite programs that I couldn’t live without. So here are the pieces of software I’d always prefer to install:

VLC – A flexible video player

HTOP – A graphical resource monitor

Chromium – A web browser similar to Google’s Chrome

GIMP – A free and comprehensive graphics editor

Thunderbird – Mozilla’s open-source email client

Start with “sudo apt-get update” to update your package lists. Remember that you can string these programs together and install them all in one command:

sudo apt-get install vlc htop chromium-browser gimp thunderbird

Terminal programs

Lastly I needed to install three programs that can be run on the terminal emulator. I chose the following:

hTop – for resource monitoring

ifTop – for network speed monitoring

sudoku – for fun!

I installed all of these in one command “sudo apt-get htop iftop sudoku“.

hTop is a program for monitoring your hardware resources in real-time. It’s very convenient and easy to comprehend.

htop

ifTop is for network speed monitoring. Because it needs special privileges you need to run it with sudo.

iftop

Sudoku is a fully functional game that runs in terminal emulator. Quick and easy to jump into!

sudoku

Sources

http://terokarvinen.com/2017/aikataulu-%E2%80%93-linux-palvelimet-ict4tn021-7-ti-ja-6-to-alkukevat-2018-5-op Course site

http://terokarvinen.com/2009/command-line-basics-4 Basic Linux commands

http://terokarvinen.com/2008/commands-for-admin-4 Linux commands for admins

https://www.lifewire.com/what-is-a-root-folder-or-root-directory-2625989 Definition on root folder

http://ubuntuhandbook.org/index.php/2016/04/enable-ssh-ubuntu-16-04-lts/ Instructions for SSH installation

https://www.computerhope.com/unix/scp.htm Instructions on scp

https://linux.die.net/man/8/pam_unix Information about pam

https://unix.stackexchange.com/questions/191940/difference-between-owner-root-and-ruid-euid RUID and EUID difference

Getting started with Linux

Okay, so right now I’m attending a course where we get acquainted with Linux, in relation to servers to be specific. As an assignment, my job is to learn to use the Xubuntu distribution. For the next few weeks I’ll be posting tutorials concerning Xubuntu and other related stuff. Let’s get started!

Choosing a Linux distribution

So you want to start using Linux but are not sure where to start? That’s okay, the whole “cult of Linux” can be a bit overwhelming to comprehend, especially if you’re moving on from Windows, the mainstream operating system. Chances are that you got sick of Windows for some reason and are now looking for an alternative OS. Or maybe you’re just curious about the software behind so many projects, such as Android. In any case, you’ve made the right choice, and even if you won’t become a full-on guru with Linux, it’s always nice to know the basics. Besides, using Linux is a great way to learn more about computers, so if computer science is your thing you’re in for a treat!

To start using Linux, you must first choose a distribution, or a “distro“. Linux comes packaged in all shapes and forms so it’s essential that you pick the correct distribution suitable for your own purposes! Some of the most popular distros are Debian, Ubuntu, CentOS, Fedora and Linux Mint. Different distros are more suitable to different uses, but if you’re just getting started and want to learn the basics I can recommend Ubuntu (or Xubuntu, which is what I’ll be using here. The real difference is only that Xubuntu uses the more lightweight Xfce desktop environment to boost performance instead of the default Unity found in Ubuntu).

Once you’ve chosen your distro, it’s time to start the preparations.

(Optional) Backing up your data

This is a non-mandatory step, but if you’re going to install your Linux distro on a hard drive, you might want to take backups of your data, since reclaiming it can be near impossible if it gets overwritten. There are several ways to make backups of your most precious files. Using a simple USB stick or a cloud service such as Dropbox can be quick and handy if you only want to backup text or photographs (keep those private photos away from the cloud!). For larger files like videos, photo albums or even games and other programs I would recommend an external hard drive or a cloning dock.

External hard drives are rather cheap these days and easy to use, just connect them via USB to your PC and you can transfer everything you want. BUT, if you have access to your hard drive and can remove it from your desktop or laptop, then I would suggest using a cloning dock such as Fuj:techs Clone Dock 2. It’s only 30€ here in Finland and you can use it turn a regular hard drive into an external one. Because of its adaptability and ease of use, I’d say that 30€ isn’t a bad price for something so useful. And as a long-term solution you will save money this way, since external hard drives tend to be a bit pricier than “regular” ones, so you won’t have to buy externals in the future.

dock

No matter which method you think best, you should always take backups just in case, unless you’re absolutely certain that there’s nothing you might need in danger of being overwritten.

Installation methods/How to make a bootable USB livestick

Now that you’ve chosen the distro you want it’s time to choose your installation method. As with any other operating system, you can install Linux in various ways. However, I would recommend creating a USB stick with an image of your chosen distro for easy and convenient installations. A CD disc would also work but since optical drives are a slowly disappearing piece of hardware, it’s safer (and just faster) to use a memory stick.

In order to create a bootable USB stick you need three things; a USB memory stick (4GB in size should suffice pretty much always), an ISO image of your chosen distro and a program to burn the image to the stick. You can use programs like UNetbootin, Rufus or Win32DiskImager, I’ll use UNetbootin in this tutorial. You should be able to download the distro ISO file from your chosen distros home site. Distros often offer different ways to download your file, for instance, via FTP or a torrent client. If peer-to-peer isn’t your kinda thing, I recommend FTP, as it is typically easier, if not the fastest way. The ISO file size is typically somewhere around one to four gigabytes, so the download might take a few minutes or an hour, depending on your network speed.

Näyttökuva (6)
Xubuntu has a plain and clear download page that offers several different links.

After you’ve downloaded the ISO file and have a program that can burn it as an image to a flash drive, you’re ready to start. Make sure your USB flash drive is connected and doesn’t have any important files on it, everything will be overwritten. It’s always best to use a completely empty drive just in case.

1

2

Here you can see UNetbootin ready for action. Pay attention that you’ve chosen the correct method (“Levykuva” in this picture), the correct ISO file and the correct destination, in this case a USB drive, drive E. After selecting “OK” UNetbootin should burn the image to your flash drive. This might take a while but no longer than 10 minutes. Congratulations, you now have bootable Linux drive!

Installing Linux

You should now have a completed installation method and so you are ready to start with the installation. In order for you to use the USB drive as the boot drive, you need to access your computers boot menu. You can look for your computers boot menu key here: https://www.desertcrystal.com/bootkeys. The most typical keys are ESC, F2, F9 and F12 but this varies on different computers. If you are having trouble entering your boot menu, you might want to check out your BIOS settings and make sure that the boot menu isn’t locked. BIOS can also typically be accessed with the formerly mentioned keys, most often with ESC.

1

The above is an example of what you should be seeing. Here you can see that the USB flash drive is being recognized as a boot drive and is available for selection. Navigate to your USB drive with the arrow keys and select it with ENTER. This is what you should be getting if you used UNetbootin and Xubuntu:

2.jpg

Here you have several options on how to utilize your boot drive. You can for instance start installing the OS to a local hard drive instantly or run the OS straight from your USB drive. In order to see that everything works alright, I suggest running the OS from the USB drive first by selecting “Try Xubuntu without installing”.

3.jpg

Once the OS boots up you should arrive to the desktop. Congratulations, you are now running a Linux based operating system! Here we can use the OS just as it would be if we installed it, but in order to gain access to every single function and to fully utilize our hardware we need to install the OS on a local hard drive. Before you choose the “Install” shortcut on the desktop make sure you have a hard drive on your desktop or laptop that you’re willing to overwrite! If you have multiple drives on your computer, you can choose the correct one from the installation wizard.

NOTE! If you’re using something else than a standard US keyboard, for example one with a Nordic layout, remember to change your keyboard settings. You can do this by accessing the terminal (Windows + T or click the button in the upper-left corner -> select terminal) and by typing in the command “setxkbmap #” (replace “#” with language, for instance “fi” for finnish).

4_

5

The following installation will be performed using the Xubuntu installation wizard but other distros should come with a similar one. Once you start the installation process you must first choose your OS language. Pick the one you wish and continue on.

6

In the next step you can connect your computer to a wireless network if you have a WI-FI enabled computer. By connecting online you can speed up the installation a bit, since the installation wizard will automatically detect your timezone. You can also instantly download some updates and some useful third-party software. A wired connection will also work.

7

If you chose to connect online, you can now update and install some extra utilities and drivers. I recommend you do both.

8

Now we come to an important step. Here you can select your installation settings, and most importantly, choose to encrypt your installation drive. Encryption is extremely important to protect your data effectively so be sure to select this option. The other settings are up to you but if you’re not sure what to do but are certain that you don’t have anything of importance on your chosen hard drive, you can choose to erase everything and keep other settings on default.

9

If (hopefully) you chose to encrypt your drive, you will now set a password for your encryption. Be sure to make this a long sentence with lower-case AND capital letters AND numbers AND special characters. WRITE THIS PASSWORD DOWN SOMEWHERE SAFE, IT CANNOT BE RESTORED! You can also choose to overwrite empty space, which I recommend as well.

10

Next you will choose your timezone and the correct keyboard layout.

The last step will have you create a profile for your new installation. You can use your own name for example and name your computer. Always secure your profile behind a password and use a long sentence with lower-case AND capital letters AND numbers AND special characters. If you chose not to encrypt your hard drive earlier, be sure to encrypt your home folder!

13

Your installation will start in the next phase. This will take a moment so don’t worry if it isn’t over in a second. My installation took about five minutes with a normal 5400rpm hard drive.

Once the installation finishes you are greeted by a completion message. Here you can choose to restart your computer and start running the OS from your hard drive. All done!

14

Once you’ve restarted your PC, you can finally remove your USB drive, you won’t need it anymore to run your OS.

Using Xubuntu, the first steps, basic commands

As Xubuntu starts you get to sign in for the first time. Use the password that you set up during the installation process.

15

You should arrive to the desktop. You can now use your new operating system in any way you wish but there are a few things I can hint for you to do. First, let’s start by checking out the hardware. Open up the terminal and type the command “sudo lshw -short -sanitize“. This lists your hardware. Notice how you need to enter your password. This happens because you’re running the command as a “superuser” with the “sudo” command. On default, once you enter your password you won’t have to enter it again for the next five minutes, even if you run another sudo command.

laitteisto

Here you can see I’m using an HP EliteBook 2570p. It has 8GB of DDR3 RAM and runs on an Intel i5-3360M at 2.8GHz. An older laptop, yes, but it runs Xubuntu beyond smooth!

Let’s move on. Installing software on Linux is much easier than on Windows for example. All you need to do is to type a short command in the terminal. Before we can start with installing we need to update our package list from where the OS knows to retrieve packages. Use the command “sudo apt-get update“. After this you’re ready to start installing away!

To install something in Linux, you can use the terminal and type “sudo apt-get install programname“. So for instance you could install the graphics editor program GIMP by typing “sudo apt-get install gimp“. You can even string program names together to simultaneously install multiple programs (for example “sudo apt-get install gimp vlc apache2“)!

install

To run a program all you need to do is type the name to the terminal, “gimp” for instance. It really is this easy. Instead of downloading an installation wizard for a program and running it, you can just give simple commands via the terminal which makes everything so much simpler and faster!

Linux is all about open-source software. This means that as a platform, the OS is much less commercial than say for example Windows or OSX. This also means that larger or smaller corporations might not be willing to provide their software for Linux users since there might be less money to make among the Linux community. No worries though, even though Linux might not have the support of every IT company out there, it has a very active and vocal community, always willing to further develop the platform and software available.

I’m going to list some alternatives here for programs that you (and I) might be using daily and can’t live without. The best thing about these is that they’re all free!

Microsoft Office – Libre Office (For writing, calculations and spreadsheet, presentations etc.)

Adobe Photoshop – GIMP (Graphics editor)

Outlook – Thunderbird (Email client)

Winrar – Karchiver (File compressing)

CCleaner – BleachBit (System cleanup)

TeamViewer – AnyDesk (Remote control)

There are tons of useful programs for Linux, often even more useful than the ones they are based on. And I’m not saying that all Linux programs are just compatible clones, I’m just pointing out that there are capable alternatives available to those old favorites, even if the original software wouldn’t be available.

Additional – On software licenses

As I mentioned before, Linux is all about open-source. The combining factor among different Linux distros is the open-source Linux kernel on which all distros are based on. Many distros also share the same pre-packaged open-source programs that often use GNU GPL, General Public License. GNU GPL is a widely used free software license that allows the user of the software to run, study, share and modify the software. In short, GNU GPL is a copyleft license that obligates you to pass on the license unviolated with the source code. This is done to make sure that the community benefits from the use of its resources.

thunderbirdvlcgimp

I started using Xubuntu by installing programs like GIMP and VLC that both use the GNU GPL. These programs are great examples of what community-based development can accomplish! I also installed Thunderbird, the email client software developed by Mozilla. Thunderbird uses three different licenses, GPL, LGPL (helps with combining licenses in relation to GPL) and MPL, Mozilla Public License. MPL resembles GPL by obligating keeping of the original license when redistributing software. To quote mozilla.org: “The MPL fills a useful space in the spectrum of free and open source software licenses, sitting between the Apache license, which does not require modifications to be shared, and the GNU family of licenses, which requires modifications to be shared under a much broader set of circumstances than the MPL.

 

I hope this short tutorial helped you with your new Linux OS and most of all I hope you will find the time and passion to study the OS on your own!

 

Sources:

http://terokarvinen.com/ (my professors site)

https://lahdemi.wordpress.com/ (for alternative program recommendations)

https://en.wikipedia.org/wiki/Linux_distribution#Package_management

http://wiki.linuxquestions.org/wiki/Linux_software_equivalent_to_Windows_software

https://en.wikipedia.org/wiki/GNU_General_Public_License

https://en.wikipedia.org/wiki/Linux_kernel

https://www.videolan.org/legal.html

https://www.gimp.org/about/COPYING

https://www.mozilla.org/en-US/about/legal/eula/thunderbird-2/

https://www.mozilla.org/en-US/MPL/2.0/FAQ/

Building a robot arm – Days 3 and 4, finished prototype

Alright, so the robot arm that me and Mark Laatikainen were building is finally finished. After a lot of… adjusting, we managed to finish the prototype successfully. There were some changes to the initial plan, so here’s a summary of our progress.

 

To control the arm we had planned to use potentiometers because of their simplicity and accuracy. However, we were presented with the possibility to use a Nunchuk (the Wii remote that is), so we just had to take the chance.

Nunchuks are fitted with an accelerometer that can measure motion and tilting. We decided to connect the Nunchuk to the two main servos that do the heavy lifting. So now when you tilt the controller horizontally or vertically the arm responds. One of the biggest problems we encountered with the accelerometer were the uneven values it provided. We had to implement a sliding average into the code and some if/else- conditions to filter out the erroneous values. The arm is still a bit “jittery” because of the faulty values but it’s manageable.

20170601_140524.jpg
A close-up of the “Wiichuck” component used to connect the Nunchuk

We use four servos in the arm and we couldn’t connect them all to the accelerometer. So we allocated the analog stick to the third servo and the fourth servo, that controls the “claw”, to the trigger button “Z”. The controls work fairly well with this configuration.

Here are some pictures of the final setup:

20170601_153543
The finished arm – Not pretty but quite functional

I had a lot of fun with this project and I’m glad I got to work on it with Mark, who’s a very capable programmer and very competent with electronics. Mark uploaded the code for the arm on his GitHub-page. Here is a list of the parts we used:

2 x Tower Pro 9g micro servos

2 x Tower pro MG995 servos

Arduino Uno

Prototype shield for the Arduino

Wii Nunchuk

Keyes Wiichuck

Breadboard

4 x Metallic shelf holders

Flexible plastic

Dental floss for the claw (yes…)

∞ jumper wires

Remember to also check out this course taught by Tero Karvinen: http://terokarvinen.com/2017/prototyypin-rakentaminen-bus4tn007-8-w22

-Oliver Lahti

Building a robot arm – Days 1 and 2

I’m attending a second course based on Arduino development. The objective is to build a prototype in five days. This time I’ve partnered up with Mark Laatikainen and together we’re building a controllable robot arm.

Robotarm
An early sketch – Professional, as always

We decided to use Tower Pro micro servos and potentiometers to control the servos. At first, joysticks seemed like the best choice, but we switched to potentiometers because of their simplicity.

Here are some pictures of the early build and a quick video:

 

Stay tuned for the finished prototype. In the meanwhile, you can check out the course taught by Tero Karvinen over here: http://terokarvinen.com/2017/prototyypin-rakentaminen-bus4tn007-8-w22

-Oliver Lahti

Finished product

So we managed to finish our IoT-device, the weather lamp. Because we didn’t have a shade for the lamp we wrapped it up in toilet paper and put it in a plastic bag. Very professional.

Nonetheless the device works. It checks the temperature in Helsinki and changes its color depending on the results. We tested it with other cities too and it worked well.

20170323_13551220170323_150148

 

 

 

 

 

Here are the components we used:

1x Arduino Uno R3

1x Breadboard

1x Keyes RGB LED

4x jumper cables

1x 180Ω resistor

The course was organized by Tero Karvinen and you can check it out here: http://terokarvinen.com/2016/internet-of-things-tyopaja-ict8tn017-1-intensiiviviikon-w12

I made the lamp with Tomi Laakkonen

You can also get all the necessary code for the lamp here: https://www.dropbox.com/sh/brjyysyuql0nkle/AABdnxMuwTYVhMZ4_WId5QXda?dl=0

If you want to learn more about Arduino, you can also check out the book written by Tero over here: http://botbook.com/

-Oliver Lahti