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.

Friday, 22 November 2013

Setup Yum Server on Linux step by step.

Yellowdog updater, Modified (Yum) is a software package manager that installs, updates and removes packages on RPM-based Linux distributions. Yum uses an online repository by default, and we can also configure it to use a local repository packages.

Use the below steps to setup yum serer on your linux server:
First of all mount the contents of your CentOS 6.2 DVD in the /mnt directory or wherever you want.

[root@Packages]#mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only.

Install vsftpd package, so that we can use this  as a FTP serer to share our repository in the client systems.
Change to the directory where you mounted CentOS DVD.

#cd /mnt/Packages
#rpm -ivh vsftpd (tab) vsftpd-2.2.2-11.el6.i686.rpm

Start the FTP service:

#service vsftpd start

Install createrepo package if it is not installed. This package will used to create our local repository:

[root@Packages]#rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
error: Failed dependencies:
      deltarpm is needed by createrepo-0.9.8-4.el6.noarch.rpm
      python-deltarpm is needed by createrepo-0.9.8-4.el6.noarch.rpm

It shows us the dependency problem. So install missing dependencies first:

[root@Packages]#rpm -ivh deltarpm-3.5-0.5.200900810git.el6.x86_64.rpm
Preparing....           ##########################################[100%]
1:deltarpm             ##########################################[100%]

[root@Packages]#rpm -ivh python-deltarpm-3.5-0.5.200900810git.el6.x86_64.rpm
Preparing....           ##########################################[100%]
1:python-deltarpm  ##########################################[100%]

Now install the createrepo package:
[root@Packages]#rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
Preparing....           ##########################################[100%]
1:createrepo          ##########################################[100%]

Create a folder called yum (you can use your own) in /var/ftp directory to save all the packages from CentOS DVD.
Copy all the files in the yum folder from the DVD.

[root@Packages]# mkdir /var/ftp/yum
[root@Packages]#cp /mnt/Packages/* /var/ftp/yum/

After all packages are copied, create a repo file called it.repo in /etc/yum.repos.d directory.

[root@Packages]#vi /etc/yum.repos.d/it.repo
and type the following entries and save the files:

[not-install]
baseurl=ftp://ip address of server/yum
gpgcheck=0

Now it's time to create our repository:

[root@Packages]#createrepo /var/ftp/yum

Client side configuration:
Create a repo file in your client system as mentioned above in the /etc/yum.repos.d/ directory:

 [client@ss]#vi /etc/yum.repos.d/it.repo
and type the following entries and save the files:

[not-install]
baseurl=ftp://ip address of yum server/yum
gpgcheck=0

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

Tuesday, 19 November 2013

Install ftp server and set ftp permission on home directory on Linux.

vsftpd  is a service which allows us to setup ftp server in secure way. By default ftp server can be access by anonymously and we can also configure login-based FTP session.

Use the below steps to Install vsftpd server:

Step 1
#yum install vsftpd

Step 2 - (Edit in main configuration file)
#vi /etc/vsftpd/vsftpd.conf

change below line as follows :
anonymous_enable=NO
local_enable=YES

Step 3 - (Enable 'vsftpd' service for automatic start after server restart)
#chkconfig vsftpd on
#service vsftpd start

Step 4 - (Set SeLinux Booleans)
#getsebool -a | grep ftp
#setsebool -P ftp_home_dir on

Now we can make login-based ftp session on web browser or Filezilla ftp client:

Step 5 - (Create Users):
#useradd user1

and update the password of user1
#passwd user1

Now you can access file server :

ftp://ip address of ftp server


username:


passwd:


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

Saturday, 26 October 2013

Install Fedora EPEL repository on CentOS Linux

In my this blog i will describe how to configure a CentOS based system to use Fedora EPEL repository and third party remi package repository and As advantage they provide much more current versions of popular applications.

Install the third party or extra repositories:
Now download some RPM files that contain the additional Yum repository definitions. In the below example we are using 64 bit version that work with our server.

Download  Requires RPM files for Centos 5.X:

# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5.4.noarch.rpm

# wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

# sudo rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

Download  Requires RPM files for Centos 6.X:

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm


# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

# sudo rpm -Uvh remi-release-6*.rpm eplel-release-6*.rpm

Once Installed we can see some additional repository definitions under the /etc/yum.repos.d directory.

# ls -l  /etc/yum.repos.d/epel* /etc/yum.repos.d/remi.repo

/etc/yum.repos.d/epel.repo

/etc/yum.repos.d/epel-testing.repo

/etc/yum.repos.d/remi.repo

Enable the remi repository:
remi repository provides a variety of up-to-date packages that are useful for web based services. That means it's good to enable the remi repositories by default.
Now open the /etc/yum.repos.d/remi.repo repository file using your favourite text editor:

# vim /etc/yum.repos.d/remi.repo

Now edit the [remi] portion of the file so that the enabled option is set to 1. This will enable the remi repository.

name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
# baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

Now we will have a larger array of yum repositories.

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

Friday, 25 October 2013

Difference between ext2, ext3 and ext4 File System on Linux.

Linux is a very flexible operating system, Linux can read and write several different file systems that originated with other operating systems much different from linux. 
One main reason is that Linux support so many file systems because Linux works on VFS (Virtual File System) Layer. The VFS layer avoids duplication of common code between all file systems also it provides a fairly universal backward compatible method for programs to access data from almost all type of file systems.

ext2 Filesystem:
  • ext2 stands for second extended file system.
  • Introduced with kernel 1.0 in 1993.
  • Super block feature increase file system performance
  • Flexible can handle upto 4 TB
  • ext2 filesystem is popular on USB and other solid-state devices.
  • ext2 filesystem reserve 5% of disk space for root
ext3 Filesystem:
  • ext3 filesystem was introduced in 2001 & Developed by Stephen Tweedie.
  • ext3 filesystem stands for third extended file system.
  • ext3 filesystem was released with Linux Kernel 2.4.15.
  • The main advantage of ext3 filesystem is that it allows journaling.
  • By journaling the possibility of file system corruption is less, So its a main advantage.
  • In ext3 filesystem Maximum file size can be from 16 GB to 2 TB.
  • Overall ext3 filesystem size can be from 2 TB to 32 TB.
  • We can convert a ext2 filesystem to ext3 filesystem directly.
Journaling: it has a dedicated area in the file system, Where all changes are tracked and when the system crashes the possibility of data loss is less because of Journaling.

ext4 Filesystem:
  • ext4 filesystem was introduced in 2008.
  • ext4 filesystem stands for fourth extended file system.
  • ext4 filesystem was released with Linux Kernel 2.6.19.
  • ext4 filesystem supports huge individual file size.
  • In ext4 filesystem Maximum file size can be from 16 GB to 16 TB.
  • Overall ext4 filesystem size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte).
  • In ext4 filesystem we can mount an existing ext3 filesystem as ext4 filesystem.
Converting ext2 Filesystem to ext3 Filesystem:
For example, if we are converting /dev/sda3 that is mounted as /home, from ext2 to ext3, do the following:

#umount /dev/sda3

#tune2fs -j /dev/sda3

#mount /dev/sda3 /home

Converting ext3 Filesystem to ext4 Filesystem:
For example, if we are converting /dev/sda3 that is mounted as /home, from ext3 to ext4, do the following:

#umount /dev/sda3

#tune2fs -0 extents,uninit_bg,dir_index /dev/sda3

#e2fsck -pf /dev/sda3

#mount /dev/sda3 /home

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

Wednesday, 23 October 2013

Backup of Linux Using dd command on Linux.

In some cases critical data loss will have a financial impact on companies. In my this blog i am updating 4 examples for using dd command to backup the Linux system. dd is a powerful Unix utility, Which is used by the Linux kernel to make boot images. dd command can only run by the root user or superuser. 

Warning: Please be careful while using dd command, If you don't know what you are doing, You will loss your data.

Example 1. - Hard Disk Backup (disk to disk)
We can use dd command to backup entire copy of a hard disk to another hard disk connected to the same system. run the dd command as shown below. In below example, the name of the source hard disk is /dev/sda and the name of the target hard disk is /dev/sdb.

# dd if =/dev/sda of =/dev/sdb

* Here "if" represents input file and "of " represents to output file, So the backup copy of /dev/sda will be available in /dev/sdb.
* If there are any errors, the above command will fail. Add the parameter "conv=noerror"
* Input file and Output file should be mentioned very carefully.

In the copy of hard disk to hard disk using dd command given below, sync option allows you to copy everything.

# dd if=/dev/sda of=/dev/sdb conv=noerror,sync

Example 2. - Create an Image of a Hard Disk
Instead of taking a backup of the hard disk, We can create an image file of the hard disk and save it. There are many advantages to backing up data to a disk image, This method is faster than other types of backups, and enabling you to quickly restore data.

