Wednesday, January 07, 2009

Configuring VNC for Linux

VNC (Virtual Network Computing) is a remote display application widely used these days (similar to RDC or 'Remote Desktop Connection' on Windows). It is a client/server software that allows you to build up a terminal server scenario. VNC is available on most of the major platforms including Windows, Linux, Unix, Solaris etc.

Most of the new Linux distributions provide an easy way to configure VNC in main menu as 'Remote Desktop Preferences'. You just need to enable the options and provide a password. But if for any reason your linux doesn't have VNC or you don't have physical access to the machine to even enable VNC you can do the following:


1) Download and Install VNC
You can download the rpm off internet. Famous distributions are RealVNC and TightVNC. TightVNC offers more compression and is better when you have less bandwidth. Please google for more info.

2) Configure VNC remotely
Connect to the system using telnet, xterm or ssh/putty.

The default location of server configuration file for vncserver is '/etc/sysconfig/'. To configure the resolution, user and port open '/etc/sysconfig/vncservers' in you favorite editor and add two lines per user configuration as shown below:

VNCSERVERS="<displayport>:<username>"
VNCSERVERARGS[<displayport>]="-geometry <windowWidth> x
<windowHeight>"

eg:
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600"

You can choose any display port, but it should not be in use by another X server. Window height and width can be anything. The system on which you are going to view the desktop using vncviewer should have greater resolution than what you specify here, otherwise scrollbars will appear.


The default desktop view in vncviewer is gray scale desktop with very pathetic GUI (TWM or Tab Window Manager which came out in 1988!) as shown above. To view normal Gnome or KDE desktop in vncviewer, the xstartup file needs to be configured properly. This user specific configuration file of vncviewer resides in '.vnc' directory in user's home directory. (e.g. '/home/user1/.vnc/' or /root/.vnc). Open '.vnc/xstartup' in your favorite editor and edit as below:


#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startx &


The changes are:
1) uncomment
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

2) comment
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &

3) add
startx & - for Gnome OR
startkde & - for KDE

3) Configuring VNC password
For setting up vncviewer password for user 'xyz', login as user 'xyz' and issue 'vncpasswd' command on a terminal/konsole. Enter password twice and you are good to go.
4) Starting Vncserver
To start vncserver, login as root and issue 'service vncserver start' command (first stop if already running - 'service vncserver stop'). If service started successfully, you are ready to use vncviewer on a remote/local machine.

5) Accessing through Vncviewer
* From Linux based machines
vncviewer <ipaddress>:<displayport> [Enter] #(IP Address is for the machine where you set up vncserver)

* From Windows
Install a VNC Viewer available for download from net (RealVNC, TightVNC, UltraVNC etc). Open it and enter <ipaddress>:<displayport> in the dialog box.



Keep in mind that by default, VNC is not a secure protocol. Passwords are not send in plain text though. But there are many distributions which encrypt the entire session (eg: UltraVNC). You can access a windows machine also remotely if you install VNC Server on it.

Alternatives to VNC:
  • XDMCP
Operating systems using the X Window System can use the X Display Manager Control Protocol (XDMCP) to allow network based access to a remote system's graphical desktop. XDMCP uses much less network bandwith than VNC, but it requires an X server. There are X servers available for non-UNIX OS's. (eg: CygwinX for Windows or XManager or Hummingbird Exceed)

  • NX
Faster than VNC and with sound. NX is an exciting new technology for remote display. It provides near local speed application responsiveness over high latency, low bandwidth links.

Visit this link for more info on NX:
http://www.nomachine.com/


For more info on VNC, refer:
http://wiki.linuxquestions.org/wiki/VNC
http://bobpeers.com/linux/vnc.php
http://fedora.co.in/2007/12/01/how-to-configure-vncserver
http://en.wikipedia.org/wiki/Virtual_Network_Computing

Tuesday, December 09, 2008

Replace Notepad with Notepad2

Notepad is one of the few tools that have always been a part of Windows, but in the process of updating and improving the OS, were left behind and have not evolved at all. Microsoft views Notepad as a final product and does not plan to make any changes or additions to it in the foreseeable future.

