How to set PcManFm as the default file manager in Ubuntu 14.04

After struggling with this Nautilus’ slowness for a while, I decided to change my default as well. The simple solution that works for me in all cases without mucking with changing desktop files was to do the following two commands:

sudo mv /usr/bin/nautilus /usr/bin/nautilus.bak
sudo ln -s /usr/bin/pcmanfm /usr/bin/nautilus

You can of course replace /usr/bin/pcmanfm with /usr/bin/thunar, or whatever.

If you also want to have a desktop, open /etc/xdg/autostart/nautilus-autostart.desktop and make the Exec line

Exec=nautilus --desktop

Installing teamviewer on 64-bit Ubuntu 13.10, 14.04 and 16.04

Edited: 10/12/16 Installation instructions for 16.04 added

Edited: 12/5/15 Installation instructions for 14.04 added

64-bit Ubuntu 16.04:

As first, remove the actually broken Teamviewer installation in a terminal () by:

apt-get purge teamviewer

If this does not want to work you can as well do this with dpkg:

dpkg -r --force teamviewer

After that make sure you delete any leftovers from your user directory, i.e. ~/.local/share/teamviewer11, ~/.config/temaviewer and /etc/teamviewer:

rm -r ~/.local/share/teamviewer11
rm -r ~/.config/teamviewer
sudo rm -r /etc/teamviewer

Now that this is out of the way, you do an update and an upgrade:

sudo apt-get update
sudo apt-get dist-upgrade

Then install the following packages:

sudo apt-get install libjpeg62:i386 libxinerama1:i386 libxrandr2:i386 libxtst6:i386 ca-certificates

Now download the Teamviewer package from their website (download-link) and install it:

cd ~/Downloads
sudo dpkg -i teamviewer_11.0.57095_i386.deb

After that it should run start normaly. If you not see teamviewer yet in the dash search check /usr/share/applications directory if the shortcut teamviewer-teamviewer11.desktop exists. If not create one by

sudoedit teamviewer-teamviewer11.desktop

And pasting (ctrl+shift+v) the following in:

[Desktop Entry]
Name=TeamViewer 11
Comment=TeamViewer Remote Control Application

It should show up in dash at least after a reboot. Meanwhile you can firstly start your new installed Teamviewer vie the terminal by:

teamviewer &

Now you can lock it at least already onto your launcher if you wish to do so.

64-bit Ubuntu 14.04 Multiarch:

  1. According to TeamViewer’s web site: “On newer 64-bit DEB-systems with Multiarch-support (Debian 7) teamviewer_linux_x64.deb cannot be installed because the package ia32-libs is not available anymore on these systems. In this case you can use ‘teamviewer_10.0.41499_i386.deb‘ instead.”
  2.  Before installing the app, we need to apply the following commands to avoid “wrong architecture i386” error:
    1. sudo dpkg --add-architecture i386
    2. sudo apt-get update
  3. Now from terminal we ca run teamviewer by applying the ‘teamviewer’ command.

64-bit Ubuntu 13.10:

While trying to install Teamviewer 9 on 64-bit Ubuntu 13.10, you’ll get a dependencies error such as this:

Unpacking teamviewer (from teamviewer_linux_x64.deb) ...
dpkg: dependency problems prevent configuration of teamviewer:
 teamviewer depends on lib32asound2; however:
  Package lib32asound2 is not installed.
 teamviewer depends on lib32z1; however:
  Package lib32z1 is not installed.
 teamviewer depends on ia32-libs; however:
  Package ia32-libs is not installed.

