Roshan Book

My Tech Notebook

Tag Archives: ubuntu

Improve battery life and reduce overheating in Ubuntu/Debian

Feeling the heat from your laptop? Overheating and reduced battery life is common ‘phenomenon’ in Linux Mint. Jupiter was the best tool to reduce overheating in Linux desktop but since its development has stopped, you can use TLP or CPUFREQ instead of Jupiter. Install TLP using the following command:

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt-get install tlp tlp-rdw
sudo tlp start

No configuration required for using TLP. Install it and forget about it. If you want to use CPUFREQ, read this article how to use CPUFREQ to reduce overheating in Ubuntu.

Solving : net usershare add: cannot convert name “Everyone” to a SID + unexpected information received

Today while sharing my Public folder , I was getting this error:

“net usershare add: cannot convert name “Everyone” to a SID + unexpected information received”.

Agter searching for a while, I found solution which worked from here :


[1] Do not ever use gadmin-samba again for as long as you live.

[2] Purging the “samba” package will not resolve your discombobulated smb.conf file since that file doesn’t come from the “samba” package.

[3] Restore a factory fresh copy of smb.conf:

(**) Make sure the following file exists: /usr/share/samba/smb.conf

(**) Make a backup of your current smb.conf

  sudo cp /etc/samba/smb.conf /etc/samba/smb.confMOD

(**) Start with a fresh one:

sudo cp -a /usr/share/samba/smb.conf /etc/samba/

(**) Correct one mistake in the new one:
Find the line:

encrypt passwords = false

and change it to:

encrypt passwords = true

(**) Restart samba

sudo service smbd restart

Setting up Lisp on Linux (Ubuntu)

I consider Paul Graham as my guru. His book Hackers & Painters has given me my dream. So when he says Lisp is great , I believe him. I have no idea about the concept of “macros”, or “closure” is, but I know one day I will learn Lisp and get that blub paradox.

Installing Lisp

Today I tried to set up lisp environment on my system, and succeed 🙂 . Not a tough job when you have the power of

sudo apt-get install clisp

You can install popular Clisp dialect on ubuntu system by typing above command.

For start using it, well you could just type clisp in your terminal and be greeted with

You are now at the lisp REPL (Read Eval Print Loop).

To get an editor

I was recommended to used Emacs with slime for Lisp. In-fact hardcore vim users also uses emacs for lisp editing

So, the magical command to get this 88mb program installed is

sudo apt-get install emacs slime

Configuring Emacs with Slime

No don’t ask me what they mean. Just go ahead with the following steps to configure Emacs with slime

mkdir ~/.slime

This command will make a directory “.slime” in your home folder

gedit .emacs

This will open a new file by the name of .emacs in gedit (editor), which is to be saved in home directory

;;; Lisp (SLIME) interaction
(setq inferior-lisp-program “clisp”)
(add-to-list ‘load-path “~/.slime”)
(require ‘slime)

(global-font-lock-mode t)
(show-paren-mode 1)
(add-hook ‘lisp-mode-hook ‘(lambda ()
(local-set-key (kbd “RET”) ‘newline-and-indent)))

Add above lines to .emacs file

I tried to explain what each command does. Will try to add more, once I get hang of it.

Just for fun

; Lisp
(defun addn (n)
#'(lambda (x)
(+ x n)))

Do you know what this does ?

Yes it takes a number n, and returns a function that adds n to its argument
Do you understand how it does?

No Idea, Bro!

Can you represent something like this in C?

Not possible at all.

That is just one sample, to show power of lisp – self 🙂

Do read about blub paradox, to get little bit of light on this .

Set up wireless in HP Compaq nx6310 in ubuntu

1. First install alsa driver from

2. Go addtional drivers

3. Enable Software modem

4. Run terminal (ctrl+alt+t)

5. Run command sudo apt-get install firmware-b43-installer b43-fwcutter


Starting YII development in ubuntu – Part 2


Nothing is worse than an ugly URL. Well, Hitler was quite bad, but so are ugly URL’s. Not only are they ugly for your users, but as clever as google is, they are ugly for it too. How is google supposed to know that “products/index.php?cat=3&id=46″ is an iPod nano? Today we will be looking at making the sexiest thing in the world, nice URL’s. Jessica Alba isn’t bad either.


