Saturday 31 May 2014

Installing programs on Linux

One of the main problems new Linux users have is installing programs.

In Windows, you can just double-click a .exe or .msi file and an installer will run the work for you. In Macintosh, you can double-click a .dmg file or drop it in the Applications folder (dropping it is actually pretty intuitive, if you think about it).

In Debian and Ubuntu you can click your .deb file too, and use a graphical interface which runs gdebi installer for you. (for instance, installing latexila)



[Side note: when I mention Ubuntu, most of what I say applies to it's derived distributions like Lubuntu or Mint]

However, my preferred way of installing packages is using the terminal. You can either install packages from the repositories or download them and install "manually". I'll cover both ways.

Let's assume you want to install a package and you don't know if it is in the repositories. In a terminal, type:

sudo apt-get update
apt-cache search package_name

If your desired package is available, it'll show as output. Proceed to install it:

sudo apt-get install package-name 

[Side note: Even though this post covers Debian based distributions, CentOS or Fedora have their own repositories and installers. Instead of apt-get (aptitude), they use yum, Arch Linux uses pacman, etc, but the logic is the same.]


If not, that package may be in a personal repository (PPA). You can add that PPA to your list

using:

sudo add-apt-repository ppa:someonesppa

For an example, check this previous post on PulseAudio Equalizer.

After this step you can install it by typing:

sudo apt-get install package-name

Now, let's say the package you want is not in the main repositories and there are no PPA's you can find in which your package is available, but you were able to download a .deb file and you want it to work.

My favourite way to do this is using gdebi in the terminal. Just cd to the folder where your .deb file is and type:

sudo gdebi package_name.deb

Or if your are not inside that folder, give it the path:

sudo gdebi /path/to/file/package_name

and gdebi will do it for you. If your package has dependencies you don't have installed, gdebi will solve them for you.

Another way to install .deb files is by using dpkg (you have to change to the directory where your file is, just like with gdebi):

sudo dpkg -i desired_package_name

However, dpkg will not solve missing dependencies. You might be wondering why you would use it, then. Some packages like libreoffice have to be installed by running the installer for all files inside a folder full of .deb files. dpkg will install all files iteratively (sudo dpkg -i *.deb), whereas gdebi (sudo gdebi *.deb) will try to get dependencies from the repositories instead of keep looking for packages inside that folder, so it'll fail.

[Another side note: *.deb means it'll run through all .deb files inside that folder. If you wanted to install all files whose name starts with banana, you would do banana*]

By now you should be able to install quite a few things. However, let's imagine there are no PPA's nor .deb files for you package, and you only managed to find a .tar.gz (or something similar). Don't worry, there's still hope you can get your beloved package!

It's worth mentioning that you don't install a .tar.gz file. Tarball's (as they're called) are compressed files, like .zip or .rar, but they're commonly used to distribute packages (you can store regular files in them if you want).

First things first, you have to extract what's inside:

tar zfx package_name.tar.gz

but my favourite way is to use unp, which will unpack tarballs, zips, whatever is compressed:

unp package_name.tar.gz

After extraction, what I recommend is to read the REAME or INSTALL file. They contain specific instructions you should follow. I'll give some hints, but when dealing with compressed packages, always try to follow the instructions. If the developer is kind enough, there may be an installer file which you can run (a script that will do the install for you).

If there is no such thing, run the following commands:

./configure
make
sudo make install

And by now you should be able to install software. But remember, ALWAYS read the README help files.

If this tutorial was of any help and you have suggestions to this post or my writting, feel free to comment and I'll try to reply as soon as possible ;)




Wednesday 28 May 2014

Mixed blog

Very quick post with a simple though: after looking at some pretty fascinating blogs dedicated to neuroscience, I'm thinking maybe it should have been a good idea to split the blog instead of running a mixed topic one.

Perils of blogging for the first time. Let's hope this blog doesn't become messy ;)

BTW: The awsome blog I found: Computing for Psychologists

Monday 26 May 2014

PulseAudio Equalizer for Linux

 When using the PC, listening to music became a habit.

PulseAudio Equalizer is an equalizer for Linux with a GUI (Graphical User Interface) with a lot of presets which work pretty well.




In order to install on Debian 7 (where it was tested, will probably work on Ubuntu, Linux Mint and related distros):


Add the repository:

sudo add-apt-repository ppa:nilarimogard/webupd8


This line will add the PPA to your repository list: it tells your software installer where to search for new packages. In this case you add someone's personal repository in order to install what they developed.

Next, update your software installer:

sudo apt-get update

