Tuesday, December 21, 2010

How to know free memory on linux

Command to know free memory on Linux/Unix machines

$ free -m

It will show you status in MB. You can optionally use other filters as well

-b switch displays the amount of memory in bytes

-k switch (set by default) displays it in kilobytes

-m switch displays it in megabytes.

-t switch displays a line containing the totals.

-o switch disables the display of a "buffer adjusted" line. If the -o option is not specified, free subtracts buffer memory from the used memory and adds it to the free memory reported.

-s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times.

You can also use /proc/meminfo to see the current status of memory

$ cat /proc/meminfo

Sphere: Related Content

Sunday, December 12, 2010

Create subversion repository on Ubuntu

Recently I had to setup a ubuntu box with subversion on it. I had to also provide web access from subversion with authentication. After few hiccups I managed to do this with installing few packages and configuring them.

Step 1: login to your ubuntu box

#ssh root@x.y.z.t

Step 2: Install required packages
#yum install subversion
#yum install mod_dav_svn httpd

Step 3: Create a parent directory where all your repositories will be set up.
#mkdir -p /srv/svn

Step 4: Create a sample repository using svnadmin tool
#svnadmin create /srv/svn/app
In this step we have created a repository named as app.

Step 5: Change the user and group of the created app repository to give the permission to apache user.
#chown -R apache.apache /srv/svn/app
This user is created when you installed httpd package in step 2. Without this step user will not be able to access it via webserver http protocal, they can however access it using command promp using ssh protocol.

Step6: Restart apache webserver.
#service httpd restart

Step 7: Create a password file for the authentication of users which will be accessing your app repository via http protocol.
#mkdir -p /srv/auth/svn/
#htpasswd -c /srv/auth/svn/app.htpasswd ahsan.javed
In this step we are creating a directory first to store the htpasswd file. then using the htpasswd tool we are creating an user name and password hash entry in created file. This htpasswd tool is by default installed when you perform step 2.

Step 8: Create a virtual host for hosting your subversion access
create a new virtual host file at /etc/httpd/conf.d/svn.conf with the content

    LoadModule dav_svn_module     modules/mod_dav_svn.so
    LoadModule authz_svn_module   modules/mod_authz_svn.so

    <Location /repos>
       DAV svn
       SVNParentPath /srv/svn
    </Location>
    <Location /repos/app>
       AuthType Basic
       AuthName "Subversion Repository"
       AuthUserFile /srv/auth/svn/app.htpasswd
       Require valid-user
    </Location>

Step 9: Restart apache webserver
#service httpd restart


Step 10: Access your setup repository in a browser by typing
http://x.y.z.t:80/repos/app
This will ask a user name and password, provide the username and password created in step 7 to access the repository.

Sphere: Related Content

Thursday, December 9, 2010

Enable mysql to connect from desired remote IP

Recently I had to work on mysql server on Linux platform.

All our development was done on windows machine and everything went fine.

When we tried to migrate the same code to Linux platform, everything worked fine except that our program was not able to connect to mysql. It was continuously throwing this exception.

Caused by: java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at java.net.Socket.connect(Socket.java:478)
        at java.net.Socket.(Socket.java:375)
        at java.net.Socket.(Socket.java:218)
        at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:254)
        at com.mysql.jdbc.MysqlIO.(MysqlIO.java:292)

However we were able to connect via mysqladmin as follows


#mysql -u username -h localhost -p password


After doing some google I found that mysql was actually not allowing remote connections from our program. It was only allowing the Unix socket connections in case of mysql admin, thats why it was able to connect to it.

I had to change few configuration parameters in mysql configuration files as follows to allow remote connections to mysql and restart it.

# vi /etc/my.cnf
Once file opened, locate line that read as follows

[mysqld]

Add the following line at the end of this block

bind-address=YOUR-SERVER-IP
#skip-networking


Where,

    * bind-address : IP address to bind to.
    * skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should be removed from my.cnf or put it in comment state

Restart the mysql server, enter:
# /etc/init.d/mysql restart

Sphere: Related Content

Wednesday, November 24, 2010

How to know which port is blocked by which process on Windows?

Recently I was trying to use my apache server for my web development. However every time, I tried it showed me that port 80 is being used already. So I took a dig and found out the solution as follows.

C:\>netstat -aon | findstr 0.0:80
-a means list all active connections and their ports. -o means include their process IDs. -n means display the port numbers numerically.

I got this output.
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4504

It means that process 4504 is currently listening on port 80. So to start apache on this default port we need to kill this process, you can do it by Task Manager and find process by the id 4504 and kill that process.

You can also identify the process by using command line as follows.
C:\>tasklist | findstr 4504 

I found that skype is using the port 80.
Skype.exe  4504 Console 1 107,170K

So we need to kill the process as follows.
taskkill /F /PID 4504