Yii makes it insanely easy to rewrite URL’s to whatever you want. All of it is done in our config/main.php. Let’s open that bad boy up and see what’s inside. If you scroll down to around line line 34ish you will see the urlManager. If we uncomment this we get much nicer URL’s straight away. Insead of having ugly variables in the URL we will now have pretty good looking controller/action URL’s. So if we are using our product controller and looking at the browser action the URL would look like “index.php/product/browse”. Not to bad, but what about the index.php? We can take that out using our .htaccess file. Nobody understands. htaccess files, so instead of trying to write your own, just download this one that my friend William gave me. Click here to download it.

Just chuck that in your root directory and you never have to see and index.php again. Now, what about custom URL’s? We want the URL to look like it is an apple iPod. Let’s pretend that the URL now looks like “products/browse/prod/46″. Like I said early, we can make it look like whatever we want! Open up your main/config.php again, and scrolldown to somewhere around line 37ish. You will see:


That is Yii’s URL rewriting at work. Now, above that we can add the line:


Thats it. Now when Yii follows the link “catalogue/apple/ipod” the controller/view variable/value it will open is “products/browse/prod/46″ but the URL will be sexy. Told you it was easy. Stay tuned for our advanced tutorial on dynamic URL rewriting coming one day soon.

Posted by admin   @   17 November 20101 comments


How to install an updated version of PEAR / PHPUnit on Ubuntu?

First, install PEAR.

sudo apt-get install php-pear 

Next, tell PEAR to update its own channel.

sudo pear channel-update 

Then, tell PEAR to upgrade itself to the newest version.

sudo pear upgrade-all 

You should now have the newest version of PEAR installed.

To install PHPUnit, let PEAR know where to find PHPUnit.

sudo pear channel-discover 

Then install PHPUnit. (the -a makes sure all dependency packages are also installed)

sudo pear install -a phpunit/PHPUnit 


According to the latest PHPUnit installation documentation, you can install PHPUnit with the following commands (make sure you have updated PEAR first):

pear config-set auto_discover 1 pear install

Make you own private cloud


Today I want to introduce you one of the most amazing light weight cloud based operating system known as eyeOS. eyeOS is a cloud based operating system which can be accessed from any where , think about your desktop from everywhere any device , your documents , files & applications on the web , that means your files on your private cloud.It is a complete open source offering , simply speaking it a light weight OS that can be accessed from anywhere through a web browser , currently there are two options to start with eyeOS.

It is a complete open source offering , simply speaking it a light weight OS that can be accessed from anywhere through a web browser , currently there are two options to start with eyeOS.

1. eyeOS 1.x stable

2. eyeOS 2.x beta

eyeOS 1.9 is equipped with

* More than 250 applications from eyeOS community

* 35 available languages &

* To be used in production environments

eyeOS 2.x includes live collaboration and many more social capabilities than eyeOS 1.x & is soon going to replace the 1.x

In this article we are going to install eyeOS 1.9 stable over ubuntu 10.10 32 bit OS , so sit back , relax & watch the art in detail.


In order to install eyeOS we need to have the following first in your linux distro


  • Apache HTTP Server 2.x
  • MySQL-server and MySQL-client 5.x
  • & PHP5.2 or higher

Apache HTTP Server 2.x

Install Apache 2 in your ubuntu 10.10 as shown below.

Fig -1

MySQL-server and MySQL-client 5.x

Install mysql client in your linux distro as shown below.

Fig -2

Install mysql server as shown below.

Fig -3

You need to enter a password for the administrative user of mysql server , type in a password of your choice.

Fig -4

PHP  5.2, or higher

Install php as shown in your linux distro.

Fig – 5

eyeOS installation

Now it is time for us to get in to the real installation of eyeOS , download eyeOS 1.x stable version from their site.

Extract the to our website directory & assign chmod 777 to eyeos directory.

Fig – 6

From the console type

sudo chown -R www-data.www-data /var/www/eyeOS


sudo chmod 750 -R /var/www/eyeOS

Fig -7

Restart your pc , go to the web browser & type as shown below.

Fig – 8

Now it is time for you to set a password for the root user , you will also get an option to allow your end users to add their accounts themselves .

Fig -9

Fig -10

Now we have done with it , we are in eyeos Desktop as shown below.

Fig -11

Customizing the defaults.

The default upload size with eyeos is only 2 MB , you can change it to a value of your choice by editing the php.ini file at


In php.ini change upload_max_filesize & post_max_size values


upload_max_filesize = 200M

post_max_size = 200M

Upload size changed to 200 MB now  as shown below.

