Quickly create a bootable USB in Linux

Yes – Everything I do – I do it for you (more like IN you; Ahem! You = Linux BTW)!

Alright without wasting any time lets quickly get on with it.

This post is about saving your DVD and DVD tray; This post is about installing the OS at a superior speed; This post is about saving time.

What we want to achieve:

We want to install an OS using a bootable USB drive instead of a DVD (it has a lot of hassles – you need to buy one – you need to sit and wait for burning to complete – it may fail – you need to go to the shop and buy another one – as it runs from a DVD the installation will be slower – BLAH BLAH BLAH!)

How we are doing it?

For Ubuntu and other more recognized Operating Systems, we already have Ubuntu Startup Disk Creator, or that.

But it requires software installation and doesn’t work with all the Operating Systems.

So we are going to use the tools which come bundled with all the Linux distros and we are going to make our USB disk imitate a DVD.

What to do:

Make sure you have the ISO of the operating system downloaded already. Lets put it in the $HOME directory and let’s call it OS.iso


$ sudo dd if=$HOME/OS.iso of=/dev/sdx oflag=direct  bs=1048576

Where:

bs stands for bytes. 1048576 = 1024 * 1024 bytes = 1Mb.

‘/dev/sdx‘ is the target USB drive. If your system doesn’t support ‘oflag=direct’, you can just leave it out as it is simply intended to speed up the process a bit.

If you don’t know about the target USB drive path, run this command and figure out your destination drive.


$ sudo fdisk -l

Warning: Please make sure you have the correct value for x – or it can be catastrophic for you running environment.

Remember, don’t include an integer for the USB drive, e.g. ‘/dev/sdx1’, as it would refer to the existing partition on that drive and not the drive itself.
When the USB has been properly created by ‘dd’, there should be an output similar to this:

706+1 records in
706+1 records out
740601856 bytes (741 MB) copied, 91.7024 s, 8.1 MB/s

Happy Hacking!

Source: http://community.linuxmint.com/tutorial/view/744

 

Switch to Colemak/Dvorak

Its true! I can touch type without even looking at the monitor, with an average WPM of 60+ (most people can! Are you most people?), but then sometimes LOVE is not enough.

 

#1 Why?

QWERTY wasn’t designed with the user in mind (typewriter wins). More info: here & here

User productivity increases. Less fatigue – don’t have to worry about http://en.wikipedia.org/wiki/Repetitive_strain_injury

Colemak etc are less prone to typos.

& for the sheer thrill in doing something new & rare (btw eight years ago I moved to Linux. No analogy! *Wink*)

 

#2 How?

Ideally all you need is an OS that understands the layout. All modern operating systems do.

That’s how you can switch layouts in Windows Ubuntu etc (just google).

 