dpkg: error processing teamviewer (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:

The problem is that the teamviewer_linux_x64.deb has dependencies problems. It isn’t recommended for distributions using multiarch (Ubuntu 12.04 and later). For said distributions the teamviewer_linux.deb package should be used.

This is noted in the help page of Teamviewer:

Notes to Multiarch:

On newer 64-bit DEB-systems with Multiarch-support (Debian 7)
teamviewer_linux_x64.deb cannot be installed because the package
ia32-libs is not available anymore on these systems.
In this case you can use teamviewer_linux.deb instead.

So, here’s how to install it:

1. Download it


2. Install gdebi (GDebi can install local .deb packages with automatic dependency resolution (it automatically downloads and installs the required packages).):

sudo apt-get install gdebi

3. In the same directory you download the .deb file just run:

sudo gdebi teamviewer_linux.deb

f.lux and redshift: Solutions for computer induced eye strain and sleep disorder

Night-time exposure to blue light keeps people up late. Experimental research suggests that an average person reading on a tablet for a couple hours before bed may find that their sleep is delayed by about an hour. In 2012, the American Medical Association’s Council on Science and Public Health made this recommendation:

Recognizes that exposure to excessive light at night, including extended use of various electronic media, can disrupt sleep or exacerbate sleep disorders, especially in children and adolescents. This effect can be minimized by using dim red lighting in the nighttime bedroom environment.


f.lux adjusts colors in a way that greatly reduces the stimulating effects of blue light at night. f.lux changes the color temperature of your display. Natural light is more blue, while most artificial light (including candlelight) is warmer. Incandescent bulbs, which we’re all used to, become more red in tone when you dim them. But newer LEDs and CFLs don’t – this includes the backlight on your monitor.

The term color temperature is a way to numerically describe how much red or blue light is illuminating a room. Color temperature is measured in Kelvins, and is determined by the kind of light you’re using. Confusingly, warmer (more red) light sources are described in lower degrees Kelvin. Compared to indoor lighting, daylight is cool – very blue. A candle is around 1800K, while a sunny day might be 6000K. An overcast day is more blue, so it might be around 7000K. Most computer monitors display around 6500K. If you are using incandescent task lights behind your computer, those are around 3000K.

During the daylight hours, f.lux keeps your monitor relatively cool with a default color temperature of 6500K. Your brain tends to associate blue light with daylight. At night, f.lux dials down the color temperature to a warmer, more yellow glow (3400K). You can also choose from presets:
Ember: 1200K
Candle: 1900K
Warm Incandescent: 2300K
Incandescent: 2700K
Halogen: 3400K
Fluorescent: 4200K
Daylight: 5500K
or adjust the settings to another specific preference. In general, the yellower the light, the less straining it is on your eyes. f.lux support kelvin color between 2000-10000K.

The best way to set f.lux is to adjust it in the environment you usually work in during the day and night. First, bring up a blank white text screen and adjust the color temperature of your display by trying to match the color of a white wall in the room. Once they match in both lighting environments, you’re on your way to much happier eyes.

Installing f.lux on Ubuntu 13.10

sudo add-apt-repository ppa:kilian/f.lux
sudo apt-get update
sudo apt-get install fluxgui

How to use

Find latitude and longitude of your location using

xflux -l <latitude> -g <longitude> -k <color temparatature in Kelvin, default 3400>


$ xflux -l 23.70 -g 90.40
Welcome to xflux (f.lux for X)
This will only work if you're running X on console.

Your location (lat, long) is 23.7, 90.4

Your night-time color temperature is 3400
It's night time. Your screen is changing now.
Going to background: 'kill 24712' to turn off.

Turn off f.lux

$sudo killall xflux


You can also check out Redshift which is an open source application that does the same thing, its development was inspired by f.lux. As of Jan 4, 2014 the current version is 1.8.

Installing redshift 1.8 on ubuntu 13.10:

1. Download and extract redshift 1.8 in desired folder.

sudo make install

3. Create redshift.conf in ~/.config folder, example is given here, also providing my one below:

; Global settings for redshift
; Set the day and night screen temperatures

; Enable/Disable a smooth transition between day and night
; 0 will cause a direct change from day to night screen temperature. 
; 1 will gradually increase or decrease the screen temperature

; Set the screen brightness. Default is 1.0
; It is also possible to use different settings for day and night since version 1.8.
; Set the screen gamma (for all colors, or each color channel individually)

; Set the location-provider: 'geoclue', 'gnome-clock', 'manual'
; type 'redshift -l list' to see possible values
; The location provider settings are in a different section.

; Set the adjustment-method: 'randr', 'vidmode'
; type 'redshift -m list' to see all possible values
; 'randr' is the preferred method, 'vidmode' is an older API
; but works in some cases when 'randr' does not.
; The adjustment method settings are in a different section.

; Configuration of the location-provider:
; type 'redshift -l PROVIDER:help' to see the settings
; ex: 'redshift -l manual:help'

; Configuration of the adjustment-method
; type 'redshift -m METHOD:help' to see the settings
; ex: 'redshift -m randr:help'
; In this example, vidmode is configured to adjust screen 1. 
; Note that the numbering starts from 0, so this is actually the second screen.

4. run redshift

$/usr/local/bin/redshift &

Some awesome linux command line tricks on bash

1. Runing the last command as Root

 sudo !! 

(!! repeats the last command)

2. Run your previous command with replacing “foo” with “bar”



$ ehco foo bar baz
bash: ehco: command not found
$ ^ehco^echo
foo bar baz

Or alternatively you can use the below command:


3. the command-line equivalent of the back button

cd -

(It’s worth mentioning that ‘cd’ takes you to your home directory)

4. Insert arguments from you last bash command

ESC + ‘.’

Inserts the last arguments from your last bash command. It comes in handy more than you think.

cp file /to/some/long/path

cd ESC + '.'

5. bulk rename


$ ls

$ rename 's/text_to_find/been_renamed/' *.txt
$ ls

6. Renaming/moving files with suffixes quickly:

cp /home/foo/realllylongname.cpp{,-old}

This expands to:

cp /home/foo/realllylongname.cpp /home/foo/realllylongname.cpp-old

7. List only subdirectories in the current one

 ls -d */

8. Reverse search

^R reverse search. Hit ^R, type a fragment of a previous command you want to match, and hit ^R until you find the one you want. Then you don’t have to remember recently used commands that are still in history.

9. Selected bash keyboard shortcuts

Ctrl-U – Cuts everything to the left
Ctrl-W – Cuts the word to the left
Ctrl-Y – Pastes what’s in the buffer
Ctrl-A – Go to beginning of line
Ctrl-E – Go to end of line

10. Running a second command with the same arguments as the previous command

use ‘!*’ to repeat all arguments or ‘!:2’ to use the second argument. ‘!$’ uses the final argument.

$ cd /home/user/foo

cd: /home/user/foo: No such file or directory

$ mkdir !*

mkdir /home/user/foo

11. Get an ordered list of subdirectory sizes

This piece of code lists the size of every file and subdirectory of the current directory, much like du -sch ./* except the output is sorted by size, with larger files and directories at the end of the list. Useful to find where all that space goes.

du -sk ./* | sort -n | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'

12. Use ALT+. to insert last parameter

In bash (or anything using libreadline, such as mysql) press ALT+. to insert the last used parameter from the previous line.


$ vim some/file.c
$ svn commit ALT+.


1. top 25 commands
2. all-time greats
3. public snipts

Ubuntu tip: Getting information about your installed packages

1. Show the List of Installed Packages on Ubuntu :
The command we need to use is dpkg –get-selections, which will give us a list of all the currently installed packages.

    $ dpkg --get-selections
    adduser                                         install
    alsa-base                                       install
    alsa-utils                                      install
    apache2                                         install
    apache2-mpm-prefork                             install
    apache2-utils                                   install
    apache2.2-common                                install
    apt                                             install
    apt-utils                                       install

You can filter through grep to get results for the exact package you need. For instance, I wanted to see which php packages I had already installed through apt-get:

    dpkg --get-selections | grep php

    libapache2-mod-php5                             install
    php-db                                          install
    php-pear                                        install
    php-sqlite3                                     install
    php5                                            install
    php5-cli                                        install
    php5-common                                     install
    php5-gd                                         install
    php5-memcache                                   install
    php5-mysql                                      install
    php5-sqlite                                     install
    php5-sqlite3                                    install
    php5-xsl                                        install

2. How do I get a list of installed files from a package

To see all the files the package put onto your system, do this:

dpkg-query -L <package_name>


dpkg -L php5-gd

3. Get a list of installed Python modules



in a Python shell/prompt.

4. Find all packages installed with easy_install/pip

pip freeze

will output a list of installed packages and their versions. It also allows you to write those packages to a file that can later be used to set up a new environment.

How to fix Unity/Compiz freeze on Ubuntu 12.04 LTS

Sometimes while running Unity + compiz in precise (12.04), display manager hangs so that the mouse moves, but the keyboard allows to get to tty1. The recovery process is:

1. Ctl + Alt + F1 to get to tty1, then
2. Use “top” to check the compiz cpu use and get its pid, then sudo kill -9 , then
3. Perform “sudo service lightdm restart”, then
4. login to X-window environment

(Note that, if one doesn’t kill compiz, a new one will be loaded by lightdm, leaving the orphan compiz to use an entire cpu. And if you hit the problem and don’t kill the new compiz, you now have two cpus locked up.)

Configuration for Connecting to MSSQL Server 2008 on Virtualbox GuestOS from Ubuntu 12.04 HostOS using PyODBC 3.0.8

1. VirtualBox Configuration

– Adding a host-only network adapter
If you don’t have a host-only adapter setup then goto topmost menu:
File->Preferences->Network->Host-only network->Add ‘vboxnet0’ by clicking on the ‘+’ sign at
the right-hand corner. Go to edit and take note of the IP address assigned (lets assume its, so that is the virtual network adapter that has been created at host OS)
Now go to:
Settings->Network->Adapter 2 Tab (considering you’ve NAT set on Adapter 1 for internet) ->Attach to host-only adapter> Name select ‘vboxnet0’
[Note, if you already have a network adapter with NAT selected for accessing internet from
guest os, leave it and just add another one.]
-Add GuestOS to the network
Go to Stat->Settings->Network Connections->Select ‘Local Area Connection 2’ (‘Local Area Connection 1’ should be allocated to NAT Adapter 1 , which is used for Internet)
Right click to get properties ->Internet Protocol (TCP/IP)->Use the following IP address->Assign an IP in the same network as host-only adapter (In this example, that can be

2. MSSQL Server 2008 R2 Configuration (GuestOS)

– Enable TCP/IP and Piping

Open SQL Server Configuration Manager (SSCM) go to ‘SQL Server Network Configuration’->Double Click on ‘TCP/IP’->Select Protocol Tab -> Select Enabled as ‘yes’
Goto IP Address Tab -> Change IP1 (or anyother) IP address to ‘’ (In same network as the host OS ip)->Select Active to yes, Enabled to yes
Now go back to main menu, change ‘Named Pipes’ to ‘Enabled’

– Set SQL Server Authentication

If you’re using ‘Windows Authentication’ to login to your Database. You have to change it to ‘SQL Server Authentication’ and set username and password for it , so that it can be accessed using PyODBC.

To change security authentication mode

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

To enable the sa login, (‘sa’ will be your username)

In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
On the General page, you might have to create and confirm a password for the login.
On the Status page, in the Login section, click Enabled, and then click OK.

3. Disble Windows Firewall serivce
Simply turning off the firewall won’t do, you’ve to stop the service, do:
Run->Services.msc->Windows Firewall->Stop

4. Test connection
Using telnet:
From hostOS ( do: telnet 1433
You can also use a DB client such as, dbeaver.

5. PyODBC configurations

– freetds.conf

# local sql server
    host =
    port = 1433  
    tds version = 7.0

– odbcinst.ini

Driver = /usr/lib/i386-linux-gnu/odbc/
Description = ODBC connection via FreeTDS
Server =
Port = 1433 
Database = Test
TDS_Version = 8.0

– code

import pyodbc

dsn = 'sqlserverdatasource1'
user = 'sa'
password = '******'
database = 'TestDB' 

con_string = 'DSN=%s;UID=%s;PWD=%s;DATABASE=%s;' % (dsn, user, password, database)
cnxn = pyodbc.connect(con_string)
cursor = cnxn.cursor()
print cursor

Increase your VirtualBox Hard Disk Size

Steps to Increase your VirtualBox Hard Disk Size

cd into the directory where your virtual drive is found (usually ~/VirtualBox VMs/{Your VirtualBox PC name})

    cd ~/VirtualBox VMs/WinXP_SP3

run the modify hd function with the new size (in MB) I choose 25GB (25 * 1024mb = 25600MB)

    VBoxManage modifyhd WinXP_SP3.vdi --resize 25600

VirtualBox will resize your hard drive and you will see the following output from the system indicating that the process is complete


Now start up your Virtual Windows Machine. Right Click on ‘My Computer’ (‘Computer’ in newer versions) and choose Manage.

Click on the Disk Management option on the left panel. You will notice some black space next to your C drive (this means the space addition was successful.)

Right Click on the C drive and choose Extend Volume. Follow the wizard and you have successfully increased the size of your VirtualBox disk. Or, if that option is not available use a third party partition making software like Partition Magic or create a second primary partition.

Ubuntu tip: How to safely kill hanged processes.

List the process using ps and find desired application, e.g. idle

naved@neo:~$ ps aux|grep idle
naved     7884  0.5  0.2  33556 15316 pts/3    Tl   20:56   0:30 /usr/bin/python /usr/bin/idle -e
naved     7929  0.6  0.2  34156 16000 pts/3    Tl   21:06   0:30 /usr/bin/python /usr/bin/idle -e
naved     7933  0.5  0.2  33416 15280 pts/3    Tl   21:08   0:24 /usr/bin/python /usr/bin/idle -e
naved     7998  0.3  0.2  33408 15308 pts/3    Tl   21:45   0:08 /usr/bin/python /usr/bin/idle -e /home/naved/Coding/
naved     8243  0.0  0.0   4384   832 pts/4    S+   22:27   0:00 grep --color=auto idle

Use kill -9 to force kill the process

naved@neo:~$ kill -9 7884

To kill all proceses of an specific application, e.g. idle:

killall -9 idle