# dd if=/dev/sda of=~/sdadisk.img

Example 3. - Restore Using Image Backup
To restore Image backup file on another hard disk, use the following dd command:

# dd if=sdadisk.img of=/dev/sdb

The image file sdadisk.img file, is the image of a /dev/sda, So the above command will restore the backup of /dev/sda to /dev/sdb.

Example 4. - Backup a Partition
We can use the device name of a partition in the input file, and in the output file we can specify target path or image file as shown in the below example:

# dd if=/dev/sda1 of=~/partition1.img

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

Monday, 21 October 2013

How to Mount NTFS Partition on Linux Step by Step.

For access to other drive or external hard drive in linux system you need to do the following:

Note: If you face any problem in any of the steps, Please add a comment and i'll get back with solution.

#yum install fuse fuse-ntfs-3g

If not able to install or getting something like,
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: centos.syn.co.il
* extras: centos.syn.co.il
* updates: centos.syn.co.il
Setting up Install Process
No package ntfs-3g available
No package ntfsprogs available

Don't Worry, you can download them using the following link, Just copy-paste it your browser and download will start:

#wget ftp://ftp.muug.mb.ca/mirror/fedora/epel/6/x86_64/ntfs-3g-2011.4.12-5.el6.x86_64.rpm

Once downloaded, Install the package:

#rpm -ivh ntfs-3g-2011.4.12-5.el6.x86_64.rpm

Now you should be able to open the ntfs partition by double clicking it.

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

Monday, 23 September 2013

Why yum grouplist and groupinstall command not working on Linux.

Whenever we are trying to install all the default packages by group using 'yum groupinstall groupname' command under RHEL v5.x. But, grouplist, groupinstall and groupdelete options are not working with yum.
How do I fix this issue and make sure yum command works with software groups under Redhat Enterprise Linux to increase productivity?

We need to install a package called yum-utils. its a collection of utilities that make yum easier and more powerful to use. 

Install yum-utils:
Type the following command:
# yum install yum-utils

To list software groups enter:
# yum grouplist


Loaded plugins: rhnplugin, security
Setting up Group Process
Installed Groups:
   Engineering and Scientific
   Graphics
   Network Servers
   System Tools
Available Groups:
   Administration Tools
   Authoring and Publishing
   Development Tools
   Editors
   Educational Software
   FTP Server
   Fedora Packager
   GNOME Desktop Environment
   GNOME Software Development
   Games and Entertainment
   Graphical Internet
   Hardware Support
   KDE (K Desktop Environment)
   KDE Software Development
   Mail Server
   News Server
   Office/Productivity
   Sound and Video
   Text-based Internet
   Web Development
   Web Server
   Window Managers
   X Window System
Done

To install "Web server" group, enter:
#yum groupinstall "Web server"

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


Wednesday, 10 July 2013

Configure open fire chat server on Linux.

Open-fire is a powerful instant messaging (IM) and chat server that Implements the XMPP protocols.

Server Installation:


1) Download and make a fresh installed Linux/CentOS latest version for 32/64 bits.


2) Download and install Jre-6u33-linux-i586.bin (jdk is not need just jre):


Get it here (or download from Internet)

http://www.oracle.com/technetork/java/javase/downloads/index.html
download jre-6u33-linux-i586.bin or Download tar.gz file.
Then configure.

chmod +x jre-6u33-linux-i586.bin Or

jre-6u33-linux-i586.bin Extract tar file
mv jre1.6.0_33/opt

3) #mysql - u root -p;

     #mysql>CREATE DATABASE openfire;
     #mysql>quite;

4) Download and Install openfire - openfire_3_7_1 tar.gz

    #tar xvfz openfire_3_7_1 tar.gz
    #mv openfire /opt

    # cd /opt/openfire/bin


Uncomment and modify the following line at the beginning of "/opt/openfire/bin/openfire" script to override "JAVA_HOME":

INSTALL4J_JAVA_HOME_OVERRIDE=/opt/jre1.6.0_33


Note: This is not need if "echo $JAVA_HOME" point to a valid ORACLE java 1.5 (or later) or OPENJDK installation path.

Openfire does not works with "gcj" which can be installed on Ubuntu, check installed version executing "java-version".

Then just Start it!


./openfire start


5) Next, edit the configuration file /etc/openfire/openfire.xml, and add your linux server's public IP address in the <interface> section, and removing the "<!-->" comment markers that surround this section.