Now we can start apache as usual. Even if we start skype again it will work, I think it choses some other random port this time.

Sphere: Related Content

Thursday, October 28, 2010

Facebook Page for GreenDeewali

This is the page for Green Deewali.
http://www.facebook.com/pages/Green-Deewali/100290780040511?v=app_4949752878

Please visit, this is very nice initiative to make environment greener and cleaner.

Sphere: Related Content

A nice initiative by webshrub to make environment cleaner

Web shrub has launched a new initiative to make environment greener and cleaner.
Please have a look at their another web site Green Deewali and take a pledge this year.

http://www.greendeewali.com/take-pledge.html

Sphere: Related Content

Friday, June 11, 2010

Helpful Tips And Tricks: My letter to Airtel...

Facebook page for my problem.

Sphere: Related Content

Thursday, June 10, 2010

My letter to Airtel...

My letter to Airtel...

Hi,
I have been facing problems with my internet connection for last 5 days.

Earlier they told me that my DSL link was not stable and they registered my complaint with service request no 33593502.

They told me that this problem will be resolved soon. However when I tried it after a day time, I found that they have closed the ticket without taking any appropriate action.

After that, I fisrt contacted Mr. Sachin Purti(Backend Admin) 0120-4367827 and he said that it will be resolved by few hours. Nothing happened. Some guy visited me and he told me that he cannot do anything in this regard as that was fault with my main line MDF and the guy responsible for maintenance of it was on leave so it could not be fixed at that time as well. They however gave me one more SRN 33635706.

Then I contacted Mr. Yadvendra Kumar Yadav (09810184236) Sector 18 Noida, who said that the problem will be fixed by a day time. I again waited for a day but was not able to get any positive response. My internet connection was still not up, however my DSL Link problem was gone automatically. Fixing the initial DSL problem took them 3 days to fix. 

After not getting any resolution to my problem for 4 days I contacted Mr Ali Afsar (Escalation Supervisor at Bhopal Centre) who assured me that my problem will be resolved on 5th day. However I still dont see that my problem is getting resolved any soon. 

I have been very disappointed by Airtel service and seeing such service to customers, I am sure that it will be MOST DESPISED BRAND despite of Sunil mittal's vision to be the most admired brand by 2010. Your services is just HORRIBLE...! no other service provider can beat this!! Airtel will be crowned the Worst service provider for years to come...!

If this problem is not going to be fixed in near future I am going to take some drastic action and that will of course not be going to consumer forum rather than I will tarnish your brand image via powerful internet/social network media.

 Thanks
A customer who has been tortured by Airtel.

Sphere: Related Content

Wednesday, March 17, 2010

Managing content with Role and Permissions in dotCMS

In my previous post I mentioned how to create a blog site using templates, containers and contents in dotCMS. After the site has been created you need to add posts to it so that it can go publishing all its posts.

By default the content created contains the permissions of their parent structure. However in most of the cases it is required to give certain permissions to certain group of users/roles. In our case we will create a user mysiteuser and assign it a group mysitegroup. We will also create a role called mysiterole and this role will be granted to mysitegroup.

Using this as an example we will allow users having mysiterole only to add content/post to the blog just created.

1. Add New Role
Click on CMS Admin link and chose New -> Role from the drop down. This will lead to a screen where you can add a new role named as mysiterole.

2. Add New Group

Click on CMS Admin link and chose New -> Group from the drop down. This will lead to a screen where you can add a new group named as mysitegroup.

3. Add New User
Click on CMS Admin link and chose New -> User from the drop down. This will lead to a screen where you can add a new user named as mysiteuser by filling all its details.

4. Assign Role to mysiteuser.
Click on CMS Admin link and chose Users. This will show a screen containing search button. Click on Search button. It will populate the newly created user mysiteuser. Select the user and click on User Roles tab from the screen. Now there will be a screen showing available and current roles.
Chose CMS User Role from Available to Current list. This role is important because of this is the parent role of all dotCMS editing roles.  
5. Assigning Group to mysiteuser.
Click on CMS Admin link and chose Users. This will show a screen containing search button. Click on Search button. It will populate the newly created user mysiteuser. Select the user and click on User Groups tab from the screen. Now there will be a screen showing available and current group.
Chose CMS Users group from Available to Current list. 

6. Adding Role mysiterole to mysitegroup.
Click on CMS Admin link and chose Permissions -> Groups. This will show a screen containing newly created group mysearchgroup in the left side. Click on mysitegroup. It will enable few options downwards. Click on Edit Roles button. It will open a screen containing available and current roles for th group. Select mysiterole from the available list and click update button.

7. Editing pages for the role
Click on CMS Admin link and chose Permissions -> Groups. This will show a screen containing newly created group mysearchgroup in the left side. Click on mysitegroup. It will enable few options downwards. Click on Edit Pages button. It will populate a screen as follows.