This is an important line. Before installing something via APT, you should update it. If you tried running the next code line without updating, it probably wouldn't find the equalizer because APT wouldn't know it has another repository in it's list to search for software.

Finally, install the equalizer:

sudo apt-get install pulseaudio-equalizer


Final note on update and upgrade:

If you want to upgrade your packages via

sudo apt-get upgrade


You should run

sudo apt-get update

because your packages might have been updated and APT doesn't know about that yet, so it'll not upgrade your packages because their versions match the latest version as read by APT.

Source with detailed information and bug fix here.

Sunday 25 May 2014

Stairway To Heaven - Led Zeppelin

Timeless masterpiece


MRI: a glympse of a fascinating area of research

Some of you may have already been inside an Magnetic Resonance scanner. From the outside it has a pretty simple donut-like shape, like this:

(image from here)

Even though the outside has a fancy minimalist design, the way it works is one of the most sophisticated method's I've ever studied, and I'm far from fully understanding it. Every time I read something on magnetic resonance imaging (MRI), not only I learn something new but also have new questions about it.

Very very very (I really have to emphasize it) briefly, this technique works by placing a human body in a strong magnetic field.
This magnetic field is slightly different from the head to feet, meaning the atoms inside the body will precess (rotate somehow like a spinning top) at different speeds.

Different speeds mean they'll have different resonance frequencies. It is possible to stimulate a number of elements, but because hydrogen is abundant inside the human body and the MR signal is strong, this is the chosen element for stimulation.

When precessing protons are stimulated by radiofrequency pulses, they absorb energy and tend to return to their lowest energy state (oriented along the magnetic field). When releasing energy, protons emit a magnetization signal which can be detected by electromagnetic induction in coils.

After reconstruction from frequency domain, different types of images can be obtained depending on how the protons are stimulated. 
New techniques such as diffusion kurtosis imaging may provide new information relevant to clinicians. Scientists all over the world actively investigate new ways to stimulate protons and have different contrast images, new types of information, etc.

Maybe one day I'll get to work on this. So far I analysed DTI images in order to look for differences between Parkinson's disease and healthy subjects, which was a pretty interesting project and in which I've learnt many things.

Suggested reading (online and free): The Basics of MRI by Joseph P. Hornak.

Wednesday 21 May 2014

One of my favorite songs. Sometimes it takes a lot to start something over (give it a thought)... But it may be worth it ;)

Enjoy the clip, quite funny too!


Tuesday 20 May 2014

Linux: nohup and ampersand (&)


When in a linux shell (Debian, in my case), you may want to run several commands in the same shell, or even close it and keep the programs you called running.

If you want to edit a textfile, lets say, potato.txt, you'll use gedit (or any other text editor):

gedit potato.txt

However you won't be able to write in that terminal until you close gedit. If you want to use your terminal while editing potato.txt, type instead:

gedit potato.txt &

If you suddenly close your terminal, gedit will close and you're likely to lose any data you changed. The nohup command might be the solution:

nohup gedit potato.txt &

Even if you close your terminal, gedit will keep running. If a command or program is frozen, and closing the terminal won't kill it, you might just use pkill to do it:

pkill gedit

However, there are still a lot of things I can't figure out: when I try running matlab with nohup, the splash screen will appear but matlab won't open.

In that case, screen might help you. In a shell, type:

screen

It's possible that the screen page will appear (with version, license, etc), just type ENTER. It may look like nothing changed. Type:

matlab &

Just like you'd do any other time. Matlab will start. In the shell, press CTRL+A and then D (without hitting CTRL) and your shell with dettach from Matlab. Now you can close the shell and Matlab will keep running ;)

I hope this was helpful. For more information check nohup and & and running matlab in the background.



Monday 19 May 2014

JDM symbol: Datsun 510

I decided to start the first topic with something that I really like: cars.

Since I was a child I always grew up wandering around my father's car repair shop. Perhaps that's why I like cars.

Some of them are not that pretty, not that fast or not that classy. However, that does not mean they're not special.

One car I like a lot is the Datsun 510:

(you can find other info on this one here, from where I got the picture)

It is a small salloon car from the late 60's / early 70's, with some quite interesting features such as autolocking differential and independent rear suspensions, which is quite remarkable for a car with over 40 years (even some of modern cars don't have that technology).

On my personal point of view, it is a very preety and exciting car, and it's definitly something I intend to have. I'd like to restore one myself, at my own pace and taste.

Even though I can't afford a car project at a moment (as a university student without income, I have no time nor money), it's something I hope I can do in a few years!