Edit in /etc/openfire/openfire.xml file


<interface>192.168.21.8</interface>


Now restart the Openfire with the following command:


/etc/init.d/openfire restart


Now access to openfire server - http://192.168.21.8:9090


For any query please feel free to contact me by this mail ID - sashwatkatore@gmail.com


Tuesday, 18 June 2013

Configure Squirrelmail Webmail Server on Linux.

Configure Squirrelmail Server with POP3/IMAP on Linux/CentOS
Package Requirements:
* Linux Server with Centos 5/6
* Apache 2 with PHP4 or later
* Postfix (SMTP server or MTA)
* Dovecot ( IMAP/POP3 server)
* Squirrelmail (A free Webmail)
We will be setting up the email server for local users where they can use
webmail or outlook express to access their email. We will be setting up a simple
and most basic mail server for local users.
Before we proceed to setup a mail server, the following 3 are most important
for delivering email to destination.
1. DNS Entry for your mail server with MX record
2. Setup an SPF record
3. Setup Domain Name Keys
4. Reverse IP for your Mail Server
The most important of it setting up reverse IP for your mail server. You have
to ask your hosting provider to setup a reverse IP for your mail server. 
Install Postfix (SMTP Server/MTA)
Postfix is fast and popular SMTP server and widely used. Its main job is to
relay mail locally or to intended destination outside the network.
By default Sendmail comes Pre-installed with Centos. We will need need to remove
it and install Postfix:
#yum remove sendmail
#yum install postfix
The configuration file is located at /etc/postfix/main.cf. 
Edit the file and make sure you change the following lines with your domain name:
myhost = mail.sumit.com
mydomain = sumit.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, $mydomain

we have to be careful about $mydestination is because it restrictions receiving
Setting up SASL + TLS
To enable SASL authentication open /etc/postfix/main.cf and
Install Dovecot (POP3/IMAP Server)
Look for the line auth default and make these changes. Becareful with the lines as they are heavily commented out:
Install Squirrelmail
Before you access Squirrelmail or Mail restart all the services:
To access squirrelmail point your browser to

emails by the server pertaining to domains.

We have to also setup SASL with our postfix to authenticate our users who want
to send email outside of the permitted network:
#yum install cyrus-sasl

add the following lines:
smtpd_sasl_auth_enable = yes
smtpd_reciptient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

Dovecot is a very popular POP3/IMAP server. The main difference between POP3
and IMAP is while accessing the your email with outlook if you use POP3 the
mail is downloaded to your computer and deleted from the server. With IMAP the

mail is retained in the server. 
The configuration file is located at /etc/dovecot.conf
#yum install dovecot
Open the dovecot config file /etc/dovecot.conf and make the following changes. 
You may need to comment or uncomment certain lines:
protocols = imap imaps pop3 pop3s

auth default {
mechanisms = plain login
passdb pam {
}
userdb passwd {
}
socket listen {
clinet {
path = /var/spool/postfix/private/auth/
mode = 0660
user = postfix
group = postfix
}
}
}

Squirrelmail is a free webbased email can be very handy for your users to login

while they are mobile.
#yum install squirrelmail
To setup the squirrelmail under apache, open /etc/httpd/conf/httpd.conf:
and insert the following lines:
Alias /squirrelmail /usr/local/squirrelmail/www
<Directory /usr/local/squirrelmail/www>
Options Indexes
AllowOverride none
DirectoryIndexes index.php
Order allow,deny
allow from all
</Directory>

The squirrelmail configuration utility is located in /usr/share/squirrelmail/config/conf.pl:
Run the configuration utility and set the server settings to SMTP and change your domain name to sumit.com
/usr/share/squirrelmail/config/conf.pl

/etc/init.d/postfix start
/etc/init.d/dovecot start
/etc/init.d/saslauthd start
service httpd restart

http://www.sumit.com/webmail
and the squirrelmail test page is located at http://domain.com/webmail/src/configtest.php
Before we login to squirrelmail, you will need to create users:
Just create a localuser with adduser:
#adduser sumit
and update the password of sumit
# passwd sumit

Now open Squirrelmail server with the username & password.
For any query please feel free to contact me my email ID is sashwatkatore@gmail.com.

Configure phpMyAdmin 4.2.11 on Linux.


 phpMyAdmin is a free software tool written in php, intended to handle the administration of MySQL over the web. phpMyAdmin supports a wide range of operations with MySQL. 

phpMyAdmin Installation on Linux:

(Note: First Install all the related files to run MySQL, php, Apache)

#yum install httpd*

#yum install php-mysql*
#yum install mysql-server

configure your Apache web server(if you have any problem regarding that you can look in my previous post "How to configure Apache or httpd Server")


check in the /etc/httpd/conf.d that there is php.conf file is present


start all the required services 


#service httpd start


#service mysqld start


#chkconfig httpd on


#chkconfig mysqld on


Download the latest version of  phpmyadmin Currently the stable version of phpMyAdmin is 4.2.11


After downloading it uncompressed it


#tar -xjvf php ....................... (depending upon the version u downloaded)


move this folder to your web directory in which your site is located and rename it as i have done php and open the configuration file, make changes to the settings so that you can access it via http:


#vi config.inc.php


make changes into line no. 73


73 $cfg['Servers'][$i]['auth_type']    ='http';     (enter http here in =''; line no. 73)


:wq            

(save and quite)

restart the httpd service and access it via web browser, inter in the address browser your IP/php to access.


#service httpd restart

in web browser your IP/php

If you had set any password for your mysql than use that other wise it will be blank


username: root


password: blank


If you want to know the username and password of your phpMyAdmin go to:


#vi config.inc.php


and see in line no. 74 & 75 - 


74   $cfg['Servers'][$i]['user']       ='root';              (MySQL user)


75   $cfg['Servers'][$i]['password']   ='';                 (MySQL password)


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

Friday, 7 June 2013

Configure ftp Server on Linux.

Though the steps provided here are tested in CentOS 6.5, it should work on RHEL and Scientific Linux 6.x too. In this blog my ftp server IP and hostname are 192.168.21.10 and sumit.com respectively. 

Before proceed, stop the firewall.