Inside the Add New Page text box write the name of content "Content" and click on Update Page Settings button. It will now reflect a new screen downwards as follows.

Click on Selected Page "Content" from the drop down  menu and click on Content Management link under categories tab. Now select Content Search Manager(n) from the list of checkboxes. Click on Update Content Settings button to make changes permanent.

8. Change the permissions of Blog structure.
Click on Structures link and chose structures. This will show a screen containing all structures. Click on Blog. Then click on Permissions tab and check mysiterole and CMS Anonymous role under View column.


9. Change the permission of the Blog Entry structure.
Click on Structures link and chose structures. This will show a screen containing all structures. Click on Blog Entry. Then click on Permissions tab and check View, Modify and Publish permissions to mysiterole. Also give View permission to CMS Anonymous role.

This now completed the assigning permissions and role to a blog site. Now only user mysiteuser will be able to create a blog post when logged into the system. After you login to the system as mysiteuser it will look like as follows.

By clicking on Add New Content and selecting Blog Entry from the drop down you will be able to go to following screen where you can write your contents of post.
After you are done with writing your changes, you need to relate this blog post with one of the blogs. You can do it by going to relationship tab and clicking on Relate Content button. This will populate a search screen. You need to search for the relevant blog and relate content.

Sphere: Related Content

Creating a blog Site with dotCMS(A Open Source Java CMS)

In my organization I had to create a blog site for one of my International team. The obvious options were to chose from vast range of PHP based CMS. But due to some technical issues we could not proceed to them and we were asked to use Open Source Java based CMS. After few days analysis we found that dotCMS matched our requirements for the blog site.

I searched on the net and found very little documentation on how to work with dotCMS however. It took me couple of days to figure out how to make a customized site only for blogging using dotCMS.

Here are few building blocks of dotCMS architecture.

1.Structure
2.Content
3.Category
4.Relationship
5.Container
6.Template

For any site we need to understand these properly and the initial documentation is given at this url

dotCMS comes bundled with a starter site that contains a blog module in itself. We will use this blog module to create a blog site of us named as MySite.

We will first login as admin user(test@dotcms.org/test) to http://localhost/c url.
We see that there are bunch of links available there for managing whole site. However initially we will be interested only in Container and Template section.



In every website we have few elements common to all like Header, Footer, Left Side Navigation, Right Side Navigation and Center Body. There also needs to be a template file which will contain all these elements.

Hence we will create/modify few files for things to work.

1.Create a container MySite-Header by clicking on Add/Edit Container link and write down the html that will go to your header

2.Create a container MySite-Footer by clicking on Add/Edit Container link and write down the html that will go to your footer

3.Create a container MySite-CenterBody by clicking on Add/Edit Container link and write down the html that will go to your center body(Make sure you have selected max contents to be non zero). Chose WebPageContent as content's structure. Normally the code for the body will be $!{Body} because it will be replaced with the content you will add to the center body container.

4.Create a container MySite-LeftSideNavBar by clicking on Add/Edit Container link and write down the html that will go to your Left Side Navigation Bar

5.Create a container MySite-RightSideNavBar fby clicking on Add/Edit Container link and write down the html that will go to your Right Side Navigation Bar

6.Create a template MySite-Template by clicking on Templates and then Add/Edit Templates link. You will write here the overall layout of the site. While creating the template code you also need to include the headers, footer, center body, left side navigation bar, right side navigation bar container just created above. For this you need to click on Add Container button and search for all your containers, this selected container will now be included in the code of your template created.

Click on Save and Publish to make your template active.

Now click on Browser section and browse to /global/images and create a new folder called mysite  by right clicking on images->New->Folder

Now upload all your css/images files there. You may also create a separate folder for images and css in the same way.

Now Go to Browser section again and disable all shown folders to be shown on Main Menu by right clicking on each folder and selecting Edit. Make sure you have unchecked the Show on Menu checkbox.

Now we will modify the pages in /blog directory to customize them. First of all we will modify the index.dot file by double clicking on /blog/index.dot.  When you click on the index.dot you will see a link  Page Properties on the top left side of the page. By Clicking on this link we will change the page template to our created MySite-Template.


We will change the templates of all the files present in /blog folder so that every page is in consistency with the site template.


We will now start adding actual content to all the pages modified.

For doing this we need to click on Add Content link and selecting Reuse content from the drop down. We need to search for "Widget-blog listing" content from the search window.

We need to add the content "widget - Entries by tag" in tags.dot.

Now click on add content button and chose widget - Blog Entry Detail (with audio catcha) to /blog/detail.dot

Add the content "Contributor Blog Entries" in contributor_blog_entries.dot

Add the content "Blog Archived List" in archived_blog_list.dot

Add the content "Widget - Blog listing" again to entries.dot

This now completes the blog site creation tutorial. I will update the role and user creation tutorial in next few days.

Sphere: Related Content