| Working with files | |
| Vim command | Action |
| :e filename | Open a new file. You can use the Tab key for automatic file name completion, just like at the shell command prompt. |
| :w filename | Save changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name. |
| :q | Quit Vim. If you have unsaved changes, Vim refuses to exit. |
| :q! | Exit Vim without saving changes. |
| :wq | Write the file and exit. |
| :x | Almost the same as :wq, write the file and exit if you've made changes to the file. If you haven't made any changes to the file, Vim exits without writing the file. |
| Moving in the file | |
| These Vim commands and keys work both in command mode and visual mode. | |
| Vim command | Action |
| j or Up Arrow | Move the cursor up one line. |
| k or Down Arrow | Down one line. |
| l or Right Arrow | Right one character. |
| h or Left Arrow | Left one character. |
| e | To the end of a word. |
| E | To the end of a whitespace-delimited word. |
| b | To the beginning of a word. |
| B | To the beginning of a whitespace-delimited word. |
| 0 | To the beginning of a line. |
| ^ | To the first non-whitespace character of a line. |
| $ | To the end of a line. |
| H | To the first line of the screen. |
| M | To the middle line of the screen. |
| L | To the the last line of the screen. |
| :n | Jump to line number n. For example, to jump to line 42, you'd type :42 |
| Inserting and overwriting text | |
| Vim command | Action |
| i | Insert before cursor. |
| I | Insert to the start of the current line. |
| a | Append after cursor. |
| A | Append to the end of the current line. |
| o | Open a new line below and insert. |
| O | Open a new line above and insert. |
| C | Change the rest of the current line. |
| r | Overwrite one character. After overwriting the single character, go back to command mode. |
| R | Enter insert mode but replace characters rather than inserting. |
| The ESC key | Exit insert/overwrite mode and go back to command mode. |
| Deleting text | |
| Vim command | Action |
| x | Delete characters under the cursor. |
| X | Delete characters before the cursor. |
| dd or :d | Delete the current line. |
| Entering visual mode | |
| Vim command | Action |
| v | Start highlighting characters. Use the normal movement keys and commands to select text for highlighting. |
| V | Start highlighting lines. |
| The ESC key | Exit visual mode and return to command mode. |
| Editing blocks of text | |
| The Vim commands marked with (V) work in visual mode, when you've selected some text. The other commands work in the command mode, when you haven't selected any text. | |
| Vim command | Action |
| ~ | Change the case of characters. This works both in visual and command mode. In visual mode, change the case of highlighted characters. In command mode, change the case of the character uder cursor. |
| > (V) | Shift right. |
| < (V) | Shift left. |
| c (V) | Change the highlighted text. |
| y (V) | Yank the highlighted text. In Winblows terms, "copy the selected text to clipboard." |
| d (V) | Delete the highlighted text. In Winblows terms, "cut the selected text to clipboard." |
| yy or :y or Y | Yank the current line. You don't need to highlight it first. |
| dd or :d | Delete the current line. Again, you don't need to highlight it first. |
| p | In Winblows terms, "paste" the contents of the "clipboard". In Vim terms, you "put" the text you yanked or deleted. Put characters after the cursor. Put lines below the current line. |
| P | Put characters before the cursor. Put lines above the current line. |
| Undo and redo | |
| Vim command | Action |
| u | Undo the last action. |
| U | Undo all the latest changes that were made to the current line. |
| Ctrl + r | Redo. |
| Search | |
| Vim command | Action |
| /pattern | Search the file for pattern. |
| n | Scan for next search match in the same direction. |
| N | Scan for next search match but opposite direction. |
| Replace | |
| Vim command | Action |
| :rs/foo/bar/a | Substitute foo with bar. r determines the range and a determines the arguments. |
| The range (r) can be | |
| nothing | Work on current line only. |
| number | Work on the line whose number you give. |
| % | The whole file. |
| Arguments (a) can be | |
| g | Replace all occurrences in the line. Without this, Vim replaces only the first occurrences in each line. |
| i | Ignore case for the search pattern. |
| I | Don't ignore case. |
| c | Confirm each substitution. You can type y to substitute this match, n to skip this match, a to substitute this and all the remaining matches ("Yes to all"), and q to quit substitution. |
| Examples | |
| :452s/foo/bar/ | Replace the first occurrence of the word foo with bar on line number 452. |
| :s/foo/bar/g | Replace every occurrence of the word foo with bar on current line. |
| :%s/foo/bar/g | Replace every occurrence of the word foo with bar in the whole file. |
| :%s/foo/bar/gi | The same as above, but ignore the case of the pattern you want to substitute. This replaces foo, FOO, Foo, and so on. |
| :%s/foo/bar/gc | Confirm every substitution. |
| :%s/foo/bar/c | For each line on the file, replace the first occurrence of foo with bar and confirm every substitution. |
Thursday, February 19, 2009
VIM Cheat Sheet
Lex and Yacc Installation with Cygwin
$ bison --versionbison (GNU Bison) 1.875b
$ flex --versionWednesday, February 18, 2009
Run Your Personal wiki from a USB Stick
You don't have to lease server space or keep your home computer always on to access a personal web server—you can run a web, FTP, and database server straight from a USB drive. A slim web server package called XAMPP fits on a USB stick and can run database-driven webapps like the software that powers Wikipedia, MediaWiki. Almost two years ago you learned how to set up your "personal Wikipedia" on your home web server to capture ideas and track document revisions in a central knowledge repository. Today we'll set up MediaWiki on your flash drive for access on any Windows PC on the go.
A word on security: The XAMPP web server package is intended for web developers to use while building web sites, so by default, the passwords are blank and configuration is not secure. Running server software opens up a port on your computer, which in and of itself is a security risk. Getting this set up requires getting your hands dirty editing configuration files. If you're not comfortable with the risks and implications of this solution but still want your own wiki, I highly recommend the free, hosted, PBWiki. Also check out the nifty TiddlyWiki for a less setup-intensive wiki-on-a-thumb-drive alternative.
Still with me? Let's get your personal wiki running on a thumb drive.
What You'll Need
In order to get your personal Wikipedia running on your thumb drive, you'll need:
- A Windows XP PC with Service Pack 2 or Windows Vista Ultimate
- A thumb drive with at least 150MB free. The bigger your drive, the more data you can store on it so go as big as you can here.
Install and Start XAMPP
Download the XAMPP Lite .EXE installer from here. Double-click on the file to extract it, and choose your flash drive's drive letter as the destination (not a subfolder.) A folder called xampplite will be created on your thumb drive.
(Note: I chose XAMPP Lite because it offers everything we need to run MediaWiki, and it's smaller in size than XAMPP. But XAMPP is updated more often than XAMPP Lite, and you can install add-ons with full-on XAMPP, so it may be a consideration if you want to do more than just run MediaWiki on your thumb drive.)
Once XAMPPLite is saved to your flash drive, to start it up, double-click on the xampp-control.exe file in the xampplitedirectory. That will launch XAMPP's Control Panel, which lets you start all the services you need.
To run MediaWiki, you need two services: Apache web server, and the MySql database server. Click the Start button next to each of those in the XAMPP Control Panel, as shown.
When you hit the Start button, your system's firewall may ask whether or not it should allow incoming and outgoing connections to the software. Allow it.
Now your portable web server is up and running. To see it in action, in your web browser, visit http://localhost/. Click on your language of choice—by default, XAMPP Lite's English homepage looks like this.
The first thing we want to do is set up a few passwords to secure your servers. Click on the "Security" link on the sidebar (by default, located at http://localhost/security/. You'll see that by default, all of XAMPP's settings are marked as insecure. Click on the link below the security table to "fix" the problems (by default, http://localhost/security/xamppsecurity.php.) On this next page, set your MySql database password for the root user. If you choose, you can set a password for visiting any web page as well, as shown.
To enable the new MySQL password, switch to the XAMPP Control Panel, stop MySql, and start it again.
Install and Configure MediaWiki
Now that your web and database server is up and running, it's time to install the MediaWiki wiki software. Download the latest version of MediaWiki from here (as of this writing, the file name is mediawiki-1.11.1.tar.gz.) Extract the files (first gunzip, then tar, the free 7-Zip utility can do this for you), and by default they'll be stored in a folder called mediawiki-1.11.1. Rename this folder simply wiki and move it to your thumb drive in XAMPP's xampplite\htdocs\ folder. When you're done, if your thumb drive's letter is G:\, the full path to the MediaWiki files would beG:\xampplite\htdocs\wiki\.
To configure MediaWiki, visit http://localhost/wiki/. Click on the link to configure your wiki. There you can keep all the default settings except:
- You must enter the name of your wiki. Mine is "GinaWiki."
- You must enter a wiki administrator name (by default, WikiSysop) and password.
- Enter your database information. The database name can stay wikidb, but change the DB username to root and enter the password you set up above.
Scroll to the bottom of the page and click on the "Install MediaWiki!" button to save your settings. When the installation is complete, MediaWiki will prompt you to move the LocalSettings.config.php file up a directory on your thumb drive. Go ahead and do that. You're moving the file fromG:\xampplite\htdocs\wiki\config\LocalSettings.php
toG:\xampplite\htdocs\wiki\LocalSettings.php.
Finally, visit http://localhost/wiki/ to see your fresh new MediaWiki installation in action, as shown below. Congratulations!
From here you can start editing and adding pages, creating user accounts and even uploading files to your new wiki.
But first, two helpful customizations will make your new wiki easier to use.
- Make your wiki the default start page. When you visit your local server, you might want your wiki's home page to appear first instead of XAMPP's homepage. To do that, open the
index.phpfile in XAMPP'shtdocsdirectory in a text editor. Change the line that reads:header('Location: '.$uri.'/xampp/');toheader('Location: '.$uri.'/wiki/');and save it. Now, when you visit http://localhost/, you'll go directly to your wiki. - Add a custom wiki logo. To add your own logo to the upper left hand side of your wiki install, create a 135x135 pixel image, name it
mywikilogo.png, and save it toH:\xampplite\htdocs\wiki\skins\common\imageswhere H: is your thumb drive's letter. Then, open theH:\xampplite\htdocs\wiki\LocalSettings.phpfile in a text editor and add the following line:$wgLogo = "/wiki/skins/common/images/mywikilogo.png";Save the file, and refresh your wiki in the browser. You should now see your custom logo. (Note: the logo doesn't have to be a PNG file; substitute your image's extension, like JPG or GIF.)
Stopping and Starting Your Wiki
When you're finished using your wiki, invoke the XAMPP Control Panel running in your system tray. Click the Stop button next to Apache, then click the Stop button next to MySql. Once the servers have stopped, click the Exit button. You can now eject your thumb drive as usual. Remember: don't try to eject your thumb drive before stopping the services; doing so can blue screen your PC and possibly screw up your wiki and server installation.
To start up your wiki at a new computer, plug in your thumb drive, and double-click on the xampp-control.exe file to start the Control Panel. From there, start the Apache and MySql servers, then visit http://localhost/ to edit your wiki.
Why a personal Wikipedia?
A wiki is an incredible collaborative tool for groups of people, but it's also a great one-stop shop for your own personal "stuff I want to remember"—like ideas, drafts, lists, and bookmarks. If you haven't edited Wikipedia or just want to see what MediaWiki can do, here's a quick demonstration of what writing a novel draft would be like using the software and its specialWikitext markup.
More Portable Web Servers
XAMPP isn't the only portable web server on the block. Another free portable server package called Server2Go includes Perl 5.8. Thanks, Vijay!
What do you do with your key chain web server? Let us know in the comments.
Ref :-
Gina Trapani, the editor of Lifehacker, likes her web servers tiny and portable. Her weekly feature, Geek to Live, appears every Monday on Lifehacker. Subscribe to the Geek to Live feed to get new installments in your newsreader.
Tuesday, February 17, 2009
How to check free disk space on a linux server /how to check reaming space on hdd
Monday, February 16, 2009
Microsoft DOS tree command
Allows the user to view a listing of files and folders in an easy to read listing.
Syntax
TREE Drive:\ Path /f /a
| Drive:\Path | Drive and directory containing disk for display of directory structure. |
| /f | Displays file names in each directory. |
| /a | ext characters used for linking lines, instead of graphic characters. /a is used with code pages that do not support graphic characters and to send output to printers that do not properly interpret graphic characters. |
tree
List a tree listing of the current drive. Below is a basic example of what a directory may look like.
C:.
├───Common
├───Director
├───Flash
├───Shockwave 8
│ ├───DswMedia
│ ├───Prefs
│ └───Xtras
└───update
HOWTO for running VNCserver on Linux
Why use VNCserver?
In Linux, everything can be done from a shell. However, there may be a time when you need to access the machine as if you were at the console.Getting Started
You will need several things to get started:- root privledges
- VNC client software (tightVNC, you can download it here.)
- A good password!
[root@roswell etc]# service vncserver start Starting VNC server: [ OK ] [root@roswell etc]# [root@roswell etc]# vncpasswd Password: Verify: [root@roswell etc]# [root@roswell etc]# vncserver New 'roswell:1 (root)' desktop is roswell:1 Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/roswell:1.log [root@roswell etc]#So what did we do there? First, we started the vncserver service. It may or may not have already been running on your system. Next we set a password to access the VNC desktop. When you set the password, you will not see any characters on the screen, and you must enter the password twice. You will only need to do this the very first time you run vncserver. The password will be saved in the Linux filesystem, and you can change it at any time by invoking thevncpasswd command again. Last, to activate the VNC desktop, we simply invoked the vncserver command. Notice the output; the desktop is named "roswell:1" which can also be replaced via the machines IP address.
Connecting
Assuming you already installed TightVNC or another VNC client, enter the desktop name:You can replace the server name with an IP address if you are logging in from outside your LAN. Remember, if you are using NAT port 5900 must be forwarded to your VNCserver.
Upon successful connection, you will be prompted for a password. You will then see a terminal screen that will allow you to execute commands:
VNCserver in Runlevel 5 (KDE or Gnome)
If you are new to linux, running VNC server with a terminal isn't going to do you much good. You might want to have a menu-driven GUI like Windows. No problem. Follow these steps:First, we are going to assume that VNCserver is running under the root user, as shown with the example above. For this example, I will be editing my VNCserver to enter Gnome. You can specify a KDE desktop if you have KDE installed on your server. Make sure you are in the root directory.
[root@roswell ~]# ls -a . cacti-0.8.6c.tar.gz .gnome2_private .lftp queue.dat temp .. client.cfg .gnupg machinedependent.dat .recently-used Templates .config FAHlog-Prev.txt .gstreamer-0.8 .metacity .rhn-applet.cache .themes .cshrc FAHlog.txt .gtkrc .mozilla .rhn-applet.conf .thumbnails .bash_history Desktop .fonts.cache-1 .gtkrc-1.2-gnome2 .rnd .Trash .bash_logout .dmrc .gconf .ICEauthority .mysql_history scripts .bash_profile .eggcups .gconfd .icons .nautilus .sh_history .viminfo .bashrc .bashdevl .esd_auth .gnome php-4.11 .ssh .vnc cacti-0.8.6c .gnome2 install.log [root@roswell ~]# cd .vnc [root@roswell .vnc]# ls passwd roswell:1.pid roswell:2.pid roswell:3.pid roswell:4.pid roswell:5.pid roswell.area51.lan:1.pid roswell:1.log roswell:2.log roswell:3.log roswell:4.log roswell:5.log roswell.area51.lan:1.log roswell.area51.lan:2.log xstartup [root@roswell .vnc]# vi xstartup
Using vi (vim) to edit the xstartup file, make sure your file matches this one:
#!/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" & startx &
Notice that the last line is "startx &" as this command will launch Gnome upon login via VNCserver. If you are using a KDE desktop, the line "startkde &" should replace the last line.
Logging in, you will be presented with a Gnome or KDE desktop.
Shown above is a Gnome desktop on Red Hat Enterprise Linux 4.
Friday, February 13, 2009
FireFox AddOn For Twiki Editing
- Open the firefox
- Open about:config in the URL
- Click on the "I will be careful, I promise !"
- Right click , when menu pops up select New >Boolean
- Enter name as extensions.checkUpdateSecurity
- Click OK
- select False as the value
- Click OK
- Close firefox
- Open firefox
- Save the twikiAddOn to your computer from the bottom of this page
- Open the plug-in using open file from file menu. or just drag and drop the saved plug-in in firefox
- Restart firefox
Saturday, February 7, 2009
Using webcam on linux \ video chatting \ yahoo video chatting
Resolving an odd dpkg error in Ubuntu \ dpkg: ../../src/packages.c:191: process_queue: Assertion `dependtry <= 4' failed
in my case it was gxine player which got crashed while updating.
you can check which program is giving the problem by the following
mihir3445@mihir3445-laptop:~$ sudo dpkg -l | grep -v ^ii
Desired=Unknown/Install/
| Status=Not/Inst/Cfg-files/
|/ Err?=(none)/Hold/Reinst-
||/ Name Version Description
+++-==========================
rc amarok 2:1.4.10-0ubuntu3 versatile and easy to use audio player for K
rc amarok-common 2:1.4.10-0ubuntu3 architecture independent files for Amarok
rc bgchanger 0.9-1 Wallpaper Switcher
iF gxine 0.5.903-2ubuntu2 the xine video player, GTK+/Gnome user inter
rc libgd2-noxpm 2.0.36~rc1~dfsg-3ubuntu1 GD Graphics Library version 2 (without XPM s
rc libifp4 1.0.0.2-3 communicate with iRiver iFP audio devices
rc libnjb5 2.2.5-4.2ubuntu1 Creative Labs Nomad Jukebox library
rc libtunepimp5 0.5.3-7ubuntu3 MusicBrainz tagging library
rc libxalan2-java-gcj 2.7.1-2 XSL Transformations (XSLT) processor in Java
iU libxine1 1.1.15-0ubuntu3.1 the xine video/media player library, meta-pa
iU libxine1-all-plugins 1.1.15-0ubuntu3.1 the xine video/media player library, meta pa
iW libxine1-bin 1.1.15-0ubuntu3.1 the xine video/media player library, binary
iU libxine1-console 1.1.15-0ubuntu3.1 libaa/libcaca/framebuffer/
iU libxine1-ffmpeg 1.1.15-0ubuntu3.1 MPEG-related plugins for libxine1
iU libxine1-gnome 1.1.15-0ubuntu3.1 GNOME-related plugins for libxine1
iU libxine1-misc-plugins 1.1.15-0ubuntu3.1 Input, audio output and post plugins for lib
iU libxine1-plugins 1.1.15-0ubuntu3.1 the xine video/media player library, meta pa
iU libxine1-x 1.1.15-0ubuntu3.1 X desktop video output plugins for libxine1
rc libxmmsclient-glib1 0.5DrLecter-2ubuntu1 XMMS2 - glib client library
rc linux-restricted-modules-2.6.
rc myspell-en-us 1:2.4.0-2ubuntu4 English_american dictionary for myspell
you can see iF,iU etc... which shows that gzine was not installed properly.
so, to fix this problem you just need to execute following command line argument.
sudo dpkg --purge remove gxine
which means remove gzine packet and uninstall the program.
then you can check if the following command gives you responce or not.
sudo dpkg --configure -a
it should work normally...
Hope this helps.
Leave your comments..........
- Mihir Patel.
=============================================================================================
The post that i found useful on this topic is following
http://techxplorer.com/2006/05/21/resolving-an-odd-dpkg-error-in-ubuntu/
=============================================================================================
Since my last post about running the Ubuntu Dapper Drake Beta on a virtual machine using the VMware Server Beta, I've not experienced any major issue. Which is great. The only truly odd issue I've had recently is that I've been getting the following error from the dpkg program when I use apt-get or synaptic to install a package.
dpkg: ../../src/packages.c:191: process_queue: Assertion `dependtry <= 4' failed
.
E: Sub-process /usr/bin/dpkg exited unexpectedly
The problem was I didn't know which package this error applied to, simply because all of the packages appeared to be installed correctly. Any package that I installed after I noticed this error seemed to be installing fine, I was able to use them for example, and yet the error persisted. Not being one to sit by and let errors just happen I did some exploring.
After a lot of digging via Google and the Ubuntu Forums I was able to use this command to locate the offending package:
sudo dpkg -l | grep -v ^ii
The "dpkg -l" part of the command lists all of the installed packages in a table format. The first column of the table outlines the status of the package, for example if it is installed correctly etc. The second part of the command "grep -v ^ii" outputs any line that does not start with the letters ii. By passing the output of the "dpkg -l" command to the grep command I was able to get a list of all packages that were listed as not being correctly installed. That is, those packages that didn't have a status of "ii". I was then able to use this command to remove the offending package where [package-name] was the name of the package.
sudo dpkg --purge remove [package-name]
Now I don't get the odd error any more and it is resolved. While using synaptic and other GUI clients to install packages is great. Sometimes knowing a little about the underlying programs can be very useful. It is also worth noting that the Ubuntu Forums are truly invaluable.