[root@sumit.com ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
[root@sumit.com ~]# service ip6tables stop
ip6tables: Flushing firewall rules:                        [  OK  ]
ip6tables: Setting chains to policy ACCEPT: filter         [  OK  ]
ip6tables: Unloading modules:                              [  OK  ]
[root@sumit.com ~]# chkconfig iptables off
[root@sumit.com ~]# chkconfig ip6tables off
[root@sumit.com ~]# 

Now let us install FTP service.

[root@sumit.com ~]# yum install -y vsftpd
[root@sumit.com ~]# Start vsftpd service.
[root@sumit.com ~]# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
[root@sumit.com ~]# 

Enable vsftpd in multi-user levels.

[root@sumit.com ~]# chkconfig vsftpd on
Now edit the /etc/vsftpd/vsftpd.conf file. 
Uncomment and edit the lines in the vsftpd.conf file which are shown in bold.

[root@sumit.com ~]# cat /etc/vsftpd/vsftpd.conf 

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES
ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to OSTECHNIX FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
use_localtime=YES

Now let us restart the vsftpd service and try to connect to ftp server.
[root@sumit.com ~]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
Connect to the ftp server

Note: Root is not allowed to connect to ftp server by default for security purpose. So lets us create a new user called ftpuser

[root@sumit.com ~]# useradd ftpuser
[root@sumit.com ~]# passwd ftpuser
Changing password for user ftpuser.
New password: 
BAD PASSWORD: it is based on a dictionary word
Retype new password: 
passwd: all authentication tokens updated successfully.

Connet to FTP server using the new user ftpuser.
[root@sumit.com ~]# ftp 192.168.21.10
-bash: ftp: command not found
[root@sumit.com ~]# 

Oops! ftp package is not installed. So let us install ftp package first.

[root@sumit.com ~]# yum install -y ftp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ftp.i686 0:0.17-51.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package       Arch           Version                 Repository           Size
================================================================================
Installing:
 ftp           i686           0.17-51.1.el6           localrepo            55 k
Transaction Summary
===============================================================================================
Install       1 Package(s)
Total download size: 55 k
Installed size: 91 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : ftp-0.17-51.1.el6.i686                                       1/1 
  Verifying  : ftp-0.17-51.1.el6.i686                                       1/1 
Installed:
  ftp.i686 0:0.17-51.1.el6                                                      
Complete!

[root@sumit.com ~]# 
Again connect to the FTP server.
[root@sumit.com ~]# ftp 192.168.21.10
Connected to 192.168.1.200 (192.168.21.10).
220 Welcome to ftpuser FTP service.
Name (192.168.21.10:root): ftpuser
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/ostechnix
Login failed.
ftp> 

It shows a error that the user cannot change to his $HOME directory. Type exit to return back from the ftp console and allow vsftpd daemon to change users into their $HOME directories. To do that update SELinux configuration using the command below.

[root@sumit.com ~]# setsebool -P ftp_home_dir on
And finally connect to the FTP server.

[root@sumit.com ~]# ftp 192.168.21.10
Connected to 192.168.21.10 (192.168.21.10).
220 Welcome to ftpuser FTP service.
Name (192.168.21.10:root): ftpuser
331 Please specify the password.
Password:

230 Login successful.

Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/ostechnix"
ftp> 
Its working now. You can use your FTP server.
Connect to FTP server using Filezilla from Client:

Download and install Filezilla client software to any one of the client systems. Open the Filezilla client and enter the username and password which we have created earlier and click connect.

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

Monday, 27 May 2013

Reinstalling the GRUB Boot loader on Linux.



We can recover a corrupted or mistakenly deleted Grub Boot loader using the rescue mode :

1. Boot the system from any boot installation media like a CD-Rom or a Flash Drive, etc.

2. Use the linux rescue command as shown below at the installation prompt to enter the rescue environment:


# Linux rescue
3. Type the below command to mount the root partition:

     # chroot /mnt/sysimage


4. Type the below command to re install the Grub Boot loader, Where /dev/sda is the boot partition:


     # /sbin/grub-install /dev/sda


5. Go through the /boot/grub/grub.conf file once again, as additional entries may be needed for GRUB so as to make any custom changes there (like controlling another installed operating system)


Step 6. Finally, reboot the system


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


Thursday, 23 May 2013

Booting Process of Linux.


Press the power button on your system, and after few moments you see the Linux login prompt.
Have you ever wondered what happens behind the scenes from the time you press the power button until the Linux login prompt appears?
Linux uses 6 stages in booting process:

1. BIOS
  • BIOS stands for Basic Input/Output System
  • Performs some system integrity checks
  • Searches, loads, and executes the boot loader program.
  • It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.
  • Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
  • So, in simple terms BIOS loads and executes the MBR boot loader.

2. MBR

  • MBR stands for Master Boot Record.
  • It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
  • MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.
  • It contains information about GRUB (or LILO in old systems).
  • So, in simple terms MBR loads and executes the GRUB boot loader.

3. GRUB

  • GRUB stands for Grand Unified Bootloader.
  • If you have multiple kernel images installed on your system, you can choose which one to be executed.
  • GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
  • GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
  • Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of CentOS.
                                     #boot=/dev/sda
                                     default=0
                                     timeout=5
                                     splashimage=(hd,0) /boot/grub/splash.xpm.gz
                                     hiddenmenu
                                     title CentOS (2.6.18-194.EL5PAE)
                                                         root (hd,0)
                                                         kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
                                                         initrd /boot/initrd-2.6.18-194.el5PAE.img

  • As you notice from the above info, it contains kernel and initrd image.
  • So, in simple terms GRUB just loads and executes Kernel and initrd images.

4. Kernel

  • Mounts the root file system as specified in the “root=” in grub.conf
  • Kernel executes the /sbin/init program
  • Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.
  • initrd stands for Initial RAM Disk.
  • initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.

5. Init

  • Looks at the /etc/inittab file to decide the Linux run level.
  • Following are the available run levels
    • 0 – halt
    • 1 – Single user mode
    • 2 – Multiuser, without NFS
    • 3 – Full multiuser mode
    • 4 – unused
    • 5 – X11
    • 6 – reboot
  • Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.
  • Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level
  • If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that.
  • Typically you would set the default run level to either 3 or 5.

6. Runlevel programs

  • When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.
  • Depending on your default init level setting, the system will execute the programs from one of the following directories.
    • Run level 0 – /etc/rc.d/rc0.d/
    • Run level 1 – /etc/rc.d/rc1.d/
    • Run level 2 – /etc/rc.d/rc2.d/
    • Run level 3 – /etc/rc.d/rc3.d/
    • Run level 4 – /etc/rc.d/rc4.d/
    • Run level 5 – /etc/rc.d/rc5.d/
    • Run level 6 – /etc/rc.d/rc6.d/
  • Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
  • Under the /etc/rc.d/rc*.d/ direcotiries, you would see programs that start with S and K.
  • Programs starts with S are used during startup. S for startup.
  • Programs starts with K are used during shutdown. K for kill.
  • There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
  • For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.
For any query please feel free to contact me my email ID is sashwatkatore@gmail.com.