Tuesday 13 March 2012

Use of find & ls commands in RedHat 6/ CentOS 6

10:58 Posted by Birender No comments
   1.       Search the file with name
          find / -name yum
                    Or
          find / -name httpd.conf

       2.       Finding files owned by a user
        find / -user birender

      3.       Finding the files owned by user and having extension .sh
       find / -user birender –name *.sh

       4.       Finding the files those were last accessed 7 days ago
        find / -atime +7

       5.       Finding the files those size is more than 200 MB
       find / -size +100M

        6.       Find the passwd file under root and one level down.
                        find -maxdepth 2 -name passwd
        ./etc/passwd

       7.       Finding the file on which user has full permission
        find / -perm –u=rwx –type f

       8.       Finding the file on which group has full permission
       find / -perm –g=rwx –type f

       9.   Finding the directory on which user has full permission
     find / -perm –u=rwx –type d

     10.   Finding all the empty files
     find / -empty

      11.   Finding a file in home directory which size is more than 100 MB and remove it
      find –type f –size +100M exec rm –I {} \;

      12.   Finding a file owned by user1 and change its permission to 744
      find / -user user1  -type f exec chmod 744 {} \;

      13.   Finding the files whose content got updated within 1 hours
      find / -mmin 60

      14.   Finding the files which was accessed within 1 hours
    find / amin 60




LS
1.       To show the list of files use
      ls

2.       To show the full information and long list use:
      ls –l

3.       To show the size of files in human readable form use
      ls –lh

4.       To show file per line use:
     ls -1

5.       To show only directory information use
    ls –ld

6.       To show files recursively use:
    ls –R

7.       To show all the hidden files use
   ls -la



How To SSH Without Password ON RedHat 6/CentOS 6

09:28 Posted by Birender No comments

1.       Suppose I have Two machines A and B. I want to ssh from A to B. So login into machine A and run this command. 
                ssh-keygen

               
              Follow the instructions. Don,t enter pass phrase just leave it blank. 

    
2.       Now copy the file rsa.pub to machine B

               ssh-copy-id –i /root/.ssh/id_rsa.pub root@ip

3.       Now ssh A to B you will not prompt for password.


Friday 9 March 2012

Tuesday 6 March 2012

Nagios Monitoring Server Installation & Configuration on RedHat 6/CentOS 6

09:03 Posted by Birender No comments

Nagios Monitoring Server Installation & Configuration on RedHat 6/CentOS 6

Download following packages nagios and nagios-plugin

Install following packages will be required for nagios installation