The original Notepad shipped with Windows is probably the handiest program of all times, small, fast, without frills! But Notepad has many disadvantages that are clear to any person using it on a daily basis. That's why many programmers and 3rd-party software developers looked into developing better tools that will still be as simple to use as Notepad, yet offer additional features and capabilities that were left out of the original Notepad. For example, notepad hangs if you try to open a large file (even if just a few MBs). Also there is no option to view line numbers or to go to a line. Again notepad can undo only the last action and neither can it detect external file changes.

Even if you have many complex IDEs and advanced word editors installed on your machine, we still use notepad at least a few times daily, probably to copy and paste the clipboard content or quickly note down something or even to open one or two files in a rush instead of waiting for the bulky IDE to load. I have EditPlus and Programmers Notepad installed on my machine, but still I use notepad for something or the other.

I considered multiple options, which finally boiled down to
1) Programmers Notepad
2) Notepad ++
3) TinyEdit
4) Notepad2

And the winner is, well the first position is shared between two, Notepad2 as a notepad replacement and Programmers Notepad for programming uses. Notepad2 doesn't have any installer. Just download and unzip notepad2.zip and you are ready to go. See Notepad2 in action below. You can see the line numbers, current line highlighting, wrap & long line indicator etc.


To replace windows notepad, do the following:
* Backup your original c:\windows\Notepad.exe (say copy to old_notepad.exe).
* Rename Notepad2.exe to Notepad.exe in above unzipped folder
* Copy the above notepad.exe into 4 directories (in given order) :
1. c:\windows\servicepackfiles\i386 or C:\WINDOWS\i386
2. c:\windows\system32\dllcache
3. c:\windows\system32
4. c:\windows

If when you replace notepad.exe, a "Windows File Protection" message box appears, click Cancel. Now wherever notepad used to come, you get notepad2 instead. Notepad2 is fast and light (260KB versus 67KB windows notepad) and very much worth the extra 200 KB.

You can download it from here:
http://www.flos-freeware.ch/notepad2.html

I did like Notepad ++ a lot too, because:
1) Comes with an autoupdater (no need to download and install again when a new version is released)
2) Supports code folding and syntax highlighting
3) Has plugin support and MDI (multiple tabs)
4) Can replace the default notepad
5) Supports USB mode (all settings stored in app folder)
6) Auto-completion and explorer context menu
7) Love the function list in java files
and a lot more....

My favorite NPP (Notepad Plus) plugins are:
1) Function List (No Unicode Support)
2) Hex Editor
3) Search In Files (No Unicode Support)
4) Spell Checker

Download NPP from here:
http://notepad-plus.sourceforge.net

Here is the list of complete plugins:
http://sourceforge.net/project/showfiles.php?group_id=189927

To install the plugins, just unzip to C:\Program Files\Notepad++\plugins

Since Function List and Search In Files doesn't work in the new versions because of no unicode support, I had to ditch Notepad++ and select Programmers Notepad (PN) instead.

Advantages of Programmers Notepad are:
# Code Folding/Outlining
# Docking tool windows
# Excellent external tool support with user-configurable output matching - click on errors and warnings to jump right to the place in the file where they were generated (compile and run from PN itself)
# File association manager
# In-file method/definition navigation (using Ctags)
# No limit on file size (although large files may take a while to load)
# Projects and Project Groups with multi-level folders and file system mirroring
# Support for unicode files
# Support for windows, unix and macintosh file formats
# Syntax highlighting for many languages through “schemes”.
# Tabbed MDI interface