Optionally, if you are like me – feedback is vital.

  • Let’s buy that keyboard?
  • Maybe those glowing stickers?
  • Ah! Just get me a screw driver X(

Pop the keys out and rearrange!

image

The red “i” has landed on the home row. Good stuff. Please don’t do that to your laptop. USB keyboard is pretty easy to acquire.

Downside: F & J have moved (if you know what I mean). #anchor #bump #ridges

 

#3 Next Steps

Learn

 

Q. All said and done – Why is QWERTY still in production?

A. I don’t have to answer that as we all know what will happen if you go to your manager/boss and ask him to sponsor this migration. For him all that’s expected out of you is that you ‘deliver’ – which you are already capable of.

 

Happy hacking!

 

PS: WPM has significantly gone down. But do not worry. #FreshStart

PPS: Yes! I used Colemak to write this post.

more stuff:

http://en.wikipedia.org/wiki/Latin-script_non-QWERTY_keyboards

 

Update (20130812):

Q. How to Switch in Android?

A. Google Keyboard is the answer. Get the app.

Settings — Language & Input — Google Keyboard — Advanced settings — Custom Input Styles — Add style (Currently it supports 6 layouts)

This is definitely cool. Gesture typing is fun.

Android-Colemak

Android-Colemak

PPTP VPN on Linux. Spotify on Linux. VPN on Android

What is VPN (source: Wikipedia)

A virtual private network (VPN) extends a private network and the resources contained in the network across public networks like the Internet. It enables a host computer to send and receive data across shared or public networks as if it were a private network with all the functionality, security and management policies of the private network. This is done by establishing a virtual point-to-point connection through the use of dedicated connections, encryption, or a combination of the two.

VPN on Linux Mint

Just follow the screenshots –

Image

under the VPN tab you specify the server details.

( Free Servers are available at http://www.vpnbook.com/#pricing )

Image

Image

For troubleshooting:

$ tail -f /var/log/syslog

 

 

Additionally …

#1

Install Spotify on Linux

https://www.spotify.com/int/download/previews/

(Works just great! Much better than using WINE to make it work!)Image

#2

Use Extended Google Play (+install Spotify application) on Android

Recently Google Books have been launched on Google Play in India.

Image

(Running OpenVPN in this snapshot; You might not be able to buy a lot of stuff. I haven’t tried!)

Make sure you connect to a US VPN server when you register for Spotify & the Spotify Radio shall be available for you.

Switch accounts on Google Play. And you would finally see the world.

#3

Run VPN on Android

Fairly straightforward.

Android Settings – Wireless and networks – VPN – Add VPN network

 

Cheers!

(Android SGS2 I9100G running ICS; Indian demographic)

Citrix Receiver on Linux x86_64

Of late I have been on an OS installation spree; For some reason I didn’t like 12.10 too much.

To WFH and that too from some derivative of Linux, I had to each time make sure that Citrix worked. I have successfully installed it on Ubuntu, Slackware and Linux Mint (few minutes back).

#Step 1

Go to Citrix.com and download Receiver for Linux in .deb

The package:

Even though we have downloaded it from the 64-bit section, as the name suggests it still is a 32-bit package.

#Step 2

To make sure that the 32-bit binaries work on your 64-bit machine please install:

$ sudo apt-get install ia32-libs

#Step 3

Installation is as simple as a double click (for Debian and derivatives). For others please convert it to the required format using the tools available on your current system.

#Step 4

Open web browser (Chrome works best). Login etc.

And when the browser downloads the .ICA file then advise the Browser to use

/opt/Citrix/ICAClient/wfica

Known Issues:

Installation Fails:

You are happily waiting for the installation to complete but it fails at the final post-install steps, even after getting successfully installed.

Now each time you try to install a new software this post-install will be retried and would leave your machines in a mess.

The work around is pretty simple. The script is looking for x86 as the desired architecture when it actually is x86_64 (you can validate that by typing `uname -m` in the terminal)

#StepA Open the postinstall file
$ sudo gedit /var/lib/dpkg/info/icaclient.postinst

#StepB
# replace
# echo $Arch|grep "i[0-9]86" >/dev/null
# with
# echo $Arch|grep -E "i[0-9]86|x86_64" > /dev/null

#StepC tell dpkg to configure icaclient
$ sudo dpkg --configure icaclient

If it still doesn’t work for you then open the terminal and try this:

/opt/Citrix/ICAClient/wfica PATH_TO_ICA_FILE

This way you can find out details and try to troubleshoot.

Additionally you may check this https://help.ubuntu.com/community/CitrixICAClientHowTo.

Happy Hacking.

VirtualBox vboxdrv problem on Ubuntu

Problem Statement:

#1

Kernel driver not installed (rc=-1908)

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing


/etc/init.d/vboxdrv setup

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.

#2

Failed to open a session for the virtual machine “Windows XP”.

The virtual machine ‘Windows XP’ has terminated unexpectedly during startup with exit code 1.

(Running a virtual machine on VirtualBox the two dialogues would say that)

The cause — as the VirtualBox page states it:

Ubuntu/Debian users might want to install the dkms package to ensure that the VirtualBox host kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are properly updated if the linux kernel version changes during the next apt-get upgrade.

The Fix:

The dkms package can be installed through the Synaptic Package manager or through the following command:

sudo apt-get install dkms

Running `virtualbox` in the terminal says almost the same thing…

$ virtualbox
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (3.5.0-18-generic) or it failed to
load. Please recompile the kernel module and install it by

sudo /etc/init.d/vboxdrv setup

You will not be able to start VMs until this problem is fixed.
# You have heard the man!
$ sudo /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules [ OK ]
* Uninstalling old VirtualBox DKMS kernel modules [ OK ]
* Trying to register the VirtualBox kernel modules using DKMS
Error! Your kernel headers for kernel 3.5.0-18-generic cannot be found.
Please install the linux-headers-3.5.0-18-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located

* Failed, trying without DKMS
* Recompiling VirtualBox kernel modules
* Look at /var/log/vbox-install.log to find out what went wrong
# Downloading the Linux Headers now
# sudo apt-get install linux-headers-3.5.0-18-generic
$ sudo apt-get install linux-headers-`uname -r`
# Running it again
$ sudo /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules                          [ OK ]
* Uninstalling old VirtualBox DKMS kernel modules             [ OK ]
* Trying to register the VirtualBox kernel modules using DKMS [ OK ]
* Starting VirtualBox kernel modules                          [ OK ]

All good!

Missing “Safely Remove” in Ubuntu 12.10

Strange isn’t it?

There was a time when all you had to do was “Safely Remove” and see the progress bar dance for a few seconds — and you were golden.

Those were the days! Anyway it turns out unmount/eject/safely remove are all meant to do different things.

Yes we are talking about our near and dear external hard-disks. (think: WD, Segate, FreeAgent Blah Blah)

 

Now with Ubuntu 12.10, only “unmount” is available on “Nautilus”! Even “Thunar” is no good.

(*these are lets say pretty awesome “Windows Explorer” in the world of Linux)

Well people have even reported it [bug]. Please feel free to mark it “The Bug affects You”.

 

Why?

What do you mean “why”? Its a BUG. The beauty of opensource is that someone will fix it. Sit back and relax. Its not urgent anyway.

So why this post?

Well who would not want to make sure that their Hard Drive is doing well and not in an inconsistent state — unable to do the most important thing that they are supposed to do — SAVE DATA! You wouldn’t want a lossy storage. Anyway, the point is — to make sure that all the data was written to the harddisk before you unplugged it — you’d need to UNMOUNT it. You always should. And if there are more than one partitions on the Hard Drive then you need to unmount each and everyone separately (which was earlier taken care by “SAFELY REMOVE”).

But?

Still the Harddisk keeps spinning. You can feel it. You can even hear it. And the LED would just keep glowing.

So until they fixed it, we have a work around.

Spin down the harddisk

I found answers to my queries here:

I created a quick shell script


#!/bin/bash
echo "Unmounting disks..."
udisks --unmount /dev/sdb1
udisks --unmount /dev/sdb2

#udisks --unmount /dev/sdb3
#depending on the number of partitions you have on your drive edit above
#please make sure all the partitions are unmounted before you detach

echo "Spinning down!"
udisks --detach /dev/sdb
echo "All done!"

Execute it …


$ chmod u+x safelyremove.sh
$ ./safelyremove.sh
Unmounting disks...
Spinning down!
All done!

Or even better — Save it on Desktop

Just double click; “Run” and you are almost “GOLDEN” again!

 

Happy Hackin’

Enable Hibernation on Ubuntu

One of those note-to-self posts!

Why does Ubuntu come with Hibernation disabled by default?

Ubuntu had to resort to such measures as users experienced a lot of issues like:

  • No resume after suspending the PC — in a limbo
  • Open files and folders gone — Shutdown instead of hibernation
  • Wifi etc devices not working after waking up — the worst nightmare

And that happened because there wasn’t enough Hardware support. Even in Ubuntu derivatives like Linux Mint it came disabled.

What is hibernation?

Seriously? Forget it. I am not even going to look at you.

Alright Alright suit yourself: https://help.ubuntu.com/community/PowerManagement/Hibernate

Advantages of Hibernation:

  • You have an edge over “suspending”. It saves power.
  • The exact state of the computer is resumed.
  • Major use case for the people who leave their  PCs unattended (think: http://Torrentz.in)

How to enable it in Ubuntu:

Step#1 Check if hibernate works on your hardware.

  • Open Terminal (CTRL + ALT + T)
  • Save your work first and then type
 $ sudo pm-hibernate 
  • If everything goes smoothly, start your laptop and continue iff things look good.
  • If you see anything unexpected then please make sure that the size of SWAP is at least as large as the RAM or just 
     System.exit(1) 

Step#2 You can continue to use that command safely or make it permanent by enabling it on the menu (do it only if Step#1 above works)

Open terminal and type:

 $ sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla 

Enter the password

(instead of `gedit` you can use `vi` its awesome)

hit “i”; paste; hit “ESC”; hit “:”; hit “x”

Step#3 Paste the following lines in the blank file you created just now.

[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

Hit Save and Quit.

Step#4 Reboot for the changes to take effect.

If upon restart you still cannot see the “Hibernate” item in the menu, then you need to Tweak the Grub but mostly it would not come to that.

And we’re back …

Also check http://nikunjlahoti.com/2012/04/29/ubuntu-12-04-fix-fn-brightness-keys/

Sources:

https://help.ubuntu.com/12.04/ubuntu-help/power-hibernate.html

https://help.ubuntu.com/12.04/ubuntu-help/power-suspendfail.html

Get your own website & WordPress++

Well… You can Blog!! (And the crowd cheers)

Frankly.. to cover everything would very exhausting. Lets just focus on the fancy stuff eh?!! (When I say fancy I just mean things that won’t make the ninja angry. You can totally keep living your life like you do)

So all you need is a credit-card and with absolutely no ado you can choose a custom domain and link your blog to it. You just have to THINK (of a name for your custom domain) and PAY ($18 per year; less than 1000INR). And WordPress takes care of everything.

Eg: https://nikunjlahoti.wordpress.com becomes http://nikunjlahoti.com

All your existing links etc get redirected to the new address. There are a lot of  TLDs like .ME, .COM etc that you can use.

For the rest of this post I am safely assuming that you have already bought the domain using WordPress. (Yes! There are ways to buy the domain yourself [think: http://godaddy.com] and then pay WordPress money to link it. Eventually you don’t get to save much. I would say as Tumblr.com does that for free so check that out today!)

Lets say your wordpress blog was: http://domain.wordpress.com

You got a brandnew custom domain name: http://mydomain.com

#2 (No! I wasn’t kidding before)

Get a http://blog.mydomain.com kind of URL for your Blog

I recently (5 minutes back) linked my Tumblr account [http://nikunjlahoti.tumblr.com] to my WordPress domain [http://nikunjlahoti.com]. Yeah that’s the place where I rant about topics not really related to technology or IT in general.

So as soon as you click on that Tumblr link above, it magically changes to [http://blog.nikunjlahoti.com]

I know it doesn’t make much sense to nest the blogs. But its a valid use-case.

Step1:

Login to your Tumblr blog

http://www.tumblr.com/blog/blogname/settings

Choose a CNAME (in this case “blog“)

CNAME record or Canonical Name record is a type of resource record in the Domain Name System (DNS) that specifies that the domain name is an alias of another, canonical domain name. This helps when running multiple services (like an FTP server and a webserver; each running on different ports) from a single IP address. Each service can then have its own entry in DNS (likeftp.example.com and www.example.com).

Wiki

Step2:

Go to: https://domain.wordpress.com/wp-admin/paid-upgrades.php?page=domains

Hit: “Edit DNS”

Add an entry: CNAME blog domains.tumblr.com

Save!

#3

Get a http://mail.mydomain.com kind of URL for your Email

me@nikunjlahoti.com

I mean how chic is that right?

Features:

Its powered by Gmail. Called Google Apps for business! You get an inbox of 10Gb. And there is Calendar, Docs and Sites.

In a free package you can create upto 10 email ids like that on your domain.

Btw, if you want an iamafan@nikunjlahoti.com email id then please let me know. I will be happy (wink) to do that. First lucky 5 people!! Ha!

How to:

Step1: Go to http://google.com/apps and Sign up Free Trial. Use a domain name I have already purchased (mydomain.com)

Step2: Verify site ownership. Use Add a <meta> tag to your home page

Go to: https://domain.wordpress.com/wp-admin/tools.php and paste that code. Save!

Come back and verify again. It will work!

Step3: Route the emails using Google servers

https://domain.wordpress.com/wp-admin/paid-upgrades.php?page=domains

“Edit DNS”

put in the following entries (as told by Google)

CNAME mail ghs.googlehosted.com.
MX 5 ALT1.ASPMX.L.GOOGLE.COM.
MX 5 ALT2.ASPMX.L.GOOGLE.COM.
MX 1 ASPMX.L.GOOGLE.COM.
MX 10 ASPMX2.GOOGLEMAIL.COM.
MX 10 ASPMX3.GOOGLEMAIL.COM.

(refer to the first image)

It can take upto 48 hours for this to work but generally just takes less than 1 hour.

And we are done!

and as we wrap up, let me throw in a Productivity tip:

[sourcecode language=”css”]
your code here
[/sourcecode]

becomes

your code here

Honorary mention to Java:

class MyClass {
 public static void main(String arr[]) {
 System.out.println("Wordpress Code Highlights");
 }
}

http://en.support.wordpress.com/code/posting-source-code/

Also, please notice the Doomsday Clock to the left!

Funny right? It would have been so much fun to see the countdown running. I guess it will eventually come!

Talking of which, I have written stuff on my Tumblr log — my non technical blog 😀 (almost non technical). Feel free to check it out.

Happy Hacking!

Save HTML webpage to a PDF Document

Why?

You get to access it offline. Its more readable. You can annotate, leave comments, etc from a PDF Client (Adobe Acrobat Reader anyone?). You can even track your progress inside the document. If your client is really friendly it can even reopen the document from where you left it.

Well for me its merely a matter of convenience. I always prefer a PDF manual instead of an HTML/CHM one for some reason (think: http://docs.python.org/download.html); Does it really matter if PDF is three times the size of the HTML archive? Storage isn’t really a pushing concern these days. Is it?

Idea:

Multiple HTML pages to a Single PDF.

There are a lot of websites which offer to convert an HTML document to PDF on the fly. Doesn’t serve the purpose and I not very big on registering everywhere!

For our little experiment lets pick a URL. I suggest http://www.catb.org/~esr/writings/homesteading/cathedral-bazaar/index.html.

(for further reading go to https://en.wikipedia.org/wiki/The_Cathedral_and_the_Bazaar by Eric S. Raymond).

#1 Download web pages recursively using wget

# create a directory under home; Think: less clutter
$ mkdir ~/our_little_experiment; cd ~/our_little_experiment;

# download the webpage and recursively download all those webpages which are linked from this page in the current directory.
$ wget -v -r http://www.catb.org/~esr/writings/homesteading/cathedral-bazaar/index.html

FINISHED –2012-10-07 20:15:47–
Total wall clock time: 2m 51s
Downloaded: 16 files, 164K in 1.9s (88.7 KB/s)

A little later …

# lets look at the files generated by wget (an awesome tool btw!)
$ cd ~/our_little_experiment/www.catb.org/~esr/writings/homesteading/cathedral-bazaar

$ ls -1
ar01s02.html
ar01s03.html
ar01s04.html
ar01s05.html
ar01s06.html
ar01s07.html
ar01s08.html
ar01s09.html
ar01s10.html
ar01s11.html
ar01s12.html
ar01s13.html
ar01s14.html
ar01s15.html
ar01s16.html
index.html

# index.html is actually chapter 1 so renaming it to ar01s01.html
$ mv index.html ar01s01.html

#2 install htmldoc

$ sudo apt-get install htmldoc

#3 create the PDF document

$ htmldoc --webpage -t pdf14 -v -f catb_cathedral_bazaar.pdf *.html

Output: catb_cathedral_bazaar.pdf

Voila!

All the links work perfectly.

I’d be happy to guide anyone doing it on w32.

Please don’t use “win” as an abbreviation for Microsoft Windows in GNU software or
documentation. In hacker terminology, calling something a “win” is a form of praise. If you
wish to praise Microsoft Windows when speaking on your own, by all means do so, but not
in GNU software. Usually we write the name “Windows” in full, but when brevity is very
important (as in file names and sometimes symbol names), we abbreviate it to “w”. For
instance, the files and functions in Emacs that deal with Windows start with ‘w32’.

— GNU Standards

http://www.gnu.org/prep/standards/standards.html#Trademarks-1

 

Happy Hacking!
References:

http://freecode.com/projects/htmldoc

http://www.htmldoc.org/software.php

Separate logs for each order in Log4J

In my current project we are using Apache CommonsLogging backed up by Log4J.

Though it is a Multi-threaded application (processes multiple orders simultaneously), all the logs from all these threads simultaneously go inside a single file (via RollingFileAppender). Recently there was a change request to maintain separate logs for each order.
Having a separate file for every incoming order can prove a little more than costly.

— Housekeeping of these logs on the basis of time? Who decides which log has to be kept and which one has to be discarded? Perhaps it can be handled by writing a few shellscripts.

— Under development, or in production, for each run we’d have to open a different Log file to check the Logs for debugging purposes.

— On a Unix server there is a limited number of inodes or files that you can keep inside a directory. You run out of it then you cannot create more files and for such a bulky directory, manipulation would be a big pain.
So I would rather append an identifier (which can tell the order uniquely) with each and every log statement and then can easily `grep` the main Log file for the complete logs of a particular order.

— Appending ORDERID of that order to each and every log statement of a big big application would be a major overhead and isn’t maintainable. What if there comes a NEWUNIQUEVALUE for the orders!?

— Appending ORDERID just to the first and the last log statement wouldn’t guarantee that all the logs which get extracted are of that same order. It is a multi-threaded application anyway.

Step1:

Make changes to the Log4J.properties file. Add a %t at the starting of the Pattern.

Eg.

ConversionPattern=%p %c – %m%n

to

ConversionPattern=%t %p %c – %m%n

(Here we are asking the Logging Framework to append the name of the Thread to the logs)

t = Used to output the name of the thread that generated the logging event.

p = Used to output the priority of the logging event.

c = Used to output the category of the logging event.

m = Used to output the application supplied message associated with the logging event.

n = Outputs the platform dependent line separator character or characters.

Step2:

In your Java code, inside the run() method of the ThreadClass or the Concrete Implementation of the Runnable Interface change the name of the Thread using:


String uniqueOrderId = ${ fetched from inside the order XML etc };

Thread.currentThread().setName(uniqueOrderId);

If for some reason you need to preserve the ThreadName, in that case append it back to the uniqueOrderId.

Step3:

$ grep uniqueOrderId MAINLOG.log > uniqueOrderId.log

(find the lines with uniqueOrderId in the MAINLOG.log and create a new file uniqueOrderId.log with that)

COMPILE and EXECUTE!

(Dinner is getting cold. I know I could have been more verbose! TING!)