Packages and versions used:
                       a.       nagios-3.3.1.tar
                       b.      nagios-plugins-1.4.15.tar

     1.       Download the following dependency for nagios installation
         yum install httpd php gcc glibc glibc-common gd gd-devel     openssl*

     2.       Now add a user ‘nagios’ and group ‘nagms’
               useradd nagios
 passwd nagios
 groupadd nagms

     3.       Now add nagios and apache to nagms group
        usermod –g  nagms nagios
     usermod –g nagms apache

     4.       Now download the nagios-3.3.1.tar package from              here(http://www.nagios.org/download/core/thanks/)

     5.       Untar the nagios package  
              tar xvfz nagios-3.3.1.tar
     cd nagios-3.3..1/
     ./configure –with-coomand-group=nagms
     make all


           make install


                  make install-init


                     make install-config



         make install-commandmode




                          make install webconf




      Now Nagios server installation is complete. We can now customize our nagios server.

      6.       Edit admin email account
                     vim /usr/local/nagios/etc/objects/contacts.cfg

       7.       Now create a user for login using web browser
                      htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosuser
           service httpd restart

       8.     Now install nagios plugin. Download from here(http://www.nagios.org/download/plugins/)

       9.    Untar the package
                    tar xvfz nagios-plugins-1.4.15.tar
          cd nagios-plugins-1.4.15/
          ./configure
          make
          make install
          chkconfig nagios on
          service nagios restart

       10.   To check whether installation is done without error, run this
   /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nag  ios.cfg


           11.   Now open web browser and open the link http://localhost/nagios

         
                    



























Friday 2 March 2012

Local Yum Repository On Red Hat 6/CentOS 6

00:35 Posted by Birender No comments

1.      Create a directory for RPMs
              mkdir /yum-repos
2.      
            Copy All the Packages from Red Hat Installer DVD
     cp -rp /media/REDHATDVD/Packages/* /yum-repos
3.        
       Now install createrepo
     cd /yum-repos
     rpm –ivh createrepo*
4.      
              Now run this command

     createrepo -v /yum-repos/Packages
5.  
                Now create a file
              
              vim /etc/yum.repos.d/yum-server.repo
6.    
                And add  following lines(all are necessary)

     [mylocalnet]
      name=red hat $basearch
      baseurl=file:///yum-repos/Packages
      enabled=1
      gpgcheck=0

Mail Server Using Zimbra Collaboration Server On Red Hat 6

00:19 Posted by Birender No comments

1.     
     1.      Download Zimbra Collaboration Suit(ZCS) From here(http://www.zimbra.com/downloads          /os-downloads.html) and download file for RED HAT 6
    
    2.      Stop sendmail, disable iptables, set selinux to permissive mode
       service sendmail stop
       chkconfig sendmail off
       setenforce 0

    3.       Now install following packages before installing ZCS.
       yum install nc sudo libidn gmp libstdc++ perl sysstat sqlite –y

    4.      Now set hostname from here, my hostname is mail.example.com.

    5.      Set MX record for the example.com zone from here.

    6.      Untar the ZCS package using this command
        tar xvfz zcs-7.1.4_GA_2555.RHEL6_64.20120105094542.tgz
       cd zcs-7.1.4_GA_2555.RHEL6_64.20120105094542
    7.      Now run the script and let the magic begins
.      /install.sh

                                                                                                                                                                            

    
    8.      Accept the license agreement.
 





      9.  Now DNS error will show add your domain and interface address like mine


    10.      Now time to set admin password. First choose the option no. 3 then 4 and set admin password.










                                                                                        
               Hurray! Your mail server is ready to work. 
11.      Now open web browser and enter user https://mail.demoslice.com:7071 and Zimbra Webmail URL for users: http://mail.zimbra.local

Mail Server Using Postfix, Dovecot, Squirrelmail On Red Hat 6

00:14 Posted by Birender No comments
        1.      List and Version of Packages:
         postfix-2.6.6-2.el6.x86_64
         dovecot-2.0-0.10.beta6.20100630.el6.x86_64
         squirrelmail-1.4.6-1.norlug.noarch
        2.      Postfix Installation and Configuration
      yum install postfix
      vim /etc/postfix/main.cf
          Main.cf file should be look like this
      myhostname = mail.demoslice.com
      mydomain = demoslice.com
      inet_interfaces = all
      mydestination = $myhostname, localhost.$mydomain,                   localhost, $mydomain
      mynetworks = 10.10.10.0/24, 127.0.0.0/8
      home_mailbox = Maildir/
   At the end of main.cf
      smtpd_sasl_type = dovecot
      smtpd_sasl_path = private/auth
      smtpd_sasl_auth_enable = yes
      smtpd_recipient_restrictions =  permit_mynetworks,
      permit_sasl_authenticated,
      reject_unauth_destination
      broken_sasl_auth_clients = yes
          4.      Dovecot Installation and Configuration
yum install dovecot
   vim /etc/dovecot/dovecot.conf
           Dovecot.conf should look like this
  protocols = imap pop3 lmtp
       vim /etc/dovecot/conf.d/10-mail.conf
  mail_location = maildir:~/Maildir
       vim /etc/dovecot/conf.d/10-master.conf
         unix_listener /var/spool/postfix/private/auth {
         mode = 0666
         user = postfix
         group = postfix
 vim /etc/dovecot/conf.d/10-auth.conf
       auth_mechanisms = plain login
 vim /etc/dovecot/conf.d/20-pop3.conf
      pop3_uidl_format = %08Xu%08Xv
            pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

         5.      Installing and Configuring Squirrelmail
       yum install squirrelmail
       /usr/share/squireelmail/config/config.pl
        Then enter D and enter dovecot
        Now press 2 and enter domain name.