But I wish PN has an auto updater too :(

You can download it from here:
http://www.pnotepad.org/

You can map new file types to existing schemas for enabling syntax highlighting as shown below. Now I can create/edit JSPs with PN.

This is the file type manager in PN.

PN in action. See the methods and member variables listed nicely, excellent!

You can also notice that I compiled the java program from inside PN. Click on the error and it will take you to that line in source file.

Wednesday, December 03, 2008

Browser Bookmarks Synchronizer


Do you have multiple computers? Say you have a desktop and a laptop? Or perhaps you have a PC/laptop at work and have another one at home too? For e.g.: I have a work laptop, a personal laptop and also a desktop at home. I get online from all of these and many times I wish I had the bookmark on the other machine here or wish I could bookmark a site and it is accessible from everywhere. Many years back I found a solution. It was a different browser called 'Avant' which is basically an Internet Explorer extension. Avant has an online storage and a bookmark manager (multi-tabbed too), and while starting the browser I can login to my account and all my bookmarks are available anywhere... wow! It was so cool and very helpful. Over the years I changed my work PC and laptops many times and I still I have all the bookmarks I accumulated. Trust me, in these days a bookmark is almost as valuable as a contact number. Of course you may be able to locate a site thru a search engine like Google or Yahoo, but then many times when you quickly want something you may not have the luxury to search and find it. Also what is the guarantee that it appears on top of your search results!

So back to the story, I was a happy user of Avant for many years (since 2004). But then in between I quit using IE (2005-06) and fell in love with my sweet, sexy and versatile Firefox browser. Once a foxy (firefox user :P), always one. Back in the days of slow stupid single tabbed IE 5/6, firefox was a charmer with amazingly fast page loading, multiple tabs, integrated download manager and a general sturdy and dependable feel. It even has an integrated search box which can be associated with any search engine of your choice, including msn, Google, Yahoo and even wikipedia. Oh and as an extra bonus, you can even change your search engine in one click. I believe I started using firefox from version 1.x and now it is 3.x. But the only thing I miss is my well arranged huge collection of bookmarks. Firefox didn't have an option to automatically synchronize bookmarks (but you can import IE bookmarks). So I still used to install Avant just to get my bookmarks, but then managing bookmarks and synching between my computers became a big headache. And then I stumbled upon this, a nifty firefox add-on called ‘foxmarks’.

"If you use Firefox on more than one computer, you'll want Foxmarks. Install Foxmarks on each computer, and it works silently in the background to keep your bookmarks and (optionally) passwords synchronized. Foxmarks also keeps your data backed up and safe from computer failures. If you're away from your computer, Foxmarks allows you to access your bookmarks online by logging into my.foxmarks.com"



If you are excited already wait to hear this. Foxmarks just launched a beta version for IE (and Safari) too. Wow! What more do you need?! What are you waiting for, download foxmarks today itself, give it a try and share your experience. It also has an optional 'secure' password synchronizer, but as a word a caution, I would rather stay away from it as I don't want to take any risk and trust anyone else with my password. I prefer not to store my passwords even on the browser!

Here is the download link for foxmarks:
https://addons.mozilla.org/en-US/firefox/addon/2410
http://www.foxmarks.com/ (home page)

Very useful, compiled link of popular Firefox add-ons
http://en.wikipedia.org/wiki/List_of_Firefox_extensions

These are my favorite Firefox add-ons:
1) Firebug - allows the debugging, editing, and modifying of any website's CSS, HTML, DOM, and JavaScript, and provides other web development tools.
https://addons.mozilla.org/firefox/addon/1843

2) DownThemAll (DTA) - a download manager/accelerator extension
https://addons.mozilla.org/en-US/firefox/addon/201

3) IE Tab - view pages using the IE rendering engine from within Firefox. This is useful for some websites that do not work properly in Firefox.
https://addons.mozilla.org/en-US/firefox/addon/1419

4) Adblock Plus - used for blocking ads
https://addons.mozilla.org/firefox/1865/

5) PDF Download - allows users to customize the handling of PDF files. You can also convert web pages to PDF for printing or saving. Instead of the default action of opening a pdf inside browser (which clicked the pdf link), instead you can save it and open externally or even view it as html. Makes browser crashes and slow downloads a thing of the past.
https://addons.mozilla.org/en-US/firefox/addon/636

6) Tab Mix Plus - provides tabbed browsing enhancements. It includes such features as duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, plus much more. It also includes a full-featured session manager.
https://addons.mozilla.org/en-US/firefox/addon/1122

I haven't tried this, but BookmarkSync is another free bookmark synchronizer which supports even more browsers (opera, safari etc) and platforms.
http://en.wikipedia.org/wiki/BookmarkSync
http://en.wikipedia.org/wiki/Comparison_of_browser_synchronizers


Sunday, June 22, 2008

Got booted and can't sign back in to yahoo messenger?

Last night I had the same issue. I was in a chat room and someone booted me. Chat window closed and I was kicked out of messenger too (Y! 9 Beta). Since then I am not able to login to yahoo messenger with my id or any of the aliases. Tried searching in google, found no solutions. Tried using Trillian (http://www.ceruleanstudios.com/) and yahoo webmessenger (http://webmessenger.yahoo.com/), still can't login, both just hangs for ever when trying to login. When I try to login with the yahoo messenger, it logs me in for a second and show the buddy list, but quickly flicker and log out and tries to login again and goes to the same infinite loop. Tried YahELite(http://yahelite.org/), and it showed that someone is adding me as buddy and sending some variant, which I guess is exploiting some yahoo vulnerability. I tried reinstalling yahoo, and even logging in from a different machine, same issue. The same client works fine if I use a different yahoo id. Today I was able to fix it. In Internet Explorer, I cleared all temperory files, cache, cookies etc. Then in connection preferences of messenger, I changed it from "No proxies" to "Firewall with no proxies" and voila.. I'm in finally!! Hope it works for you too.... best wishes!

I hope yahoo will soon come up with some fix for the vulnerability... or your id is gone for a toss forever! All all the booters shall go to hell, Amen!

Friday, November 16, 2007

How to copy directories remotely in Linux

FTP/SFTP has commands like get and mget (put/mput) but they work only on a file or multiple files. Both commands cannot handle a directory. So how do you remotely copy a directory in linux, especially say between two Linux machines?

SCP - Secure Copy Protocol
To use the scp command to copy files between systems, use the following command:

scp filename1 userid@hostname:filename2

where filename1 is the file on the local system that you wish to copy, userid@hostname is the userid and hostname where you wish to copy it, and filename2 is the name you want to call the file on the remote system. For example:

scp /home/file1 root@mysystem.com:/root/file1

When you issue the command, you'll be prompted for the password on the remote system. You will then be given the stats of the transfer. Pay attention to the second item on the stat line; it's how much of the file got transferred (eg: 100%).

Note: SCP may also be used to copy files from a remote system to a local system. To do this in the first example above, reverse the order of filename1 and userid@hostname:filename2.

scp root@mysystem.com:/root/file1 /home/file1


To use the scp command to copy directories between systems, use the following command:

scp -r directoryname userid@hostname:directoryname2

where directoryname is the directory on the local system you wish to copy, userid@hostname is the userid and hostname where you wish to copy it, and directoryname2 is the name you want to call the file on the remote system. For example:

scp -r /home/ root@mysystem.com:/root/dir1

Note: SCP may also be used to copy directories from a remote system to a local system. To do this in the first example above, reverse the order of directoryname and userid@hostname:directoryname2.

scp -r root@mysystem.com:/root/dir1 /home/

How to increase the size of an existing VM - VMware

I created a new linux VM but it is set to a max of just 4GB. Once I started installing applications into it, soon my disk is full!! Tried using the VMware Server Console of VMware Server (a free VM hosting application and is much better than the VMware player). From the console you can change the Memory (RAM) in VM settings, but not hard disk size. Tried google and found the followings options:

1) Create a new clone/replica with increased disc size

2) Add another disc to the VM

3) Use the vdiskmanager command

I used the vdiskmanager command and following is the output:
D:\VM\linux_taddm>"C:\Program Files\VMware\VMware Server\vmware"-vdiskmanager -x 15GB linux_taddm.vmdk
Using log file C:\Users\admin\AppData\Local\Temp\vmware-admin\vdiskmanager.log
Grow: 100% done.
The old geometry C/H/S of the disk is: 522/255/63
The new geometry C/H/S of the disk is: 1958/255/63
Disk expansion completed successfully.

WARNING: If the virtual disk is partitioned, you must use a third-party utility in the virtual machine to expand the size of the partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647


It increased the size of the disc from 4GB to 15GB in couple of minutes!

















You may also want to see these:
http://www.vmware.com/support/reference/common/virtual_disks.html
http://communities.vmware.com/message/290776

How to clone a Linux VM - VMware

I had to create a new Linux virtual machine, and I wanted it to be similar to one of the existing Linux Servers (RHEL 4). A colleague of mine told to try the free software called 'VMware Converter'. It can create a virtual machine out of a physical machine. I downloaded it and gave it a try. But unfortunately it can convert only a windows based machine to VM. If you have a windows machine, it can remotely connect to that machine and create a VM for you, which would be like a clone of the physical machine (heard it takes a long time, perhaps running overnight might be a good idea). But I have to clone a linux machine, so what do I do???

Tried googling and came upon many options.

1) http://www.vmware.com/products/converter/faqs.html
Says that experimental support available for Linux-based physical to virtual machine conversions using the Vmware Converter BootCD (cold cloning) if the source physical machine has SCSI disks.
Also read: http://communities.vmware.com/thread/76266

This blog explains how to do the above:
http://virtualaleph.blogspot.com/2007/04/cloning-linux-machine-with-converter.html
It is a bit complex and you have to do a few configuration steps to get the VM running.

2) Using g4l, Ghost for Linux
http://www.windley.com/archives/2007/08/p2v_how_to_make_a_physical_linux_box_into_a_virtual_machine.shtml

3) P2V instructions for Linux
http://vmwiz.com/


All the above didn't seem quite viable. I tried creating a new VM using ESX Server, but when I powered up the VM it said "Missing operating system". I thought of cloning one of the other linux VMs in the ESX server, but you need 'Virtual Center" for that. Then suddenly the 'idea bulb' lighted and I remembered that VMware converter had an option to select a ESX server
as source. Voila!! so easy and I created a new virtual machine within a few minutes (took me just 10 mins)!!!




Tuesday, September 26, 2006

The Torrent World


BitTorrent is a peer-to-peer (P2P) file distribution protocol. Bittorrent is designed to distribute large amounts of data widely without incurring the corresponding consumption in costly server and bandwidth resources. Reports say that BitTorrent traffic accounts for ~35% of all traffic on the Internet now.

BitTorrent clients are programs which implement the BitTorrent protocol. To share a file through BitTorrent, clients first create a “torrent”. This is a small file which contains metadata about the files to be shared, and about the host computer that coordinates the file distribution. The .torrent files contain an “announce” section, which specifies the URL of the tracker, and an “info” section which contains (suggested) names for the files, their lengths, the piece length used, and a SHA-1 hash code for each piece, which clients should use to verify the integrity of the data they receive.

You need to install the BitTorrent client first to start downloading torrent files. These are some of the major clients: BitTorrent, Azureus (Java based, so multi-platform), BitComet etc. My favourite is BitComet. It has a preview feature which shows what are the contents of the torrent file and you can skip files if you don’t need it. For example, you are downloading a multi-disk 4GB game, and if you already have some of the disks with you, you can skip it and download only what you want. They recently added another feature called video preview, so now you can make sure the file you download is actually a video itself and it is what you wanted! Some times sick people share other files in pretext of video or you might get a fake one.

Once you download the client, you may want to go to a bitTorrent portal to start downloading the files. You can search these portals for torrent files and just click on them to start downloading. The actual downloading is not from the server, but from the P2P network. So you may want to check there is enough seeders for the torrent you are going to download. These are some good torrent portals: isoHunt, BitTorrent, TorrentSpy, mininova



Wednesday, September 13, 2006

Cygwin/X – The free X Client

You might have used Exceed or XManger as an X Window system for Microsoft Windows, to connect remotely to your X based OS (Unix, Linux, Solaris etc). But as you know, both XManager and Exceed are highly priced products ($200+ for an enterprise license)! So unless you spend top dollars, you were left out with only telnet/putty to access a linux/unix based system remotely. All though CLI (Command Line Interface) would be still a hot thing for the wanna be or so called geeks, it is neither user-friendly nor efficient. Why should you type from A-Z for everything when linux systems offer you the option of plenty of beautiful X Window systems starting from KDE to GNOME?

So here come the life saver. A free X Server for the windows platform, using which you can connect to any X based OS which offer XDMCP (X Display Manager Control Protocol) service. It is called Cygwin/X (http://x.cygwin.com/). Cygwin/X runs on all recent consumer and business versions of Windows, from Windows 95 to Windows Server 2003. Cygwin/X consists of an X Server, X libraries, and nearly all of the standard X clients, such as xterm, xhost, xdpyinfo, xclock, and xeyes. Cygwin/X has a modified GNU General Public License and the source code and binaries are freely available.

Quick Setup:
Cygwin/X is installed via Cygwin's setup.exe and the installation process is documented in the Cygwin/X User's Guide. Whether or not you already have Cygwin installed, you can add Cygwin/X to your installation by downloading the latest setup.exe, running setup, and selecting the 'xorg-x11-base' package from the 'X11' category. The default selection is 'Skip', click once to change. The dependencies of the package will be automatically selected. See the screenshot below.


(Note: The installer is around 60MB in size. So depending on your internet speed, it may take a while)

Quick How to:
Once installed, goto Windows Start -> Cygwin -> Cygwin Bash Shell
When the shell opens, type -> XWin -query [your machine name OR IP]



You should be seeing your login screen in a few seconds. Njoy!