Installing Oracle JDK 7 On ubuntu

  • Download he 32bit or 64bit Linux “compressed binary file” – it has a “.tar.gz” file extension i.e. “[java-version]-i586.tar.gz” for 32bit and “[java-version]-x64.tar.gz” for 64bit
  • Uncompress it

    tar -xvf jdk-7u2-linux-i586.tar.gz (32bit)

    tar -xvf jdk-7u2-linux-x64.tar.gz (64bit)

JDK 7 package is extracted into ./jdk1.7.0_02 directory. – Now move the JDK 7 directory to /usr/lib

sudo mv ./jdk1.7.0_02 /usr/lib/jvm/jdk1.7.0

  • Now run
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
  • Run
sudo update-alternatives --config java

You will see output similar one below – choose the number of jdk1.7.0 – for example 3 in this list:

$sudo update-alternatives –config java There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ———————————————————— * 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode 3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode Press enter to keep the current choice[*], or type selection number: 3 update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode. 

Check the version of you new JDK 7 installation:

java -version

java version “1.7.0” Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) 

Repeat the above for:

sudo update-alternatives --config javac sudo update-alternatives --config javaws

Control laptop chargin on ubuntu


The charging thresholds are, very unfortunately, firmware and vendor specific.

The lenovo user is luckily provided with a solution outlined here:

It basically says that you would have to install the tp-smapi-dkms package and issue the following as root:

echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh

Then it will stop charging once it reached 80% and only start charging when it drops below 40%.

Toshiba and others might have a similar kernel module that exposes firmware functionality to the /sys or/proc space, but it is very unlikely for patent issues. For the same reasons, an application that could handle this would be either Thinkpad- specific or only address a few select vendors.

FFmpeg cheat sheet


ffmpeg is a multiplatform, open-source library for video and audio files. It is usualy available in your distribution repositories, so search for it and install it. For Ubuntu:

sudo apt-get install ffmpeg

Because certain codecs are not activated for FFmpeg in Ubuntu Jaunty, I suggest you download and install these ffmpeg fixed packages (unfortunately they are available for 32bit only).

Now that you have installed ffmpeg, you can start trying these commands which cover almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more:

Getting info from a video file

ffmpeg -i video.avi

Turn X images to a video sequence

ffmpeg -f image2 -i image%d.jpg video.mpg

This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images

ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also available : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the iPpod/iPhone

ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 128kb/s
* Video codec : mpeg4
* Video bitrate : 1200kb/s
* Video size : 320px x 180px
* Generated video : final_video.mp4

Encode video for the PSP

ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

* Source : source_video.avi
* Audio codec : aac
* Audio bitrate : 32kb/s
* Video codec : xvid
* Video bitrate : 1200kb/s
* Video size : 320px x 180px
* Generated video : final_video.mp4

Extracting sound from a video, and save it as Mp3

ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

* Source video : source_video.avi
* Audio bitrate : 192kb/s
* output format : mp3
* Generated sound : sound.mp3

Convert a wav file to Mp3

ffmpeg -i source_song.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 final_song.mp3

Convert .avi video to .mpg

ffmpeg -i source_video.avi final_video.mpg

Convert .mpg to .avi

ffmpeg -i source_video.mpg final_video.avi

Convert .avi to animated gif (uncompressed)

ffmpeg -i source_video.avi animated_gif.gif

Mix a video with a sound file

ffmpeg -i song.wav -i source_video.avi final_video.mpg

Convert .avi to .flv

ffmpeg -i source_video.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv final_video.flv

Convert .avi to dv

ffmpeg -i source_video.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 final_video.dv


ffmpeg -i source_video.avi -target pal-dv final_video.dv

Convert .avi to mpeg for dvd players

ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 final_video.mpeg

Explanations :

* target pal-dvd : Output format
* ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
* aspect 16:9 : Widescreen

Compress .avi to divx

ffmpeg -i source_video.avi -s 320x240 -vcodec msmpeg4v2 final_video.avi

Compress Ogg Theora to Mpeg dvd

ffmpeg -i source_video.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 final_video.mpg

Compress .avi to SVCD mpeg2

NTSC format:

ffmpeg -i source_video.avi -target ntsc-svcd final_video.mpg

PAL format:

ffmpeg -i source_video.avi -target pal-svcd final_video.mpg

Compress .avi to VCD mpeg2

NTSC format:

ffmpeg -i source_video.avi -target ntsc-vcd final_video.mpg

PAL format:

ffmpeg -i source_video.avi -target pal-vcd final_video.mpg

Multi-pass encoding with ffmpeg

ffmpeg -i source_file -pass 2 -passlogfile ffmpeg2pass final_file-2
%d bloggers like this: