Debian/Ubuntu Remote desktop – TightVNC & LXDE

So you want the most (could be wrong 😀 ) lightweight X remote system for your Debian – Ubuntu server.
Read on for Light desktop installation on Debian and remote control with TightVnc.

Installation
Update and upgrade the system
[email protected]:~# apt-get update
[email protected]:~# apt-get upgrade

Install X, LXDE  and VNC
[email protected]:~# apt-get install xorg lxde-core tightvncserver

It will probably install some 200mb worth of packages on your hard drive, but nowadays that’s hardly a problem with Terra sized drives.
So answer yes when asked 🙂

Initialize the tightvnc server to create a new config file
[email protected]:~# tightvncserver :1

You are then prompted for a new password in order to access your remote desktop.
Repeat your password and and don’t worry when (and if) you see a :
–Warning: password truncated to the length of 8–
VNC like servers truncate the hardcore password you supply it with to the first 8 characters you enter
VNC uses a DES-encrypted challenge-response scheme, where the password is limited by 8 characters!

Answer no when prompted for a view only password, unless you want such an option

Kill the VNC
[email protected]:~# tightvncserver -kill :1

# Edit config file to start session with LXDE:
[email protected]:~# vi ~/.vnc/xstartup

# Add this at the bottom of the file:
lxterminal &
/usr/bin/lxsession -s LXDE &

# Restart VNC
[email protected]:~# tightvncserver :1

Install chromium if you don’t already have it
[email protected]:~# apt-get install chromium-browser

Your browser is now ready!

Security
Take good note that the following command
[email protected]:~# tightvncserver :1
Does actually allow the VNC daemon to listen to port 5901.
All traffic is unencrypted, except for the session password, which is a no – no (unless its the laptop on your basement with no outside access.

So in order to run securelly we shall employ the old faithful shh tunnelling

Start the VNC with listening only to localhost connections (eg. from the server inside only)
[email protected]:~# tightvncserver -localhost :1

On your local machine open a tunnel while forwarding the port 5901 port at the same time
[email protected]:~# ssh -f -N -L 5901:localhost:5901 [email protected]

Now on your local VNC client you invoke the connection to your newly created remote desktop, supply the password and Voilla you are in 😀
[email protected]:5901

NOTES
Have a pick on your system default “apps”
[email protected]:~# update-alternatives --get-selections

NOT ADVISED
if you want to run root (commando mode) ont he interwebs here is how (at your own risk, you have been warned)

[email protected]:~# chromium –user-data-dir %U
or update your short cut to include the –user-data-dir %U directive

What if, for some hideous reason you want to use your mobile or some other evil contraption to view your remote desktop.
You can change the the VNC resolution to match that of you device by issuing the following command
[email protected]:~# vncserver -geometry 800×600

Resources :
LXDE FAQ – http://wiki.lxde.org/en/LXDE:Questions#Change_default_browser
TightNVC FAQ – http://www.tightvnc.com/faq.html#howsecure
How to port forward using PUTTY  – http://www.cs.uu.nl/technical/services/ssh/putty/puttyfw.html

That’s all Folks!

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

How to calculate the innodb_buffer_pool_size im my.cnf

In order to properly calculate the size of the innodb_buffer_pool_size directive in MySql configuration we need to find the RIBPS.
RIBPS is the : Recommended InnoDB Buffer Pool Size based on all InnoDB Data and Indexes with an additional 60%.

So you fire up an sql session and run the following query :

SELECT CEILING(SUM(data_length+index_length)/POWER(1024,2)) RIBPS FROM information_schema.tables WHERE engine='InnoDB';

The output is the number we are after :


+-------+
| RIBPS |
+-------+
| 5053 |
+-------+

So in the configuration of MySql server (usually in /etc/mysql/my.cnf)
we add the following :


[mysqld]
innodb_buffer_pool_size=5053M

Given the amount of data and index pages for your dataset, having a small Buffer Pool will just cause data and index pages accessed to rotate out and load new pages as needed (like low memory and swap in Linux). Having the Buffer Pool too big would just wastes RAM so its critical to set it just right.

Tip : Use the following query after the mysql db has run for a week or so (or before restarting it, so that you dont have to wait for another week!) to see how many actual pages of InnoDB data reside in the InnoDB Buffer Pool.

SELECT (PagesData*PageSize)/POWER(1024,3) DataGB FROM
(SELECT variable_value PagesData
FROM information_schema.global_status
WHERE variable_name='Innodb_buffer_pool_pages_data') A,
(SELECT variable_value PageSize
FROM information_schema.global_status
WHERE variable_name='Innodb_page_size') B;

Have fun!

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

Downgrade PHP 5.4 to PHP 5.3

So you got your fresh Debian 7 installed and realized in terror that it ships with PHP 5.4!

Most of the popular CMS out there are not ready for the changes in php core yet so you actually need to downgrade php 5.4 to php 5.3.
Here is how :

Most of the commands are self explanatory so you could just just copy & paste them into cli.

Edit the /etc/apt/sources.list file

vi /etc/apt/sources.list

and add the old Debian 6 repositories

deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.us.debian.org/debian/ squeeze main contrib non-free

save the file

Create the /etc/apt/preferences.d/preferences file that will allow us to “pin” the older php packages to whatever we like.
vi /etc/apt/preferences.d/preferences

and insert the packages you need to have downgraded to previous version
usually the following are enough but modify further if needed

Package: php5*
Pin: release a=oldstable
Pin-Priority: 700

Package: libapache2-mod-php5
Pin: release a=oldstable
Pin-Priority: 700

Package: libapache2-mod-php5
Pin: release a=oldstable
Pin-Priority: 700

Package: php-pear
Pin: release a=oldstable
Pin-Priority: 700

Package: *
Pin: release a=stable
Pin-Priority: 600

Now remove the pre-installed php 5.4 and all its dependencies with the following command
aptitude remove `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

Update the apt-get so we it can find the older php version
apt-get update

Tell the system to install the version we want and previously pinned in the preferences file
apt-get -t oldstable install `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`

Confirm success with the following
dpkg -l | grep php

Restart apache
/etc/init.d/apache2 restart

And there you have it! Brand old php 5.3 in Debian 7 :
Greeeat succeeeess!

borat_great_success

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS