how to install vim on linux

If you are using linux so you are very much familiar with vim editor. Here I will show how install vim editor on linux box using command line.

Some time when you are doing new setup of server like for linux distribution.  There is lot is coming cloud hosting and centos and fedora. My most favorite is fedora.

install vim on linux

how to install vim on linux
how to install vim on linux

If your OS does not have vim then use following command.


[root@siwan]# yum install vim-X11 vim-common vim-enhanced vim-minimal
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: hpc.arc.georgetown.edu
 * base: mirrors.netdna.com
 * extras: mirrors.greenmountainaccess.net
 * updates: mirror.cogentco.com
Setting up Install Process
Package 2:vim-X11-7.0.109-6.el5.i386 already installed and latest version
Package 2:vim-common-7.0.109-6.el5.i386 already installed and latest version
Package 2:vim-minimal-7.0.109-6.el5.i386 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.i386 2:7.0.109-6.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================================================================
 Package                                             Arch                                        Version                                                 Repository                                   Size
===========================================================================================================================================================================================================
Installing:
 vim-enhanced                                        i386                                        2:7.0.109-6.el5                                         base                                        1.2 M

Transaction Summary
===========================================================================================================================================================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
vim-enhanced-7.0.109-6.el5.i386.rpm                                                                                                                                                 | 1.2 MB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing     : vim-enhanced                                                                                                                                                                        1/1

Installed:
 vim-enhanced.i386 2:7.0.109-6.el5

Complete!

Following are the common commands for doing editing with vim editor.

#vim somefile

some keys

i – for insert the text

escape – going to back

:18 – for going to line no 18

:w –  write and save the file

:q! –  quit the file, without saving

:wq! –  saving and closing the file

shift +g – going to bottom of file

page up – page up

page down –  page down

How to remove www from URL with nginx server

Nginx web server is becoming most popular in these year. Best server response time and minimum execution time is the advantages of Nginx server. wordpress.com itself using the nginx server for hosting these sites and blogs.

How to remove www from URL with nginx server

How to remove www from URL with nginx server
How to remove www from URL with nginx server

How to remove www from URL with nginx server

Many people want to remove the www from URL. I will tell you the tip how to remove the www from URL with nginx server.

Open your Ngnix configuration file (nginx.conf). Just use following code in server block.

if ($host ~* ^www\.(.*)) {
    set $remove_www $1;
    rewrite ^(.*)$ http://$remove_www$1 permanent;
}

This code will remove the www from the URL.

Here are some useful article about nginx

How to use hosts file on Mac, Windows and Linux
Solved:trailing slash issue with Nginx server

How to remove the www from url with rewite rule

Now these days keeping www in URL is becoming old fashion. How can check many websites for that and the current example is twitter.com. Using apache rule you can remove the www from url with rewite rule.

How to remove the www from url with rewite rule

How to remove the www from url with rewite rule
How to remove the www from url with rewite rule

I specially dont like to put www in URL so we can easily remove the www from URL.

Open your apache configuration file. If you are using Linux then open file from following location

# vim /etc/httpd/conf/httpd.conf

put following lines in your virtual directory section.


# remove www from url
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301,L]

We can use this rewrite rule in .htaccess file also. But make sure .htaccess is enable through apache server.


# remove the www from URL.
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301s,L]

For WordPress websites for seo purpose putting above lines in .htaccess file is really best. That will gives you the really great result in future.

How to execute linux commands using php

Many times we need to run the linux commands using PHP language. We are going to give you code to, execute linux commands using php. This is my favorite question about PHP when I take an interview of new PHP developer.

execute linux commands using php
execute linux commands using php

In this article I will show you how to execute the linux command using PHP language syntax or script.

You can execute linux commands within a php script – all you have to do is put the command line in backticks (”) ,exec() , and shell_exec().

$command = exec('linux command');
echo $command;
echo shell_exec('ll');

Solved : Kill command is not working on linux or Fedora

Many times this issue is happened with me I tried the kill command to stop the process. Solved, Kill command is not working on linux.
But that is really not responding. For Example, following command executed but not worked.

Kill command is not working on linux

[siwan@siwank-pc ~]$ ps -ef|grep skype
siwan     3140     1  1 09:50 ?        00:04:46 skype
siwan    13857 13818  0 17:24 pts/1    00:00:00 grep skype
[siwan@siwank-pc ~]$ kill 3140

There are really very nice unix commands present in Linux like:

[siwan@siwank-pc ~]$ killall firefox

[siwan@siwank-pc ~]$ ps -ef|grep skype
siwan     3140     1  1 09:50 ?        00:04:46 skype
siwan    13857 13818  0 17:24 pts/1    00:00:00 grep skype

[siwan@siwank-pc ~]$ kill -9 3140

I specially like the kill -9 processid command. Using kill -9 on a process is like just hitting the power button on your running PC. You already know that powering off a running PC can damage your filesystem because of run-time inconsistent data, why would you do the same thing to your applications? You risk the _exact same_ data corruption.

Kill command is not working on linux
Kill command is not working on linux

How to setup Firefox Profile Manager on Fedora or Linux

How to set up Firefox Profile Manager on Fedora or Linux

Firefox has new functionality called Profile manager which will allow you to switch with multiple Users.
You can create many user profiles in Firefox and save that as per your choice.

setup Firefox Profile Manager on Fedora

Many times on same Firefox some user don’t want some addons or theme. That time we got some difficulties.
For avoiding this issue we can create the firefox profile in firefox.

In windows creating Firefox profile is very easy. Just open windows run window and type “firefox -P”. That sit!

You will see following screens.

Using this you can create the firefox profiles.

Now I am going to show you how to create the firefox profile in Fedora.

Open terminal and just type following command

[siwan@siwank-pc ~]$ /usr/lib/firefox-3.5.6/firefox -ProfileManager
[siwan@siwank-pc ~]$

setup Firefox Profile Manager on Fedora
setup Firefox Profile Manager on Fedora

See following screens.
Note: when you got “choose user profile” window. Don’t forget to uncheck the “Don’t ask startup” checkbox.

Note:  I am using the Fedora 11 here for this example.

How to set cron jobs in Linux

If you are programmer then you many times heard about cron jobs. Who are new in to programming or new about using cron jobs they always think, how schedule job in linux box.

How to set cron jobs in Linux

How to set cron jobs in Linux
How to set cron jobs in Linux

For many purpose we can use the cron jobs. Like sending emails, taking Mysql or database backup, taking file system backup or any other purpose.

What is Cron?

Cron is basically Linux program which will run on only windows.

Cron is a program that enables you to execute a command, or a script with a sequence of commands, at a specified date, time or at set intervals. The commands or scripts that you want cron to run are defined in a file called crontab, and every user has their own independent crontab file. Cron is a system program that is running all the time and is similar to the Windows scheduler which allows you to run commands/programs at predefined times and intervals.

We can pass following parameters to Cron file.

Minute = Minute of the hour, 00 to 59. * Will indicate every minute (details later)
Hour = Hour of the day in 24-hour format, 00 to 23. * Will indicate every hour (details later)
Day = Day of the month, 1 to 31. * Will indicate every day (details later)
Month = Month of the year, 1 to 12. * Will indicate every month (details later)
Day = Day of the week, 3 chars – sun, mon, tue, or numeric (0=sun, 1=mon etc)…. * Will indicate every day (details later)
Task = The command you want to execute

Now I will show you how to use the cron in Linux.

#su

#ROOT PASSWORD

#crontab -e

This will open the corn file from linux

Put you options in this file. For example

* * * * php  /var/www/html/project_name/script.php

Above script will fun after each minute.

00 18 * * php  /var/www/html/project_name/script.php

Above script will run at 6PM of day

More commands about crontab

#crontab -l

This will list cron file and all tasks which are present in cron file.

#crontab -r

This command will delete all cron jobs from cron file.

Using following command will show the all error log about cron file.

#tail -f /log/cron/error_log

install php and memcached server on centos5

In this article I given full step by step installation guide about php and memcached . Check full article for install php and memcached server on centos5.

install php and memcached server on centos5

What is Memcached?

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

install php and memcached server on centos5
install php and memcached server on centos5

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Please use following commands for installtion;
[root@ip-192-168-2-125 wordpressapi]# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-2.noarch.rpm

[root@ip-192-168-2-125 wordpressapi]# yum remove php-common

[root@ip-192-168-2-125 wordpressapi]# yum install php-pdo php-mcrypt squirrelmail php-pecl-apc php-xml php-gd php-devel php php-imap php-pgsql php-pear php-soap php-mbstring php-ldap php-mysql php-cli php-pecl-memcache

[root@ip-192-168-2-125 wordpressapi]# /etc/init.d/memcached restart
Shutting down Distributed memory caching (memcached): [ OK ]
Starting Distributed memory caching (memcached): [ OK ]

[root@ip-192-168-2-125 wordpressapi]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

[root@ip-192-168-2-125 wordpressapi]# vim /etc/php.ini
In php.ini file Please find the “extension=modulename.extension” words
Under that sentance please paste following line:
extension=memcache.so
Note: dont comments that line.

[root@ip-192-168-2-125 wordpressapi]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@ip-192-168-2-125 wordpressapi]#

how to install wine in fedora

Linux tutorial, As we wine is windows emulator for linux box. So many people thinking how to install the Wine package on Linux box.

how to install wine in fedora

how to install wine in fedora
how to install wine in fedora

That is so easy just follow my steps. Commands will look like as follows:

[root@kapilk-pc kapil]# yum install wine*
Loaded plugins: refresh-packagekit
Setting up Install Process
Package wine-tools is obsoleted by wine-core, trying to install wine-core-1.1.32-1.fc11.i586 instead
Resolving Dependencies
–> Running transaction check
—> Package wine.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-alsa.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-capi.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-cms.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-common.noarch 0:1.1.32-1.fc11 set to be updated
—> Package wine-core.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-desktop.noarch 0:1.1.32-1.fc11 set to be updated
—> Package wine-devel.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-docs.noarch 0:1.0-2.fc11 set to be updated
—> Package wine-esd.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-fonts.noarch 0:1.1.32-1.fc11 set to be updated
—> Package wine-jack.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-ldap.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-nas.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-openal.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-oss.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-pulseaudio.i586 0:1.1.32-1.fc11 set to be updated
—> Package wine-twain.i586 0:1.1.32-1.fc11 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

==================================================================================
Package Arch Version Repository Size
==================================================================================
Installing:
wine i586 1.1.32-1.fc11 updates 27 k
wine-alsa i586 1.1.32-1.fc11 updates 88 k
wine-capi i586 1.1.32-1.fc11 updates 31 k
wine-cms i586 1.1.32-1.fc11 updates 47 k
wine-common noarch 1.1.32-1.fc11 updates 86 k
wine-core i586 1.1.32-1.fc11 updates 14 M
wine-desktop noarch 1.1.32-1.fc11 updates 31 k
wine-devel i586 1.1.32-1.fc11 updates 2.7 M
wine-docs noarch 1.0-2.fc11 fedora 1.9 M
wine-esd i586 1.1.32-1.fc11 updates 41 k
wine-fonts noarch 1.1.32-1.fc11 updates 190 k
wine-jack i586 1.1.32-1.fc11 updates 43 k
wine-ldap i586 1.1.32-1.fc11 updates 94 k
wine-nas i586 1.1.32-1.fc11 updates 29 k
wine-openal i586 1.1.32-1.fc11 updates 41 k
wine-oss i586 1.1.32-1.fc11 updates 93 k
wine-pulseaudio i586 1.1.32-1.fc11 updates 50 k
wine-twain i586 1.1.32-1.fc11 updates 57 k

Transaction Summary
=========================================================================================
Install 18 Package(s)
Upgrade 0 Package(s)

