Tuesday, 1 October 2013

Quick tutorial - Shell script

This tutorial shows the very basics of how to make your own commands for Terminal, in other words shell scripts.

First we are going to create a simple nano file which is going to be the base for your script. This single file will contain all the information for your command.

 nano tellmesomething.sh  /notice that .sh is not required but it clarifies things. Also remember to consider that some of the command names may already have taken.

In this case I will make a script that shows date and configuration of the computer. Write date and ifconfig and save the file.

This is not over yet though! You can't run your command without doing some actions first.

 chmod +x  tellmesomething.sh  gives the needed rights for all the users to execute this command. 

 sudo cp tellmesomething.sh /usr/local/bin  copies your script into this location so you are able to run it.

Now you are able to run your very own script and it should look like this:

Now you know how to create a basic shell script. Here is some command you may find useful when you continue further with scripting.

 #!/bin/bash  a comment you need to put into a nano file while you are using python.
 nano .bashrc  with this command you are able to edit the script that will be executed always when the terminal is opened. For example you can add the command date to this file and every time you open the terminal the dated is showed.
 ./tellmesomething.sh  will run your script in the current location.

Thursday, 26 September 2013

Installation and management of SSH

SSH server is a software that allows you to manage computers from distance. Today I will install it and show you how to create a new account with a webpage.

Installing SSH

I started installing SSH with the command sudo apt-get install openssh-server (Like everytime it is still important update your package list before installation (sudo apt-get update).)

After this I tested my server and logged in with my own account. Since I am using the live Cd I need to create a password first or I am not able to continue very far (can be done with passwd). If you are not sure about your username you can simply check it by running the command whoami.

I logged in as xubuntu ssh xubuntu@localhost. The connection had been created and so far everything seemed to be fine. Time to create a new account!

Creating an account

sudo adduser [username] is the needed command when creating a new account. In my case I created a test user called maryrascal, so I typed sudo adduser maryrascal in my Terminal.

At this point we can add some additional information about the user (you should at least write the full name). Remember to choose your password carefully - it should contain both lower and upper case letters, special characters and numbers. In ideal case the password doesn't resemble of a real word and is fairly long, more than 8 characters.

When creating a webpage for a new user you must have Apache installed on your computer (more information from my previous post). 

I made sure I was logged in as maryrascal and created a directory mkdir public_html and put there a file nano index.html for the webpage. If everything goes as it should the site will appear to localhost/~maryrascal. 

Finally I checked that the access rights of these files really belong to maryrascal and not to root by writing ls -l.

Analyzing the AuthLog

The AuthLog is located in cd /var/log and can be read with tail auth.log and it contains all the user logins.

Logging in SSH successfully

On September 26nd at 15:14:34 o'clock (GTM+0) in xubuntu's server the accepted password was entered and the session opened for user maryrascal.

Logging in SSH failed

On September 26nd at 15:12:25 o'clock (GTM+0) in xubuntu's server a wrong password was entered totally 3 times.

Using sudo succesfully

On September 26nd at 15:18:16 o'clock (GTM+0) xubuntu used a sudo command in directory /home/xubuntu as root user with a command sudo apt-get update.

Using sudo failed

On September 26nd at 15:20:59 o'clock (GTM+0) maryrascal (who is NOT a sudoer) tried to run a sudo command in /home/maryrascal with sudo apt-get install tetris but this command couldn't be executed because there wasn't such a file or directory existing and the session was closed. 

System information - OS: Windows 8 64bit Manufacturer: Dell Inc.Model: Inspiron 3721 BIOS: A05 Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz Memory: 8192MB RAM

Based on Linux course by Tero Karvine (http://terokarvinen.com/)

Monday, 23 September 2013

Installing LAMP

LAMP = Linux, Apache, MySQL, PHP

1. Installing Linux 

More detailed information from my previous post.

  • Before starting the installation of a new OS make sure you have all the important files from your computer in a safe place (just in case something goes wrong). I used Buffalo's external hard drive (250 Gt).
  • I started by downloading Xubuntu 13.04 (64 bit version) torrent file and used UNetboot to create a bootable memory stick.
  • When the Live USB was done I restarted my computer, pressed F12 during the start-up and navigated myself to Boot manager where I chose to try Xubuntu without installing.
  • I opened the internet browser and made a Google search to lightly test my new OS.  

2. Installing Apache

More detailed information from my previous post.

  • Before installing anything it is important to update in order to get all the newest versions of packages. Do this with the command sudo apt-get update in Terminal.
  • After this start the installation of Apache2 by writing sudo apt-get install apache2.
  • I changed the location folder to user's directory with sudo a2enmod userdir and restarted Apache.
  • When testing functionality you should be able to open "It works!" -page by writing your computer's IP address (or simply localhost) to the address bar.
  • I created a new directory public_html (mkdir public_html) and added there a file called foo (nano foo). The operation was successful since my file appeared in localhost/~xubuntu

3. Installing PHP

  • To start the installation of PHP module use the command sudo apt-get install libapache2-mod-php5
  • Notice that after the installation the PHP module is not working by oneself yet. When visiting /etc/apache2 and using the command grep -ir php we can easily see what lines in which file we have to comment to get the module working. 
Grep-command prints all the wanted elements. In this case we are searching for PHP.

  • Go to the folder /etc/apache2/mods-enabled and start editing the file "php5.conf" with the command sudoedit php5.conf
  • Comment the needed lines with # and save the modified file. 
The modified php5.conf file.
  • Now the module should run fine so let's test it by creating a PHP file to user directory's public_html.
  • As we can see the PHP file is working fine and the code prints the number 4 to my webpage as it should. 
  • But what to do if there is something wrong with the code and the browser only shows you a blank page?
    • Go to the error log /var/log/apache2 and tail error.log
  • Thanks to the error log it is easy to figure out where the problem is. Here we can see that on Sunday 22nd 12:23:25 (GMT+0) year 2013 the error occurred because there was unexpected mark ":" in the file /home/xubuntu/public_html/foo.php on line 2. 

4. Installing MySQL

  • Run the command sudo apt-get install mysql-server. After a moment you are asked to define the root user's password.
  • When the installation of MySQL is done we are able to connect it with phpMyAdmin (sudo apt-get install phpmyadmin.)
  • The next part is really important and without doing it right you are not able to connect phpMyAdmin. Select apache2 with a star (use space key) and continue.
  • Now the installation screen will tell you that you must have a database installed and configured in order to use phpMyAdmin. Since I already did this I select "Yes".
  • Now you will be asked to give the same password you configured for the root user and a new password you never need to use so the wise thing is to leave this space empty and let the computer generate it for you.
  • The installation is done and if everything went as planned phpMyAdmin should be found from localhost/phpmyadmin (once again, put this address to your browser's address bar). You can log in by using the username root and the password you selected before.

I wanted to play a little bit with my shiny new phpMyadmin and created a new database called "Hunting dogs" and inserted there information and values to test it.

Linux version: Xubuntu 12.04, 64-bit

System information - OS: Windows 8 64bit Manufacturer: Dell Inc.Model: Inspiron 3721 BIOS: A05 Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz Memory: 8192MB RAM

Based on Linux course by Tero Karvinen (http://terokarvinen.com/)

Thursday, 19 September 2013

Installation and management of Apache

First things first - before starting the operation it is necessary to update in order to get the latest versions of packages. Use the command  sudo apt-get update 
After this you can now install Apache2. Write  sudo apt-get install apache2  on to your terminal, except installation terms with Y and enter and you are ready to go.

 sudo a2enmod userdir  basically changes the location folder to user's directory, making it easier to control while all your important files stay in a one and same place. Now Terminal will ask you to restart the server and make sure you will execute it properly. 

Go to your home direction (e.g. /home/xubuntu/ Remember! if you are not sure about your identity you can always ask it by writing  whoami ).

Create a new folder  mkdir public_html  and enter. In my case I wanted to make a test file to see if my server is working. 

After saving I navigated myself into the front page. You can use your PC's IP address ( can be found with ifconfig ) and write it to a browser's URL bar (or simply type localhost).

Success! My test file appeared to localhost/~xubuntu/test so it's time to write a real HTML5-page. If you wan't your webpage to open straight in localhost/xubuntu the file name has to be index.html 

<!doctype html> Tells that this document's type is html.
<html></html> The root of html document. All your codes go inside these tags.
<head></head> Contains the information of the document (e.g. <title></title>)
<body></body> Document's body.

The final look of my webpage with the false link.

Reading the errors and user actions

Installing Apache2 didn't go as smoothly as you might think by reading this document. My first error came from very beginning after changing the directory of Apache. This is the part when I am asked to run the restart of the server (service apache2 restart).

Visiting the log doesn't really give any clues but observing the execution command enlighten my thoughts - 87: ulimit: error setting limit (operation not permitted) tells that I don't have enough authenticity to run this command. The error fixed simply by adding sudo in front of the line (sudo service apache2 restart).

 © http://xkcd.com/
Thankfully the second error was premeditated. It appeared when the user tried to get free candy from my "false link page".

Here we can see that the user visited the webpage exactly 19/Sep/2013:15:28~ and tried to click the false link to /localhost/~xubuntu/freecandy but the session ended to error 404, meaning the page wasn't found.

Linux version: Xubuntu 12.04, 64-bit

System information - OS: Windows 8 64bit Manufacturer: Dell Inc.Model: Inspiron 3721 BIOS: A05 Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz Memory: 8192MB RAM

Based on Linux course by Tero Karvinen (http://terokarvinen.com/)

Monday, 16 September 2013

Searching and installing softwares with Linux Terminal

Before starting to search the softwares you are interested in it is necessary to update the package lists by using the following command:

  • sudo apt-get update

This is how you will get all the newest versions of all the available packages.
In my experiment I searched for softwares with the keywords that met my interests and I didn't have any further experience.

1. Gjiten 

Since I'm learning Japanese language I wanted to find an application that could support my studies. I found from its looks stripped yet comprehensive software called GJiten.
Searching and installing the softwares are done with the commands;

  • apt-cache search your keywords (Mine were Japan Kanji)
  • sudo apt-get install your software (e.g. Gjiten)

After running the install command Linux Terminal will make sure that this is the software you really want to get by telling how much additional disk space the program will take. You can continue installing and press "Y" or cancel the operation with "n".

Gjiten is a extensive Japanese dictionary but its lack of romaji characters makes it hard for a beginner so be sure your hiraganas and katakanas before installing this program.
Gjiten also includes a wide kanji dictionary that doesn't only show the character but all the radicals, readings and stroke numbers of it. やった! (Yatta! = Hurray!)

2. Mahjongg

I am a game addict. I am a Mahjongg addict. Is there anything else to say? I could spend a lifetime with staring at these beautiful digital pieces. I think it's not a surprise I used the keyword "Mahjongg" to find these games.

3. digiKam

Retouching images is something that is part of my daily life so I wanted to find something new related to it. I typed my keywords (photo editing) and selected a random program digiKam that turned out to be a real surprise! DigiKam includes all the necessary tools for a basic photo retouch and beyond and I actually found it easy to use. I would say it is a great free version of PhotoShop and I will definitely keep using it in the future.

System information - OS: Windows 8 64bit Manufacturer: Dell Inc.Model: Inspiron 3721 BIOS: A05 Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz Memory: 8192MB RAM

Based on Linux course by Tero Karvinen (http://terokarvinen.com/)

Monday, 9 September 2013

Exploring Linux Terminal and Command-Line Tools

Even though I have used terminal based command-line tools before I have never had to go really deep into the program, so I would say this is totally a new thing for me and I feel excited!

Testing some of the Command-Line Tools

1. Zip and Unzip

At first I started by creating a new folder "Testikansio" and added there three files (Tiedosto1, Tiedosto2, Tiedosto3). These are the files I want to put in a one single zip file and I can do it with the following command:

zip Pakattu Tiedosto1 Tiedosto2 Tiedosto3

It tells the computer to create a zip file called "Pakattu" and copies the wanted files inside that new file. 
At this point I tested the unzip command unzip Pakattu.zip after deleting the original files. If there would be identically named files in the same folder Terminal would ask if the user wants to delete, rename or cancel the process. 

2. Seq

Seq is a mathematical tool that allows you to determine the wanted numbers inside a restricted area.
For example- the basic command seq 2 gives me all the numbers ending to 2 (1 and 2). 
There are also many ways to define the terms for the desired outcome.

seq -w --separator="||" 2 19 300
Prints all the numbers beginning from 2, spaced with 19, ending to 300. 

seq -f "%06g" 101 108
Prints all the numbers from 101 to 108 with additional zeros so the total length of each number is 6 units.

3. ImageMagick - Convert

Because I am a visual person and interested in photography I wanted to give a try to ImageMagick's Convert tool.

The command convert -resize 70% kukka.jpg kukka.gif creates a new picture from the file called kukka.jpg. The new file "kukka.gif" is 30% smaller than the original picture and also gets the new image format "gif".

Compering the converted file to the original.

I ended my experiment by adding the copyright information to my picture with following definitions;

convert kukka.gif -gravity southeast -stroke '#000C' -strokewidth 2 \ 
-annotate 0 '(c) Carola W' -stroke none -fill white \ 
-annotate 0 ' (c) Carola W' kukka.gif


Based on Linux course by Tero Karvinen (http://terokarvinen.com/)

Monday, 2 September 2013

Comparing softwares by using Windows and Linux

This time the homework assignment was all about softwares. The task was to compare the softwares we are personally using at the present time to ones we can find for free on Linux. I picked my 3 softwares pretty quickly and started the mission.

1. ITunes and Clementine Music Player

I really like ITunes and it is the "must" software for listening to music for me. The layout is clear and easy on the eyes.
I like the fact ITunes basically does everything for me - from searching the album cover to naming and categorizing the songs I just uploaded. What could be easier!

Click to enlarge image

ITunes also has a wide selection of radio channels. You can just pick the genre and get the list of the channels playing your favorite music. Personally I use ITunes just for this purpose and I often catch myself listening to Kicking country and KAWAii Radio.

ITunes and the wide collection of radio channels.

With Linux I wanted to give a try to Clementine Music Player. I would say it is the stripped version of ITunes. Don't get me wrong because this software really has potential and everything with it works just fine.

Unlike ITunes Clementine doesn't recognize the songs from your CD so you have to add the information manually.
The list of radio channels is also wide but a little bit harder to use compared to ITunes (then again it might be just my inexperience with the software). For example I had difficult of searching for the channels that play my kind of music.

  • ITunes and Clementine are both free to download.
  • They are both handy
  • Clementine is simpler looking but not simpler to use.
  • ITunes recognizes your songs and categorize them - Clementine doesn't.
  • The wanted radio channel is easier to find on ITunes.

2. Photoshop and Raw Therapee

In my opinion it is really unfair to compare PhotoShop with any software but since this comparison is only based on light photo retouching I can carry it out without feeling guilty.
I love to photograph so I use PhotoShop daily. I know it fairly well and I have no attentions of changing it to any other software. I still don't see why I couldn't do some basic editing with some other program in the case of an emergence.

For this experiment I chose one picture from my albums and gave it a little retouch with both PhotoShop (by using windows 8) and Raw Therapee (by using Xubuntu).

I started with PhotoShop by swinging the image to more horizontal position (edit > transform > free transform) and by adding a little bit more brightness and contrast from adjustment label. After that I used Clone brush to remove the trash from dog's ear and finally cropped and re-sized the image.

Back in Xubuntu's side I decided to use a software called Raw Therapee and do the same editing as I did in PhotoShop. At first everything seemed going well. Rotating the image to the right position was really easy to do and actually worked a bit faster than in PhotoShop. The editing is easy but it does not meet my personal quality standards.

Cropping the image is easy but I don't understand why the software leaves weird black zone around the selected area and doesn't delete it. Another frustrating fact is that there isn't a tool to remove the trash from your image. Well... at least adding more contrast and brightness works fine but overall Raw Therapee is way too plain software.

  • PhotoShop is professional yet expensive software while Raw Therapee is free to download.
  • Raw Therapee is fairly ok for simple editing but it misses too many actions.

3. Illustrator and Inkscape

Not only I use Adobe Illustrator to make vector graphics but also for quick sketching. I used Trust's Slimline Widescreen Tablet (16529) to perform this test between Illustrator (tested with Windows 8) and Inkscape (tested with Xubuntu).

Adobe Illustrator
I started the sketching by setting the brush as pressure sensitive. This allows to create more vibrant drawings while the brush strokes are not just one plain line (you must have a drawing tablet to do this).
After playing around with the brush settings I finally chose thick calligraphic brush and started sketching.
I finishes my work in 5 minutes and went back to Linux to find similar software and came across with Inkscape.

I have used Adobe's softwares for years I have to say Inkscape is truly competitive with Illustrator. Even though I will have to go even deeper with this software to compare them equally.
With Inkscape I didn't have to set my brush to pressure sensitive because the software did it for me automatically. All I had to do was to adjust the calligraphic brush they way I wanted and start drawing. I used 5 minutes to complete this sketch, just like I did in Illustrator. Inkscape really gave me a big surprise and I will definitely keep on studying it more!

The left sketch made with Illustator and the right sketch with Inkscape.

  • Inkscape is free to download and as good for sketching as Illustrator.
  • Inkscape is easy to use and pen pressure sensitivity works as charm.
  • Both Inkscape and Ilustrator has a wide selection to create the brush you need.

System information - OS: Windows 8 64bit Manufacturer: Dell Inc.Model: Inspiron 3721 BIOS: A05 Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz Memory: 8192MB RAM

Pictures, drawings and text: Carola Wennermark.

Based on Linux course by Tero Karvinen (http://terokarvinen.com/)

Thursday, 29 August 2013

Getting known with Linux

I think it's only natural that our first homework assignment in Linux course was to burn the disk image of Xubuntu on CD (or on memory stick) and test it. This is how it went for me.

Step 1 - The backup

Before starting the operation I want to make sure that if everything else goes wrong atleast I have my important files still left. I used my old but trusty Buffalo's external hard drive (250 Gt).

Step 2 - Downloading the operating system

I got my Xubuntu 13.04 torrent file simply from http://xubuntu.org/. I chose the 64 bit version and opened it in BitTorrent (http://www.bittorrent.com/) where I could start the download.

BitTorrent - Download done!

Step 3 - "Burning" the disk image

Since I didn't have empty 800mb cd's that the operation system needed I decided to use a memory stick.This method takes a little bit longer but it's definetly not hard.
First I needed to make my USB memory stick bootable so I downloaded a software called UNetboot.
This software is designed to create bootable USB drives for Linux distributions without burning a CD and it actually already gives me some options of the these distributions (for example Salix, Puppy Linux, Ubuntu...).  I wanted to use my already downloaded ISO file so I selected it from my own computer files.

After the installation UNetboot recommends me to restart the computer so I can test my new operation system.

Step 4 - Testing Xubuntu

While restarting my computer I pressed ESC key untill I saw the computer giving me option entering to the BIOS by pressing F2. I managed to get myself into the Boot Manager.

From there I navigated to my memory stick (EFI USB1 PATH1 (Generic Flash Disk)) and chose to "try Xubuntu without installing" (I also had an option to install Xubuntu on my computer immediately).

After 2 minutes I was already in and could start testing my new Xubuntu. First I opened the internet browser and made a small google search about cute dogs. I was also wondering around in this new invironment and really tried to get used to it. Everything seemed to go very well and so far without problems (this can't be a good sign, right? ;)). This whole process took about 1 hour and 35 minutes.

System information
OS: Windows 8 64bit
Manufacturer: Dell Inc.
Model: Inspiron 3721
Processor: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz (4 CPUs), ~~1,8GHz
Memory: 8192MB RAM

http://xubuntu.org/, http://www.bittorrent.com/, http://unetbootin.sourceforge.net/, http://www.dell.com/

Pictures and text: Carola Wennermark.

Based on Linux course by Tero Karvinen (http://terokarvinen.com/)