Saturday, 21 December 2013

Check Memory usage on Linux.

There are different commands to check Memory usage in Linux. The free command displays the total amount of free and used physical and swap memory in the system. The vmstat command reports information about processes, memory paging and cpu activity.
Depends on our requirement run the following commands to get desired output.

/proc/meminfo
The /proc/meminfo file stores statistics about memory usage on the Linux system.

Example: use the cat command or grep command to see /proc/meminfo file:
# cat /proc/meminfo

Sample outputs:
MemTotal :               9120570 kB
MemFree :                3378742 kB
Cached :                   2108250 kB
SwapCached :                       0 kB
Swap Total :              18382450 KB
SwapFree :                17980704 kB

Free Command
To display free memory size in MB (megabytes):
# free -m

Sample outputs:
                       total               used               free              shared           buffers          cached
Mem :               950               850               325                      0                 35              555
-/+ buffers/cache :                  485               695
Swap :              995                   0               998

Below command will show a line containing the totals memory in MB:
# free -t -m

Sample outputs:
                       total               used               free              shared           buffers          cached
Mem :               950               850               325                      0                 35              555
-/+ buffers/cache :                  485               695
Swap :              995                   0               998
Total :             1940                850            1320                      0                 35              555

For any query please contact me by mail my email ID is - sashwatkatore@gmail.com.

Thursday, 19 December 2013

How to hosting multiple web sites with Apache on Linux.

Apache is the most commonly used Web Server on Linux Systems. Web Servers are used to serve Web pages requested by client computers. There are two ways to host multiple sites with one Apache Server,
and both are very simple to setup. We have the choice of using Name based virtual hosts, or IP based virtual hosts.

In most common situations we will use Name based virtual hosts, this is only requires that all the sites we wish to host point to the IP address of our Apache Server.

In my this blog i am using two web sites on one Apache Server:
      Web Sites                                     Document Root
1. www.testserver.com                     DocumentRoot /var/www/html/test
2. m.testserver.com                          DocumentRoot /var/www/html/m.test

Now open the Apache Server configuration file and add the necessary entry for the multiple virtual host.
#vi /etc/httpd/conf/httpd.conf

# <VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

NameVirtualHost 118.112.104.111:80
        <VirtualHost 118.112.104.111:80>
         ServerAdmin sashwatkatore@testserver.com
         DocumentRoot /var/www/html/test
         ServerName www.testserver.com
#       ErrorLog logs/dummy-host.example.com-error_log
#       CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost 118.112.104.111:80>
         DocumentRoot /var/www/html/m.test
         ServerName m.testserver.com

# Other directives here
</VirtualHost>

For any query please feel free to contact me my email ID is sashwatkatore@gmail.com.

Wednesday, 18 December 2013

How to recover root password on Linux step by step.

7 easy steps to reset forgotten root password on Red Hat Enterprise Linux, CentOS Linux or Fedora Linux.

1. Boot the system and when you see the following message "Press any key to enter the menu" -
 press any key.

2. Pres e in order to edit commands before booting.

3. Highlight the list item with vmlinuz in it by using the arrow keys and press e. 

4. Now type single or init 1 at the end of the line.

5. Then press enter and b to boot the system with the new argument.

Now it's time to change the password:

6. Type passwd 

### Shell Commands ###
# passwd
# Enter new UNIX password:
# Retype new UNIX password:
# passwd: password updated successfully

7. Type reboot to restart the system.

For any query please feel free to contact me my email ID is - sashwatkatore@gmail.com.

How to set date and time from command prompts on Linux.

When we don't have GUI installed on Linux system, It is difficult to set the system date and time from the command prompt. Use the date command to display the current date and time.

You must login as root user to use date command.

Set Date and Time on Linux:
use the following syntax to set new date and time:
#date --set="STRING"

For example, set new data to 18 DEC 2013 16:40:00, type the following command as root user:

#date -s "18 DEC 2013 16:40:00"

OR

#date --set="18 DEC 2013 16:40:00"

For any query please feel free to contact me my email ID is sashwatkatore@gmail.com

Install MongoDB on Linux.

MongoDB is an open-source fast, reliable and the leading NoSQL database, Written in C++.
In my this article the steps to install MongoDB on Red Hat Enterprise Linux, CentOS Linux, Fedora Linux and related systems.

MongoDB Packages:
The MongoDB downloads repository contains two packages:

    1. mongo-10gen-server
        This package contains the mongod and mongos daemons from the latest stable release.

    2. mongo-10gen
        This package contain all MongoDB tools from the latest stable release.

Install MongoDB: 
Configure Package Management System using YUM:
Create a /etc/yum.repos.d/mongodb.repo file to hold the following configuration information for the MongoDB repository:

If you are running a 64-bit system, use the following configuration:
#vi /etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

If you are running a 32-bit system, use the following configuration:
#vi /etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
enabled=1

Install Packages:
Now install mongodb packages by Yum:
#yum install mongo-10gen mongo-10gen-server

After completes this command, you have successfully installed MongoDB

Start MongoDB

#service mongod start

You may optionally ensure that MongoDB will start following a system reboot by issuing the following command:

#chkconfig mongod on

For any query please feel free to contact me my email ID is sashwatkatore@gmail.com.

Tuesday, 17 December 2013

Update access log for Squid Server with Date and Time on Linux

Some time user monitoring is very difficult on Squid Server, And it is very difficult to trace which types of website is access by user with date and time. We can solve this issue with the following configuration on Linux Server.

Open your squid.conf and search for the line that starts with access_log or cache_access_log and looks like:


#vi /etc/squid/squid.conf


and search for the line that starts with access_log or cache_access_log


access_log /var/log/squid/access.log squid


Please note that the path to the log file may vary in your case.


Note that last keyword (in this case squid, but it could be common, combined). Then look for the line that starts with logformat squid and change "%ts.%03tu" with "%tl" for local time or "%tg" for GMT time.

Please note that  if the line does not exist you should add it. 

For the above example it should changed from:


logformat squid  %ts.%03tu %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt


To:


logformat squid  %tl. %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt


Now do restart Squid Server and see access file again:


#service squid restart


#vi /var/log/squid/access.log


For any query please feel free to contact me my Email ID is sashwatkatore@gmail.com.