Tuesday, 2 December 2014

Raspberry pi - Introduction

Hello once again.

This is the first of series of Raspberry pi related posts. I believe that the Raspberry pi (rpi from now on) can help us learn from basic electronics to coding, presenting alternative solutions to existing or not problems. In this series I will make a step-by-step installation of a simple, descent LAMP (Linux Apache MySql PHP) server.

This is what a rpi looks like, compared to a D, a AAA battery and a SD card.








 Introduction
For those not familiar with the pi, I think it will enough to start with the following bullets:

  • it is a single-board processor
  • it has low cost, (approximately 35$)
  • low performance, ARM6 700Mhz single core processor with 256/512Mb of RAM (type A/B)
  • runs a distribution of GNU/linux based on Debian, called raspbian
  • has some GPIO (General Purpose Input Output) pins, used to connect sensors, devices etc in order to control them, get data or output data to
  • it has a large community for project ideas/solutions
I believe those are enough for now. In a few words the rpi is a small pc that is not meant to be used as a pc (what th.. ??).

If you don`t have one, then I hope after reading this post, you will consider getting your hands on one. 

No arduino
Arduino is a microcontroller, it is not to be confused with the pi. They can work together, but they are not the same. Both projects are very popular, which is the reason why there are clones. In the case of the pi, a popular clone is the banana pi, shown in the pic below, on the right. It is in the same price range, faster (1 GHz dual core ARM7) with more RAM (1 GB), but still ... Not so well supported. More power does not always mean better.



Why bothering?
The best answer is why not? I own mine several months and I have tried a few projects. Through those projects I had to read and learn a few things about electronics (remember that Ohm's law you have learnt in school, that R=I/V?). Moreover I  got my hands dirty with solder, cables, LED's, but I also had to use python, setup an apache web server, remember the mysql syntax and of course so many more. So, yes, I believe I have learnt a thing or two. 

Disclaimer
I am not an expert, so throughout these series I am only putting together pieces I have found online, I have tried and they work. At least in the cases mentioned. Maybe there are better ways (most likely) to get the same result. Maybe mine suck, but at least, so far, I do know that they do not suck hard. If so please make your point in a comment.

Getting started
If you about to order your slice of pi, then keep in mind that you will need:
  • one SD card
  • one USB type A to male micro USB type B (the standard USB cable that comes with a smartphone)
  • one USB charger (5V, 1A)
  • one USB keyboard *
  • one USB mouse * (just to login in the GUI and play around)
  • one HDMI cable *
  • one monitor that supports HDMI *
  • one UTP Ethernet cable
* you will need them only once, to boot the first time, then SSH will be used

If you have put things together, then check again in a few days for the next post. 
C u.

Sunday, 16 March 2014

sendmail app - GUI and CLI versions

Hello there.
I recently needed to automate a process of sending emails from MS windows machine, to lots of recipients in order to help a good friend at his work. Think of it as newsletter emails. This is why I made a small .exe file in VB.net .  I had little experience with VB.net, this is why I started from the .exe file with GUI which was easier from me to visualize and debug. To cut story short. I made it work. However, without CLI how is it possible to automate it? I know there is autoit program, but ... come on. I 'd spent quite some time to make this work. So I made a CLI version too.

The use is simple.
In  the GUI version there are listboxes to add attachments and recipients. Labels are self-explanatory so no need to say much.

The CLI version takes these arguments:
-u=[username]
-p=[password]
-s=[server]
-r=[port]
-b=[subject]
-t=[mail text]
-l=[.txt file path for recipients]
-a=[path of the attachment]
-o=[path of the txt log file to write]
--help for help
e.g. for using gmail
sendmail_cli -u=[yourusername@domain.com] -p=[yourpassword] -s=smtp.gmail.com -r=587 -b=newsletter -t=newsletter -l=[absolute path to the txt file with recipients]t -a=[absolute path to attachment] -o=[absolute path to the txt log file]
The messaging is up to minimum, because I know how to work with it and so does my pal. Recipients are added to bcc. You can use any "antivirus / analyzer / anti-malware / sandbox / virtual machine / local mail server" to make sure there is no malicious code there.

Download the sendmail.exe file here and the CLI version here.

Saturday, 18 January 2014

Simple password generator from terminal

Hello again.

I wanted to get several WPA passwords and test them by trying to hack them for educational purposes.

Since I didn`t want to use an online generator (because when you don`t have a connection they are useless) I though I should have them taken from terminal.

The procedure is simple and it worked. At least for me.

1st open your bash source file
gksudo ~/.bashrc

2nd add this small script

genpasswd() {
    local l=$1
           [ "$l" == "" ] && l=16
          tr -cd 'a-zA-Z0-9\<>!".;:$%&/()=?|@#[]}{'< /dev/urandom | head -c ${l} | xargs
}

3rd save and exit

4th source it
source ~/.bashrc

and that`s it.

try it by typing
genpasswd 10

to get a password with 10 characters

GL and HF

Sunday, 11 March 2012

Conky has been polished and refurbished

Hello again.

Conky is changing. Remember this article? Get ready to see something different. Compare it with this one.
Old one Polished version

I have left out several indicator, but it looks really nice.

Here is how to get it.

If you don't have conly, install it.
$sudo apt-get install conky

Donwload the new source file, as well as the logo.png image the rings from here and extract them in a folder, let;s call it conky2 in your home folder.

First step is to install the new font, called neuropolitical by double clicking in the neuropolitical.tif file in the neuropolitical.zip file and then the install button.

Then copy the clock_rings.lua to ~/.lua/scripts folder. These two folders do not exist so create them.
$sudo mkdir ~/.lua
$sudo mkdir ~/.lua/scripts

and then copy the clock_rings.lua file
$cd ~/
$sudo cp ~/conky2/Ubuntu/clock_rings.lua ~/.lua/scripts

Create a folder to put the logo.png file.
$sudo mkdir ~/.conky
$sudo cp ~/conky2/Ubuntu/logo.png ~/.conky

Inside the same folder put the conyrc file.

Last change the code for your town to show temp for it. Visit http://weather.noaa.gov, find your town and note the code in bold and in parenthesis up right, as shown below (LGLM for my case).


Find the line below in the ~/.conky/conkyrc file

${font Neuropolitical:size=13}${color FFFFFF}${alignr}temp: ${weather http://weather.noaa.gov/pub/data/observations/metar/stations/ LGLM temperature temperature 30} °C${font}

NOTE
The neuropolitical font does not support all UTF-8 characters, so if you use a different language, greek in my case, change the font for those lines in the conkyrc file with arial, to be sure for the result.

Trigger conky by typing
$conky -c ~/.conky/conkyrc

Good luck.


New AMD ATI catalyst drivers. The scenery is changing.

Hi there once more.

It has been a while. Remember the previous post how to install the ATI drivers in Ubuntu? Well you can forget all about that.

It seems that something has changed and all the necessary actions are included in a wizard type installation for the AMDCatalyst 12.2 proprietary display drivers for Linux.

First, go here (AMD support site) to get the drivers for your OS and card.

I can say that you are almost done. You must only make this *.run file executable and then run it.
(I won't open terminal to show howeasy the whole process is)

Enter your password to allow it to run as superuser and a wizard will start as shown below. Choose according to yor case and the rest are being taken care of. A reboot however is necessary.



Has this new policy anything to do with the fact that nvidia has joined The Linux Foundation?

Read more here (endgadget.com)

What do you think?

Friday, 18 November 2011

Install the new ATI drivers in Ubuntu 11.10 (and make them work)

Hi there once more.

Following the previous post about problems with ATI drivers, amdcccle (see it here), I' ve looked it into a little bit more.

I was lucky since guys at osarena.net (they rock), had the solution ready for me.

New ATI catalyst 11.8 to the rescue and a proper easy how-to.

This is basically a re-post of the one found in osarena.net (check it here) from the noobie perspective.

First download the new drivers from here. (I got the 64bit one)

Put the ati-driver-installer-11-11-x86.x86_64.run file in a folder (lets name it ati in the home folder) and make it executable.
$cd ~/ati
$sudo chmod +x ati-driver-installer-11-11-x86.x86_64.run

Then create the necessary packages, based on the 11.10 Ubuntu version 
$sudo ./ati-driver-installer-11-11-x86.x86_64.run --buildpkg Ubuntu/oneiric

Before continuing, it is very likely that you might be missing some packages that are necessary to create the packages and cpontinue with this procedure. I've listed below those that I was missing. I have that covers you. One way or another you' get a message to install missing ones.

$sudo apt-get install build-essential cdbs fakeroot dh-make debhelper debconf libstdc++6 dkms libqtgui4 execstack libelfg0 dh-modaliases

Now open the tty session (Ctrl+Alt+F1) and login with your username and password. This is because we are about to uninstall the currently used drivers and we prefer a Command Line Interface (CLI) instead of a graphical one that is using a lot more of the resources of the card.

List folder ati and see the packages.
$ls
  1. fglrx_8.911-0ubuntu1_amd64.deb
  2. fglrx-amdcccle_8.911-0ubuntu1_amd64.deb
  3. fglrx-dev_8.911-0ubuntu1_amd64.deb

Remove old drivers
$sudo apt-get remove --purge fglrx fglrx_* fglrx-amdcccle* fglrx-dev*
Install the new packages (overwriting -f)
$sudo dpkg --force-overwrite -i *.deb

Create the xorg.conf file
$sudo aticonfig --initial -f

and restart
$reboot

After the reboot, when you log in, you might receive an error message that previous settings could not be restored.

$gksudo amdcccle 
to open the catalyst and set your card again.

You are done.

I've have noticed 2 degrees Celsius down in the adapter temperature from my conky file (see what I mean) and a lot smoother sense of the card.

Thank you again osarena.net guys.

Good luck to you all.

Thursday, 17 November 2011

Ubuntu 11.10 ATI drivers and NTFS mounts problem

Hi there again Ubuntu users.

This will be a small post about a problem I faced when I upgraded to 11.10 and it has to do with ATI drivers and NTFS mounts. I ' ve googled them around and I see that there are quite some people facing similar problems.

(I run the 64-bit version, so I do not know if the same applies for the 32-bit one.)

I use two monitors and when the PC rebooted, after the update, the monitor mode had been switched to mirror monitors. I though OK, no problem. It is something that has happened before in the past and I thought that AMD Catalyst Control Center will give the solution. Unfortunately, even though I was using the AMD Catalyst Control Center (administrative version) it didn't save any changes and simply terminated. Each time.

So I tried to "kill my time" and watch a movie instead. I tried to cut and paste a movie to an external media center. No go. I didn't have write privs in the NTFS external HDD. That was new. It took a while (reading around the community forums etc) and I came to the conclusion that must be a policy problem. This triggered me and I thought that it might also be the solution to the ATI drivers problem.

Enough said (damn it was long)

I am rookie andI didn't want to mess around any /etc/ .... conf files, so i did it manually the "newbie" way. I suggest try it only since it might not be the solution to your problem. I believe the community and Canonical will provide solution to both problem in future updates. Until then we have to be operational at least.

ATI problem solution
Simply download the proprietary drivers form the system settings section and run the AMD Catalyst Control Center (administrative version) from terminal
$gksudo amdcccle

That's all. It will work just fine (use gksudo, not sudo since it is a GUI app).

NTFS mounts problem
The solution is seperated in two parts. Mounting and unmounting.

Mounting
First you will need to know which device to mount. To list the connected HDD devices type
$sudo fdisk -l

It will list several devices and their partitions. The format will like this:


Disk /dev/sda: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders, total 117231408 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00006d97


Device
Boot
Start
End
Blocks
Id
System
/dev/sda1
*
2048
391167
194560
83
Linux
/dev/sda2


393214
117229567
58418177
5
Extended
/dev/sda5


393216
16015359
7811072
83
Linux
/dev/sda6


16017408
113324031
48653312
83
Linux
/dev/sda7


113326080
117229567
1951744
82
Linux swap/SOlaris


/dev/sda is the device
The rest in the table are the partitions.

Type
$sudo mount .... partition to mount it.

Done.

Unmount
You' ll need same privs to unmount the devices mounted before.

First list the mounted devices. Type
$mount | grep /dev/
and the mounted devices will be highlighted. Find the one you want and then
$sudo umount [device]

That's all. 

Maybe fstab can be edited, but I am not in position to recommend it. I hope a near future update will deal with these problems.

Try it and I hope it will help. Additional info about Ubuntu device management can be found here.

Raspberry pi - Introduction

Hello once again. This is the first of series of Raspberry pi related posts. I believe that the Raspberry pi (rpi from now on) can help u...