Total download size: 19 M
Is this ok [y/N]: y
Downloading Packages:
(1/18): wine-1.1.32-1.fc11.i586.rpm | 27 kB 00:00
(2/18): wine-alsa-1.1.32-1.fc11.i586.rpm | 88 kB 00:00
(3/18): wine-capi-1.1.32-1.fc11.i586.rpm | 31 kB 00:00
(4/18): wine-cms-1.1.32-1.fc11.i586.rpm | 47 kB 00:00
(5/18): wine-common-1.1.32-1.fc11.noarch.rpm | 86 kB 00:00
(6/18): wine-core-1.1.32-1.fc11.i586.rpm | 14 MB 00:25
(7/18): wine-desktop-1.1.32-1.fc11.noarch.rpm | 31 kB 00:00
(8/18): wine-devel-1.1.32-1.fc11.i586.rpm | 2.7 MB 00:05
(9/18): wine-docs-1.0-2.fc11.noarch.rpm | 1.9 MB 00:02
(10/18): wine-esd-1.1.32-1.fc11.i586.rpm | 41 kB 00:00
(11/18): wine-fonts-1.1.32-1.fc11.noarch.rpm | 190 kB 00:00
(12/18): wine-jack-1.1.32-1.fc11.i586.rpm | 43 kB 00:00
(13/18): wine-ldap-1.1.32-1.fc11.i586.rpm | 94 kB 00:00
(14/18): wine-nas-1.1.32-1.fc11.i586.rpm | 29 kB 00:00
(15/18): wine-openal-1.1.32-1.fc11.i586.rpm | 41 kB 00:00
(16/18): wine-oss-1.1.32-1.fc11.i586.rpm | 93 kB 00:00
(17/18): wine-pulseaudio-1.1.32-1.fc11.i586.rpm | 50 kB 00:00
(18/18): wine-twain-1.1.32-1.fc11.i586.rpm | 57 kB 00:00
——————————————————————————————————————————–
Total 251 kB/s | 19 MB 01:18
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : wine-fonts-1.1.32-1.fc11.noarch 1/18
Installing : wine-docs-1.0-2.fc11.noarch 2/18
Installing : wine-core-1.1.32-1.fc11.i586 3/18
Installing : wine-pulseaudio-1.1.32-1.fc11.i586 4/18
Installing : wine-twain-1.1.32-1.fc11.i586 5/18
Installing : wine-capi-1.1.32-1.fc11.i586 6/18
Installing : wine-ldap-1.1.32-1.fc11.i586 7/18
Installing : wine-cms-1.1.32-1.fc11.i586 8/18
Installing : wine-openal-1.1.32-1.fc11.i586 9/18
Installing : wine-nas-1.1.32-1.fc11.i586 10/18
Installing : wine-esd-1.1.32-1.fc11.i586 11/18
Installing : wine-jack-1.1.32-1.fc11.i586 12/18
Installing : wine-oss-1.1.32-1.fc11.i586 13/18
Installing : wine-devel-1.1.32-1.fc11.i586 14/18
Installing : wine-alsa-1.1.32-1.fc11.i586 15/18
Installing : wine-common-1.1.32-1.fc11.noarch 16/18
Installing : wine-desktop-1.1.32-1.fc11.noarch 17/18
Installing : wine-1.1.32-1.fc11.i586 18/18

Installed:
wine.i586 0:1.1.32-1.fc11 wine-alsa.i586 0:1.1.32-1.fc11 wine-capi.i586 0:1.1.32-1.fc11 wine-cms.i586 0:1.1.32-1.fc11 wine-common.noarch 0:1.1.32-1.fc11 wine-core.i586 0:1.1.32-1.fc11
wine-desktop.noarch 0:1.1.32-1.fc11 wine-devel.i586 0:1.1.32-1.fc11 wine-docs.noarch 0:1.0-2.fc11 wine-esd.i586 0:1.1.32-1.fc11 wine-fonts.noarch 0:1.1.32-1.fc11 wine-jack.i586 0:1.1.32-1.fc11
wine-ldap.i586 0:1.1.32-1.fc11 wine-nas.i586 0:1.1.32-1.fc11 wine-openal.i586 0:1.1.32-1.fc11 wine-oss.i586 0:1.1.32-1.fc11 wine-pulseaudio.i586 0:1.1.32-1.fc11 wine-twain.i586 0:1.1.32-1.fc11

Complete!
[root@kapilk-pc kapil]#

have fun!

Rails 3 beta by February

Rails 3 beta by February, Ruby on Rails 3, an upgrade to the popular Web development framework that merges Rails with the alternative Merb framework, is due to be offered as a beta release by the end of this month.

ruby_on_rails_logo
Rails 3 beta by February, Ruby on Rails 3, an upgrade to the popular Web development framework that merges Rails with the alternative Merb framework, is due to be offered as a beta release by the end of this month.

Rails 3 beta by February

According to David Heinemeier Hansson, the founder of the Ruby based web development framework, although a beta of Rails 3 is expected by the end of this month the release may slip into February. Hansson gave the estimated release timing in an article on InfoWorld. If all goes to plan Rails 3 is expected to arrive in the first quarter of this year. Rails 3 is a major reworking of the framework which sees ideas from the alternative Merb framework being integrated in a development process which began in December 2008.

Source Articles

http://www.engineyard.com/blog/2009/my-five-favorite-things-about-rails-3/