Friday, December 31, 2010

How to install & configure getmail, replacement of Fetchmail utitity ?

How to install & configure getmail, replacement of Fetchmail utitity ?


Getmail : Getmail is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. getmail is designed to be secure, flexible, reliable, and easy-to-use. getmail is designed to replace other mail retrievers such as fetchmail.
getmail version 4 includes the following features:
  • simple to install, configure, and use
  • retrieve virtually any mail
    • support for accessing mailboxes with the following protocols:
      • POP3
      • POP3-over-SSL
      • IMAP4
      • IMAP4-over-SSL
      • SDPS (Demon UK's extensions to POP3)
    • support for single-user and domain mailboxes
    • retrieve mail from an unlimited number of mailboxes and servers
    • can remember which mail it has already retrieved, and can be set to only download new messages
  • support for message filtering, classification, and annotation by external programs like spam filters and anti-virus programs
  • support for delivering messages to different destinations based on the message recipient
  • reliability
    • native safe and reliable delivery support for maildirs and mboxrd files, in addition to delivery through arbitrary external message delivery agents (MDAs)
    • does not destroy information by rewriting mail headers
    • does not cause mail loops by doing SMTP injection, and therefore does not require that you run an MTA (like qmail or sendmail) on your host
  • written in Python, and therefore easy to extend or customize
    • a flexible, extensible architecture so that support for new mail access protocols, message filtering operations, or destination types can be easily added
    • cross-platform operation; getmail 4 should work on Unix/Linux, Macintosh, and other platforms. Windows support available under the free Cygwin package.

Requirements:

Python should be installed on the server using getmail.


How to install getmail :

You have two ways to do it, either you configure 3rd party repos and install in by,

             #yum install getmail*

Or simply download getmail-3.2.5-1.noarch.rpm and install it through,

            #rpm -ivh getmail-3.2.5-1.noarch.rpm


How to Configure it:

Login to your Mail server,

Suppose you want to fetch mail for user "ashish"

Then,

     #useradd ashish

     #su ashish

     #mkdir -m 0700 ~/.getmail


Now make a new file,

     #vi ~/.getmail/getmailrc

===========================

[retriever]
type = SimplePOP3Retriever
server = <external Mail Server IP>
username =  username@domain_name # add username before @ sign
password = <Users mail password> # add password for that account

[destination]
type = MDA_external
path = /usr/sbin/sendmail
arguments = ("-i", "-bm", " @<domain_name>") # add username before @ sign
unixfrom = true

[options]
verbose = 1
read_all = false
delete = false #---------> Leave Copy on server Enabled when it's set to (False)

OR

delete_after = <days>
message_log_syslog = true

===========================

Now test below command, if it's working for that user;

     #getmail

& to make it automatic mail fetching put it in "crontab",

     #crontab -e

*/5 * * * * /usr/bin/getmail &> /dev/null


----------------------------------------------------------------------------------------------

Sample ~/.getmail/getmailrc

----------------------------------------------------------------------------------------------


#vi ~/.getmail/getmailrc


[retriever]
type = SimplePOP3Retriever
server = 70.116.111.228
username =  ashish@maildomain.in # add username before @ sign
password = ashish123 # add password for that account

[destination]
type = MDA_external
path = /usr/sbin/sendmail
arguments = ("-i", "-bm", " @maildomain.in") # add username before @ sign
unixfrom = true

[options]
verbose = 1
read_all = false
delete = false #Leave Copy on server Enabled when it's set to (False)

OR

delete_after = 30
message_log_syslog = true

----------------------------------------------------------------------------------------------


Here i have shown you simple configuration of getmail to fetch mail from External mail server to our own internal mail server. If you want to check more configuration options please visit getmail website.


_Enjoy :D

How to redirect all /etc/passwd user list to your SAMBA User list ? OR, How to add users from your NIS server to SAMBA server ?

How to redirect all /etc/passwd user list to your SAMBA User list ? OR
How to add users from your NIS server to SAMBA server ?


Use below command,

# cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd

Here, /etc/samba/smbpasswd files have user data for SAMBA server.


Now check, All your system users will be added to your SAMBA user list.


What if you are working on NIS Server and you want to redirect all NIS users in to SAMBA server list.
then,

# ypcat passwd | mksmbpasswd.sh > /etc/samba/smbpasswd

IN BOTH THE CASES YOU MUST DO THIS : #chmod 600 /etc/samba/smbpasswd



Done ...

How to split big files in to small chunks or in small parts ?

How to split big files in to small chunks or in small parts ?


What to do if you dont have much space on a drive to store any big file & you want to split and store it in to some small size parts.


A. First check md5sum hash of file, and make a note of it;

#md5sum <Big File Name>
e.g.
#md5sum Linux-pdf-HOWTOs.tar.bz2


B. Split file in to small managable chunks,

#split --bytes=<Size of each chunk>m <Big File Name> <Chunk File Prefix>
e.g.
#split --bytes=10m Linux-pdf-HOWTOs.tar.bz2 Linux-pdf-

  Note : Here it'll make 10-10 MB file chunks.


C. Now if you want to reassemble chunk files in to Big File,

#cat <File Chunk Prefix>* > <Big File Name>
e.g.
#cat Linux-pdf-a* > Linux_PDF_HOWTOS.tar.bz2


D. Check md5sum hash of file,

#md5sum <Big File Name>
e.g.
#md5sum Linux_PDF_HOWTOS.tar.bz2


E. Compare md5sum of "Step A" & "Step D", If both the md5sum are same then your big file is OK.

How to set proxy settings on RHEL OR CentOS ?

How to set proxy settings on RHEL OR CentOS ?


What you will do if you dont have direct internet connection & you want to download some package or file by wget suppose. In this scenario we have to set proxy server settings for HTTP as well as FTP traffic.

1. Get full information about the Proxy server & your access account on it like,

A. Proxy Server IP OR Hostname
B. Proxy Port Number
C. Login cridentials if any
D. Ask if admin managing different accounts & server info for HTTP & FTP access.


Now here we go, We can do this thing in two manner one is Temporary & other is Permanent setting,


To do this on temporary basis, we will set this info in environment variable;


#export http_proxy=http://<Proxy Server IP>:<Proxy Port No.> (For HTTP Proxy)
#export ftp_proxy=http://<Proxy Server IP>:<Proxy Port No.> (For FTP Proxy)

    e.g.

#export http_proxy=http://10.10.10.1:3128
#export ftp_proxy=http://10.10.10.1:3128


What if you have login credentials for Proxy then,

#export http_proxy=http://username:password@<Proxy Server IP>:<Proxy Port No.>

    e.g.

#export http_proxy=http://ashish:ashish123@10.10.10.1:3128


Note : These command will set proxy temporary, if you want to make it Permanently then, add these settings in "~/.bashrc" file.

Thursday, December 30, 2010

How to mount NTFS (Windows) partition on RHEL or CentOS 5 ?

How to mount NTFS (Windows) partition on RHEL or CentOS 5 ?


Here for this tutorial i am using CentOS 5.3 OS, Because you can easily find many open source 3rd party repos to install your any software with its dependency, just in one click.

Or If you are working on RHEL then you can get all the required packages from these two sites,

1. Download fuse & ntfs-3g

fuse: get it from http://www.atrpms.net/dist/el5/fuse/
ntfs-3g: get it from http://dag.wieers.com/rpm/packages/fuse-ntfs-3g/


To install Fuse you need these three packages,

A. fuse
B. fuse-devel
c. fuse-libs


And to install ntfs-3g,

A. ntfs-3g
B. ntfs-3g-devel


To install these two, either install it by taking above rpms separately or by configuring all 3rd Party repos as in my Previous post "How to configure 3rd Party Yum Repo's ?",

Here i have done it by 3rd party repos, which is very easy !!!

Now,

#yum install fuse*

#yum install ntfs-3g*








Now, our system is ready to mount NTFS partition,

Check the NTFS Partition device name with "#fdisk -l" command, & mount with

#mount.ntfs-3g /dev/sdb /mnt/

Here i am assuming /dev/sdb is my NTFS device or Partition, & mounted it on /mnt folder.


-cheer's

How to configure 3rd Party Yum Repo's ?

How to configure 3rd Party Yum Repo's ?


RHEL is Red Hat's enterprise distribution. Generally used for servers that require long life cycles and stability. Based off the development of Fedora. RHEL is sold with support through Red Hat. While support is of great value many users of MythTV may be looking to save money and rely on the community for support. This is where CentOS comes in. Being, RHEL is based on GPL software Red Hat must release the source to the entire OS. CentOS takes the source, removes logo/trademarks of Red Hat and creates CentOS. CentOS is a 100% binary compatible with RHEL packages, so RPMs for EL are good for CentOS.

Enabling DVB;

For some reason CentOS (not sure about RHEL) has DVB disabled by default in the kernel. The fix is easy. You need to install the centos.plus kernel to do this; So


Enable the plus repo.

#vi /etc/yum.repos.d/CentOS-Base.repo
      
Here Change

enable=0 to

enable=1 under the [centosplus] section.

#yum update kernel

DVB should now be enabled.


1. Configuring "ATRPMS.net" Yum Repos :

   Download http://dl.atrpms.net/all/atrpms-package-config-120-3.el5.i386.rpm for (i386 i.e. 32 Bit) and install it,

#rpm -ivh atrpms-package-config-120-3.el5.i386.rpm

   If you are working on (x86_64 i.e. 64Bit), then download & install

#rpm -ivh http://dl.atrpms.net/all/atrpms-package-config-120-3.el5.x86_64.rpm



   Note : If you are not getting same version then just go to,

   http://packages.atrpms.net/dist/el5/atrpms-package-config/

   & select proper version of package & install, as it gets install now edit "/etc/yum.repos.d/atrpms.repo" as below,

2. Configuring RPM Forge Repo:

Although RPM Forge is not required for MythTV is provides many packages a home user may want.

On RHEL 5 i386:

#rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

On RHEL 5 x86_64:

#rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm



3. Configuring EPEL Repo

EPEL was started because many Fedora contributors wanted to use the Fedora packages they maintain on Red Hat Enterprise Linux (RHEL) and its compatible derivatives.

To install for both i386 and x86-64

#rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm


In step 2 & 3, this will be like;





Next, after installing these 3rd Party Repo's, restart

#/etc/init.d/yum-updatesd restart


Now it's ready to fetch any 3rd party package from internet & install in on your Linux box,


To download any 3rd party package,

#yum install ntfs-3g*



_Enjoy :)

How to install .bin files in RHEL or CentOS 5 ?

How to install .bin files in RHEL or CentOS 5 ?

The *.bin files are Self extracting packages just like rpm packages. Here i am installing JAVA 6 with "jre-6u23-linux-i586.bin" package. So take a look ...

To install Java with .bin file, first give it execution permission by

#chmod 777 jre-6u23-linux-i586.bin           (Very important step)

Now just run it with

#./jre-6u23-linux-i586.bin





Installed ... Now to configure any settings you have to see it's manual or README file if provided with package, because every utility have different configuration steps.

What is difference between SetUID, SetGID & Sticky Bits ?

What is difference between SetUID, SetGID & Sticky Bits ?

         This question is one of the most important one in Linux interviews. So here we go !


Set UID: When a Set UID bit is turned on for a program, your EUID (effective user ID) becomes the same as the program’s owner when you run the program. You also gain all the privileges of the program’s owner. In other words, if user freddie runs a Set UID program owned by user root, freddie has superuser privileges while that program is running. Set UID affects programs only; it’s really not important for data files and directories. If you find a Set UID program, read the WARNING!!!

Warning: Set UID programs are potentially dangerous.Users can gain extra privileges by using files that grant them superuser privileges.

Set GID: The Set GID bit works similarly to Set UID — anyone running the program gains all the privileges of the group. When the Set GID box is checked for a directory, the files in that directory belong to that group regardless of who puts the files in the directory.


Sticky bit: Checking the Sticky box affects directories only. If this box is checked, you can’t remove (or rename) a file in that directory unless you’re the file owner.

How to enable Telnet service on RHEL / CentOS 5 ?

How to enable Telnet service on RHEL / CentOS 5 ? 

Generally in production servers we dont use Telnet connections because this doesn't use encrypted format of trasfer or session. But some applications need this to be enabled on the server to communicate. By default this service always kept disabled.

To enable it, First take a backup of "/etc/xinetd.d/telnet" configuration file;

#cp /etc/xinetd.d/telnet /etc/xinetd.d/telnet.bak

Now to start edit "/etc/xinetd.d/telnet" file,

#vi /etc/xinetd.d/telnet

Here "xinetd" word means X Internet Deamon.

Search for the "disable = yes" & replace it with "disable = no".



Remember here in example i have commented 1st "disable" statement. So dont get confuse.

Next save file & restart "xinetd" service

#service xinetd restart


Done ...

How to install Webmin on RHEL OR CentOS 5 ?

How to install Webmin on RHEL OR CentOS 5 ?


What is Webmin ?

Webmin is a web-based interface for system administration for Unix. Using any modern web browser, you can setup user accounts, Apache, DNS, file sharing and much more. Webmin removes the need to manually edit Unix configuration files like /etc/passwd, and lets you manage a system from the console or remotely.
You can download webmin through " www.webmin.com/download.html".

How do i install it to start web administration of my server ?

1. NOTE : Please note down that to use Webmin, you should have proper static IP.


2. Two methods of Webmin installation;

A. By rpm package,

  Here i am installing "webmin-1.530-1.noarch.rpm" on CentOS 5.3,

#rpm -ivh webmin-1.530-1.noarch.rpm



Here in the above snap as shown, after installation you will get the login link,

https://localhost.localdomain:10000/

e.g.

https://192.168.44.128:10000/

Instead of writing "localhost.localdomain", if you are login remotely provide "IP" or hostname of your server with "10000" port number. Note that it always work on secure "https" connection with only port number "10000". For login always remember that you can access it with your current "root" username & same password.







B. Installation by source code compilation : Generally on production server we use this installation because here you can set installation path, port number, user etc.

1. Make sure you have installed all the package related to compiler,

#rpm -qa make gcc

2. Download the source of Webmin "webmin-1.530.tar.gz" & Untar it,

#tar -zxvf webmin-1.530.tar.gz



3. Go to the extracted folder,

#cd /root/Desktop/webmin-1.530

4. run "setup.sh" script,

#./setup.sh

Now you have to give some answers for proper configuration you need . like Below,




[root@localhost webmin-1.530]# ./setup.sh
***********************************************************************
*            Welcome to the Webmin setup script, version 1.530        *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.

Installing Webmin in /root/Desktop/webmin-1.530 ...

***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.

Config file directory [/etc/webmin]: <Press Enter>
Log file directory [/var/webmin]: <Press Enter>

***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.

Full path to perl (default /usr/bin/perl): <Press Enter>

Testing Perl ...
Perl seems to be installed ok

***********************************************************************
Operating system name:    CentOS Linux
Operating system version: 5.3

***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
 - What port to run the web server on. There must not be another
   web server already using this port.
 - The login name required to access the web server.
 - The password required to access the web server.
 - If the webserver should use SSL (if your system supports it).
 - Whether to start webmin at boot time.

Web server port (default 10000): <Press Enter>
Login name (default admin): root
Login password:
Password again:
Use SSL (y/n): y
Start Webmin at boot time (y/n): y
***********************************************************************
Creating web server config files..
..done

Creating access control file..
..done

Inserting path to perl into scripts..
..done

Creating start and stop scripts..
..done

Copying config files..
..done

Configuring Webmin to start at boot time..
Created init script /etc/rc.d/init.d/webmin
..done

Creating uninstall script /etc/webmin/uninstall.sh ..
..done

Changing ownership and permissions ..
..done

Running postinstall scripts ..
..done

Enabling background status collection ..
..done

Attempting to start Webmin mini web server..
Starting Webmin server in /root/Desktop/webmin-1.530
Pre-loaded WebminCore
..done

***********************************************************************
Webmin has been installed and started successfully. Use your web
browser to go to

  https://localhost.localdomain:10000/

and login with the name and password you entered previously.

Because Webmin uses SSL for encryption only, the certificate
it uses is not signed by one of the recognized CAs such as
Verisign. When you first connect to the Webmin server, your
browser will ask you if you want to accept the certificate
presented, as it does not recognize the CA. Say yes.

[root@localhost webmin-1.530]#



Thats it, you installed Webmin on server properly.


_Enjoy :)

Wednesday, December 29, 2010

How to disable USB Storage Devices on RHEL 5 ?

How to disable USB Storage Devices on RHEL 5 ?

The USB storage drive automatically detects USB flash or hard drives. You can easily force and disable USB storage devices under any Linux distribution. The modprobe program used for automatic kernel module loading and can be configured to not load the USB storage driver upon demand. This will prevent the modprobe program from loading the usb-storage module, but will not prevent root (or another program) from using the insmod program to load the module manually.

There are total three ways to do it,


1. Type the following command:
# echo 'install usb-storage : ' >> /etc/modprobe.conf

   You can also remove USB Storage driver, enter:
# ls /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko
# mv /lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko /root

2. Disable by BIOS

   Disable USB from system BIOS configuration option. Make sure BIOS is password protected.


3. By Grub option

   You can get rid of all USB devices by disabling kernel support for USB via GRUB. Open grub.conf or menu.lst (Under Debian / Ubuntu Linux) and append "nousb" to the kernel line as follows:

   kernel /vmlinuz-2.6.18-128.1.1.el5 ro root=LABEL=/ console=tty0 console=ttyS1,19200n8 nousb
  
   Save and close the file. Once done just reboot the system:

        # reboot



_Enjoy  :)

How to enable Hot-add Memory in Linux RHEL 5 ?

What if you have Hot-added memory in your RHEL 5 server but it's still displaying Last memory configuration ?

Step : 

1. Check if two modules are loaded properly by,

     #lsmod | grep acpi


                 acpiphp                      43673  0
                 acpi_memhotplug        42199  0

If not loaded, follow below steps;


     #modprobe acpiphp
     #modprobe acpi_memhotplug


2. Now increase your server memory with Hot-add memory module. This will be done by Hardware engineer directly on the server, i am not talking about on OS level.



3. Make a shell script like "memory_online.sh" with below contents,

"for a in /sys/devices/system/memory/memory*/state; 
 do 
 echo 'online' > "$a" 
 done" and then
 "cat /sys/devices/system/memory/memory*/state"

Save it & exit

For Ubuntu you have to try with another script as below,

#!/bin/sh
i=0
while [ $i -lt 4500 ]
do
   if [ -f /sys/devices/system/memory/memory$i/state ]
   then
      if grep "offline" /sys/devices/system/memory/memory$i/state
      then
         echo 'online' > /sys/devices/system/memory/memory$i/state
      fi
   fi
   i=`expr $i + 1`
done

4. Give this script execution permission by,

    #chmod 777 memory_online.sh

5. Next execute it & check memory in either "/proc/meminfo" file or by below command

   #free


Done.

How to compile kernel in RHEL and CentOS ?

Here i am compiling Kernel "linux-2.6.36.2" on CentOS 5.3

To create new custom kernel we will follow below steps;


1. Check for essential packages.
2. Find the kernelsource code.
3. Configure the new kernel.
4. Customize the kernel.
5. Build the kernel.
6. Edit entry in "/boot/grub/grub.conf" file.


Steps :

1. Before you start compiling a kernel ckeck following packages are installed or not,

gcc & make

#rpm -qa make gcc


2. You can download latest stable kernel from "Kernel.org", then download and untar "linux-2.6.36.2.tar.bz2" package,

#bunzip2 linux-2.6.36.2.tar.bz2
#tar xvf linux-2.6.36.2.tar



3. Now got to extracted directory of latest kernel

#cd linux-2.6.36.2



4. Copy Kernel source code directory "linux-2.6.36.2"in "/usr/src" directory,

#cp -r linux-2.6.36.2 /usr/src/


5. Go to "/usr/src/linux-2.6.36.2/" and run,

#make menuconfig



        Note : Don't get confuse here, 1st i was logged in the server with Putty, but to show you all the thing graphically i switched on GUI.




This will open Linux Kernel configuration window for you to select & load extra modules. Make selection as below, you can choose something different :)

6. Select modules whatever you want,  Click "Enter" to go to sub menu, & press "Space" to enable , load & disable modules.





Here i am enabling NTFS file system in Linux, to make it enable do like this,







7. Click on exit button twice to come out up to main menu. Press "Esc" twice to get & save configuration.






8. Now execute "make" command in the same folder as above.

#make

It will start compile your brand new kernel with selected modules.



It will take atleast 15 - 20 mins depending upon your server speed. Till that time you can have coffee, and relex :D

As compilation finishes, either you run this command,

#make modules && make modules_install && make install

Or you can execute it one by one like this,

#make modules
#make modules_install
#make install


9. Once the process is done, you will see new kernel entry in "/boot/grub/grub.conf" file.

Now open it in any editor, and replace below line

defualt=1

with,

defualt=0



10. In new kernel 2.6.35 and above we dont need to make "initrd*.img", it will be made automatically when you run "make install" command.

Now reboot & check kernel version by,

#uname -a

If it's booting from new kernel.


Congrats Compilation Finished !!!

Understanding /proc File system

Understanding /proc File system:

Files that contain configuration information for all the devices connected to your computer are scattered throughout the "/proc" file system. The /proc file system also contains files full of information about system resources.


1. /proc/bus/usb: This file contains all info about USB (Universal Serial Bus) devices currently plugged into your system. USB devices like mice, cameras, and serial storage devices currently connected to your computer.

2. /proc/scsi/scsi: This file contains all information about every SCSI devices currently attached to your system.

3. /proc/cpuinfo: This file contains a collection of all information about the system’s CPU.

4. /proc/crypto: The /proc/crypto file contains information about the current encryption algorithms and digital signature tools installed on your system.

5. /proc/meminfo: This file contains a wealth of information about your system’s memory resources.

6. /proc/filesystems: This file contains information about the all file system types that can be mounted on your system. Check out "/proc/filesystems" to find out what kind of drives you can mount on your system. If ntfs isn’t in the list, you can’t mount Windows drives on your Linux box.

7. /proc/bus/pci/devices: This file contains all info about PCI cards connected to your system.

8. /proc/bus/input/devices : This file contains all info about input devices like, Keyboard, mouse, webcam etc.

9. /proc/mdstat : This file contains all info about RAID device.

10. /proc/modules : This file contains all info about all the loaded modules on Linux box.

11. /proc/partitions : This file contains all info about all the available partitions.

12. /proc/swaps : This will display info about currently assigned swap space.

13. /proc/version : Will show same output as of "uname -a" command i.e. info about kernel and architecture.

14. /proc/mounts : Will show you all the mounted partitions with their respected mount points, same as by "mount" command.

15. /proc/ide/drivers : This will display info about currently added IDE devices.

Tuesday, December 28, 2010

How to install src.rpm packages in RHEL 6 ?

How to install *.src.rpm packages in RHEL 6 ?


Here i am installing "libpciaccess-0.12.1.fc14.src.rpm"

1. Copied libpciaccess-0.12.1.fc14.src.rpm on "/root/Desktop" location.

2. open console and go to "/root/Desktop".

3. Now give command,

#rpmbuild --rebuild libpciaccess-0.12.1.fc14.src.rpm




Here at the time i executed the above command it gave me a dependancy error to compile "libpciaccess-0.12.1.fc14.src.rpm" package, asked me for new version of "xorg-x11-util-macros" package, then i installed "xorg-x11-util-macros-1.3.0-1.fc12.noarch.rpm".

Now again i executed the same command,

#rpmbuild --rebuild libpciaccess-0.12.1.fc14.src.rpm

this time it executed properly without any error.

Keep in mind ; if its asking for any dependancy, you must resolve it, else you can't go for next step.


4. Next, if you check in "/root" folder you will find a new folder named "rpmbuild" with sub-folder's,

rpmbuild
|- BUILD
|- BUILDROOT
|- RPMS
|- SOURCES
|- SPECS
|- SRPMS

Here again in "RPMS" folder rou will find;

RPMS
|- noarch
|- x86_64 (As i am using RHEL 6 - 64Bit)
      |- libpciaccess-0.12.0-1.el6.x86_64.rpm
      |- libpciaccess-debuginfo-0.12.0-1.el6.x86_64.rpm
      |- libpciaccess-devel-0.12.0-1.el6.x86_64.rpm

These above rpms are compiled from the "libpciaccess-devel-0.12.0-1.el6.x86_64.rpm" source package as per your system architecture.

Now go to,"/root/rpmbuild/RPMS/x86_64"

And install all three available rpms,

#rpm -ivh *.rpm

This command will install all the three available rpm's in that folder.


And now if you want to check the latest package verion provide, "#rpm -qa libpciaccess*" command



Package Installed ...

Cheer's ...

How to install and uninstall VMware Server 2.0.2 on CentOS 5 / RHEL 5 ?

How to install VMware Server 2.0.2 on CentOS 5 / RHEL 5 ?


VMware Server 2.0.2 is a open source server virtualization tool for Windows as well as Linux from VMware. Remember if you are installing VMware Server in VMware Workstation or on VMware ESX then dont install VMware Tools on your VM on which you are installing these product.

1. Getting VMware Server 2.0.2 : Go to http://downloads.vmware.com/d/info/datacenter_downloads/vmware_server/2_0 . Make an free account in VMware, download the package "VMware-server-2.0.2-203138.i386.tar"& get free installation keys.



2. Now extract the "VMware-server-2.0.2-203138.i386.tar" & you will see "vmware-server-distrib" folder in the same location.



3. Go to "vmware-server-distrib" folder by

# cd vmware-server-distrib



4. Next, run "./vmware-install.pl" command in terminal to execute "vmware-install.pl" script.




& Press <ENTER> to go with default options ...

-------------------------------------------OUTPUT--------------------------------------------------------


[root@km-vmqa-dhcp187 vmware-server-distrib]# ./vmware-install.pl

Creating a new VMware Server installer database using the tar4 format.

Installing VMware Server.

In which directory do you want to install the binary files?
[/usr/bin]    <ENTER>

What is the directory that contains the init directories (rc0.d/ to rc6.d/)?
[/etc/rc.d]   <ENTER>

What is the directory that contains the init scripts?
[/etc/rc.d/init.d]   <ENTER>

In which directory do you want to install the daemon files?
[/usr/sbin]   <ENTER>

In which directory do you want to install the library files?
[/usr/lib/vmware]   <ENTER>

The path "/usr/lib/vmware" does not exist currently. This program is going to
create it, including needed parent directories. Is this what you want?
[yes]   <ENTER>

In which directory do you want to install the manual files?
[/usr/share/man]   <ENTER>

In which directory do you want to install the documentation files?
[/usr/share/doc/vmware]   <ENTER>

The path "/usr/share/doc/vmware" does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes]   <ENTER>

The installation of VMware Server 2.0.2 build-203138 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command: "/usr/bin/vmware-uninstall.pl".

Before running VMware Server for the first time, you need to configure it by
invoking the following command: "/usr/bin/vmware-config.pl". Do you want this
program to invoke the command for you now? [yes]   <ENTER>

Making sure services for VMware Server are stopped.

Stopping VMware autostart virtual machines:
   Virtual machines                                        [FAILED]
Stopping VMware management services:
   VMware Virtual Infrastructure Web Access
   VMware Server Host Agent                                [FAILED]
Stopping VMware services:
   VMware Authentication Daemon                            [  OK  ]
   Virtual machine monitor                                 [  OK  ]

You must read and accept the End User License Agreement to continue.
Press enter to display it.   <ENTER>
.
.
.
.
.

Do you accept? (yes/no) yes   <Type yes & Enter>

Thank you.

The bld-2.6.18-8.el5-i686PAE-RHEL5 - vmmon module loads perfectly into the
running kernel.

The bld-2.6.18-8.el5-i686PAE-RHEL5 - vmci module loads perfectly into the
running kernel.

The bld-2.6.18-8.el5-i686PAE-RHEL5 - vsock module loads perfectly into the
running kernel.

Do you want networking for your virtual machines? (yes/no/help) [yes]   <ENTER>

Configuring a bridged network for vmnet0.

Please specify a name for this network.
[Bridged]   <ENTER>

The following bridged networks have been defined:

. vmnet0 is bridged to eth0

All your ethernet interfaces are already bridged.

Do you want to be able to use NAT networking in your virtual machines? (yes/no)
[yes]   <ENTER>

Configuring a NAT network for vmnet8.

Please specify a name for this network. [NAT]

Do you want this program to probe for an unused private subnet? (yes/no/help)
[yes]   <ENTER>

Probing for an unused private subnet (this can take some time)...

The subnet 172.16.171.0/255.255.255.0 appears to be unused.

This system appears to have a DHCP server configured for normal use.  Beware
that you should teach it how not to interfere with VMware Server's DHCP server.
There are two ways to do this:

1) Modify the file /etc/dhcpd.conf to add something like:

subnet 172.16.171.0 netmask 255.255.255.0 {
# Note: No range is given, vmnet-dhcpd will deal with this subnet.
}

2) Start your DHCP server with an explicit list of network interfaces to deal
with (leaving out vmnet8). e.g.:

dhcpd eth0

Consult the dhcpd(8) and dhcpd.conf(5) manual pages for details.

Hit enter to continue.    <ENTER>

The following NAT networks have been defined:

. vmnet8 is a NAT network on private subnet 172.16.171.0.

Do you wish to configure another NAT network? (yes/no) [no]   <ENTER>

Do you want to be able to use host-only networking in your virtual machines?
[yes]    <ENTER>

Configuring a host-only network for vmnet1.

Please specify a name for this network.
[HostOnly]    <ENTER>

Do you want this program to probe for an unused private subnet? (yes/no/help)
[yes]    <ENTER>

Probing for an unused private subnet (this can take some time)...

The subnet 192.168.126.0/255.255.255.0 appears to be unused.

This system appears to have a DHCP server configured for normal use.  Beware
that you should teach it how not to interfere with VMware Server's DHCP server.
There are two ways to do this:

1) Modify the file /etc/dhcpd.conf to add something like:

subnet 192.168.126.0 netmask 255.255.255.0 {
# Note: No range is given, vmnet-dhcpd will deal with this subnet.
}

2) Start your DHCP server with an explicit list of network interfaces to deal
with (leaving out vmnet1). e.g.:

dhcpd eth0

Consult the dhcpd(8) and dhcpd.conf(5) manual pages for details.

Hit enter to continue.    <ENTER>

The following host-only networks have been defined:

. vmnet1 is a host-only network on private subnet 192.168.126.0.

Do you wish to configure another host-only network? (yes/no) [no]   <ENTER>

The bld-2.6.18-8.el5-i686PAE-RHEL5 - vmnet module loads perfectly into the
running kernel.

Please specify a port for remote connections to use [902]    <ENTER>

Please specify a port for standard http connections to use [8222]    <ENTER>

Please specify a port for secure http (https) connections to use [8333]    <ENTER>

The current administrative user for VMware Server  is ''.  Would you like to
specify a different administrator? [no]    <ENTER>

Using root as the VMware Server administrator.

In which directory do you want to keep your virtual machine files?
[/var/lib/vmware/Virtual Machines]     <ENTER>

The path "/var/lib/vmware/Virtual Machines" does not exist currently. This
program is going to create it, including needed parent directories. Is this
what you want? [yes]     <ENTER>

Please enter your 20-character serial number.

Type XXXXX-XXXXX-XXXXX-XXXXX or 'Enter' to cancel:  A01AJ-PY08R-09NC6-4832R   <ENTER>

Creating a new VMware VIX API installer database using the tar4 format.

Installing VMware VIX API.

In which directory do you want to install the VMware VIX API binary files?
[/usr/bin]     <ENTER>

In which directory do you want to install the VMware VIX API library files?
[/usr/lib/vmware-vix/lib]     <ENTER>

The path "/usr/lib/vmware-vix/lib" does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes]     <ENTER>

In which directory do you want to install the VMware VIX API document pages?
[/usr/share/doc/vmware-vix]     <ENTER>

The path "/usr/share/doc/vmware-vix" does not exist currently. This program is
going to create it, including needed parent directories. Is this what you want?
[yes]    <ENTER>

The installation of VMware VIX API 1.6.2 build-203138 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command: "/usr/bin/vmware-uninstall-vix.pl".

Enjoy,

--the VMware team

Starting VMware services:
   Virtual machine monitor                                 [  OK  ]
   Virtual machine communication interface                 [  OK  ]
   VM communication interface socket family:               [  OK  ]
   Virtual ethernet                                        [  OK  ]
   Bridged networking on /dev/vmnet0                       [  OK  ]
   Host-only networking on /dev/vmnet1 (background)        [  OK  ]
   DHCP server on /dev/vmnet1                              [  OK  ]
   Host-only networking on /dev/vmnet8 (background)        [  OK  ]
   DHCP server on /dev/vmnet8                              [  OK  ]
   NAT service on /dev/vmnet8                              [  OK  ]
   VMware Server Authentication Daemon (background)        [  OK  ]
   Shared Memory Available                                 [  OK  ]
Starting VMware management services:
   VMware Server Host Agent (background)                   [  OK  ]
   VMware Virtual Infrastructure Web Access
Starting VMware autostart virtual machines:
   Virtual machines                                        [  OK  ]

The configuration of VMware Server 2.0.2 build-203138 for Linux for this
running kernel completed successfully.

[root@km-vmqa-dhcp187 vmware-server-distrib]#



Installation Done :)

Reboot & start working on VMware Server.

And if you want to uninstall it, then

#vmware-uninstall.pl


VMware Server Uninstalled !!!

Installed RHEL 6, but not getting network connection up ?

It's a reported bug for RHEL 6, Follow these steps to get up and running network connection ...

Edit "/etc/sysconfig/network-scripts/ifcfg-eth0" file, which is your defualt first NIC configuration file.

If you are using DHCP server to take IP then, edit it like this;

#vi /etc/sysconfig/network-scripts/ifcfg-eth0


ONBOOT="yes"
BOOTPROTO="dhcp"

Save & restart networking service,

#service network restart               OR
#/etc/init.d/network restart



If you are providing manual IP then, edit it like this;


DEVICE=eth0
           IPADDR=10.10.10.10
           NETMASK=255.255.255.0
           NETWORK=10.10.10.0
GATEWAY=10.10.10.253
           ONBOOT=yes
           BOOTPROTO=none
           USERCTL=no
Save & restart networking service,
#service network restart               OR
#/etc/init.d/network restart
OR you can use simple Network Configuration tool  to configure IP's but the highlighted two lines are compulsory to add manually in the file.
  

Command Shortcuts in Linux

Command Prompt Shortcuts :


/ - root directory

./ - current directory

./command_name - run a command in the current directory when the current directory is not on the path

../ - parent directory

~ - home directory

$ - typical prompt when logged in as ordinary user

# - typical prompt when logged in as root or superuser

! - repeat specified command

!! - repeat previous command

^^ - repeat previous command with substitution

& - run a program in background mode

[Tab][Tab] - prints a list of all available commands. This is just an example of autocomplete with no restriction on the first letter.

x[Tab][Tab] - prints a list of all available completions for a command, where the beginning is ``x''

[Alt][Ctrl][F1] - switch to the first virtual text console

[Alt][Ctrl][Fn] - switch to the nth virtual text console. Typically, there are six on a Linux PC system.

[Alt][Ctrl][F7] - switch to the first GUI console, if there is one running. If the graphical console freezes, one can switch to a nongraphical console, kill the process that is giving problems, and switch back to the graphical console using this shortcut.

[ArrowUp] - scroll through the command history (in bash)

[Shift][PageUp] - scroll terminal output up. This also works at the login prompt, so you can scroll through your boot messages.

[Shift][PageDown] - scroll terminal output down


[Ctrl][Alt][+] - switch to next X server resolution (if the server is set up for more than one resolution)

[Ctrl][Alt][-] - change to previous X server resolution

[Ctrl][Alt][BkSpc] - kill the current X server. Used when normal exit is not possible.

[Ctrl][Alt][Del] - shut down the system and reboot

[Ctrl]c - kill the current process

[Ctrl]d - logout from the current terminal

[Ctrl]s - stop transfer to current terminal

[Ctrl]q - resume transfer to current terminal. This should be tried if the terminal stops responding.

[Ctrl]z - send current process to the background

reset - restore a terminal to its default settings

[Leftmousebutton] - Hold down left mouse button and drag to highlight text. Releasing the button copies the region to the text buffer under X and (if gpm is installed) in console mode.

[Middlemousebutton] - Copies text from the text buffer and inserts it at the cursor location. With a two-button mouse, click on both buttons simultaneously. It is necessary for three-button emulation to be enabled, either under gpm or in XF86Config.

How to Enable / Disable, Firewall / SELinux ?

What is Firewall ?

Firewall (IPTables): IPTables is software based firewall that provides protection between your server and damaging content on the Internet or network. It will try to guard your server against both malicious users and software such as viruses / worms.


How to disable IPTables ?

You must be a Root user.

#service iptables save (Will save your existing IPTable Rules)
#service iptables stop (It will disable firewall Temporarly)

To Disable it Permanentely:

#chkconfig iptables off


To Enable it again:

#service iptables start (It will enable firewall Temporarly)


To enable it Permanentely:

#chkconfig iptables on


You can also use;

#system-config-securitylevel
#system-config-securitylevel-tui



Apply & "Ok".


SELinux : Also known as Security-Enhanced Linux, implements various security policies on Linux and additional levels of access crontrol.


To disable SELinux,

edit file "/etc/selinux/config" and find line;

SELINUX=enforcing

Now replace it with,

SELINUX=disabled

Now if you save & reboot your machine, it'll be disabled but if you dont want to reboot it now then, you can use following command;

#setenforce 0

This will put SELinux in to the "Permissive mode", means it will run & log your whole session till next reboot, but will not controll the permission or you can say access.

You can also use;

#system-config-securitylevel
#system-config-securitylevel-tui



Apply & "Ok".

Important configuration files in RHEL / CentOS

Important Linux Config Files :


For Configuring Ethernet card :-

/etc/hosts (Uses to maintain IP to Hostname to IP convention )

/etc/resolv.conf (DNS Servers for connectivity)

/etc/sysconfig/network (Contains gateway, hostname etc.)

/etc/sysconfig/network-scripts/ifcfg-eth0 (Defualt Network card configuration like IP, MAC address, Subnet mask etc.)


For adduser command :-

/etc/passwd (File contains info about user like UserID, shell, Username, Defualt Directory etc.)

/etc/shadow (File contains mainly encrypted password of a user)

/etc/group (Contains info about groups)

/etc/gshadow (Info about group & related users)

/etc/login.defs (File defines the site-specific configuration for the shadow password suite)

/etc/shells (Contains name of all the types of shells available)


Configuration file for the color ls utility :-

/etc/DIR_COLORS


Configuration file for the grub loader and other related files:-

/etc/grub.conf - Symbolic link of below file

/boot/grub/grub.conf (Grand Unified Boot Loader configuration file)

/boot/vmlinuz-2.6.18-128.el5 (Kernel file, cant be edited just included for your reference)

/boot/initrd-2.6.18-128.el5.img (Initial RAM Disk image)


Configuration files for boot processes :-

/etc/fstab   (descriptive information about the various file systems.)

/etc/inittab   (This file describes how the INIT process should set up the system in a certain run-level.)

/etc/rc.d/rc.sysinit   (starts networking subsystems.)

/etc/rc.d/rc   (This file is responsible for starting/stopping services when the runlevel changes.)

/etc/rc.d/init.d/functions  (This file contains functions to be used by most or all shell scripts in the /etc/init.d directory. Symbolic link - /etc/init.d/functions )

/etc/rc.d/rc*.d/   (contains all startup and kill scripts. Symbolic link - /etc/rc*.d )


Other Configuration files :-

/etc/redhat-release   (printing the banner at login screen.)

/etc/shutdown.allow   (allowing only specified users to shutdown.)

/etc/profile   (System wide environment and startup programs, for login setup)

/etc/inputrc (for terminal settings.)

/etc/profile.d/*.sh (shell scripts needed for login.)

/etc/bashrc   (System wide functions and aliases.)

/etc/modules.conf   (aliases for modules are set.)

/etc/exports   (NFS Server Configuration File, Linux to Linux file transfer)

/etc/vsftpd/vsftpd.conf (FTP Configuration File)

/etc/samba/smb.conf (Samba Server Configuration file, Linux - Windows & Linux - Linux with authentication)

/etc/httpd/conf/httpd.conf (Web server Apache configuration file)

/etc/squid/squid.conf (Proxy Server Configuration file, Bydefualt uses Port No. 3128)

/sbin/shutdown (Used to reboot or shutdown pc)

/sbin/mingetty (Virtual consoles)


Log Files :-

/bin/dmesg (Boot time loaded configurations & Driver details)

/var/log/messages (Real Time Warning, Info messages or logs)

Important RHEL Directories & their usage

Important Linux Directories :


Different distributions have different directory structures, despite attempts at standardization such as the the Linux Filesystem Hierarchy Standard (FHS) organization.

/bin - essential UNIX commands such as ls, etc. Should contain all binaries needed to boot the system or run it in single-user mode

/boot - files used during booting and possibly the kernel itself are stored here

/dev - contains device files for various devices on system

/etc - files used by subsystems such as networking, NFS, and mail. Includes tables of disks to mount, processes to run on startup, etc.

/etc/profile.d - contains scripts that are run by /etc/profile upon login.

/etc/rc.d - contains a number of shell scripts that are run on bootup at different run levels. A rc.local script that can be edited to run commands desired by the administrator, along the lines of autoexec.bat in DOS.

/etc/rc.d/init.d - contains most of the initialization scripts themselves on an rpm-based system.

/etc/rc.d/rc*.d - where ``*'' is a number corresponding to the default run level. Contains files for services to be started and stopped at that run level. On rpm-based systems, these files are symbolic links to the initialization scripts themselves, which are in /etc/rc.d/init.d.

/etc/skel - directory containing several example or skeleton initialization shells. Often contains subdirectories and files used to populate a new user's home directory.

/etc/X11 - configuration files for the X Window system

/home - home directories of individual users

/lib - standard shared library files

/lib/modules - modular device driver files, most with .o extensions

/mnt - typical mount point for many user-mountable devices such as floppy drives, cd-rom readers, etc. Each device is mounted on a subdirectory of /mnt.

/proc - virtual file system that provides a number of system statistics

/root - home directory for root

/sbin - location of binaries used for system administration, configuration, and monitoring

/tmp - directory specifically designed for programs and users to store temporary files.

/usr - directory containing a number of subdirectory with programs, libraries, documentation, etc.

/usr/bin - contains most user commands. Should not contain binaries necessary for booting the system, which go in /bin. The /bin directory is generally located on the same disk partition as /, which is mounted in read-only mode during the boot process. Other filesystems are only mounted at a later stage during startup, so putting binaries essential for boot here is not a good idea.

/usr/bin/X11 - most often a symbolic link to /usr/X11R6/bin, which contains executable binaries related to the X Window system

/usr/share/doc - location of miscellaneous documentation, and the main location of program documentation files in RHL

/usr/share - contains subdirectories where many installed programs have configuration, setup and auxiliary files

/usr/share/info - primary location of the GNU info system files [.gz]

/usr/include - standard location of include files used in C programs such as stdio.h

/usr/lib - standard library files such as libc.so. Searched by the linker when programs are compiled.

/usr/lib/X11 - X Window system distribution

/usr/local/bin - yet another place to look for comon executables

/usr/share/man - location of manual page files

/usr/sbin - other commands used by superuser for system administration

/usr/src - location of source programs used to build system. Source code for programs of all types are often unpacked in this directory.

/usr/src/linux - often a symbolic link to a subdirectory whose name corresponds to the exact version of the Linux kernel that is running. Contains the kernel sources.

/var - administrative files such as log files, mail files etcu sed by various utilities

/var/spool - temporary storage for files being printed, mail that has not yet been picked up, etc.

Working with "crontab" Scheduler

Cron is a handy little utility that helps the system administrator automate repetitive tasks. In Linux, tasks can be configured to run automatically within a given period of time and on given dates. Red Hat Linux comes preconfigured to run certain system tasks to keep your system updated. For example, the slocate database is updated daily. A system administrator can use automated tasks to perform periodic backups, monitor the system, run custom scripts etc. It uses "crond" deamon.

The cron system uses the following files:

/usr/sbin/crond - The cron service which runs continuously
/etc/crontab - The system cron table, which specifies def jobs defined by RHEL
/usr/bin/crontab - Users create and manage cron table entries
/var/spool/cron/* - The directory that holds cron files created by users
/etc/cron.d/* - The directory that holds cron files created by package installation scripts
/etc/cron.allow - Access Allow File
/etc/cron.deny  - Access Deny File
/etc/cron.hourly/ - If you put any script in this folder they will be executed automatically in every hour.
/etc/cron.daily/   - If you put any script in this folder they will be executed automatically every day basis.
/etc/cron.weekly/ - If you put any script in this folder they will be executed automatically in every week.
/etc/cron.monthly/ - If you put any script in this folder they will be executed automatically in every month.

Crontab Environment :

cron invokes the command from the user’s HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=<Users Home Dir>
LOGNAME=<Users Login ID>
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh


Adding Cron Jobs :

#crontab -e

* * * * * <Command to execute>



# crontab -u ashish -e (Root can edit cron job for User Ashish)


If you have created any file & you want to import it to use by Crontab then;

#crontab -u ashish ashish_cron.txt


Deleting user crontab :

#crontab -r (Either you can use it for root or you are logged in as any other user)

OR

#crontab -u ashish -r (Remove crontab for user Ashish)


Listing users crontab :

#crontab -l

OR

#crontab -u ashish -l


How to start/stop cron service :

#service crond start
#service crond stop


Disable Email from cron after every task :

By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .

>/dev/null 2>&1

Generate log file after every task :
To collect the cron execution execution log in a file :

10 10 * * * rm /home/ashish/tmp/* > /home/ashish/cronlogs/clean_tmp_dir.log


Other examples :


Example 1:

30 08 10 06 * /home/ashish/Full_backup.sh

30 – 30th Minute
08 – 08 AM
10 – 10th Day
06 – 6th Month (June)
* – Every day of the week


Example 2:

The variation of scheduling can be subtle, but here are a few examples:
To schedule a job twice a day:

00 11,16 * * * /home/ashish/bin/incr_backup.sh

00 – 0th Minute (Top of the hour)
11,16 – 11 AM and 4 PM
* – Every day
* – Every month
* – Every day of the week


Example 3:

*/5 * * * * <Command>

This will do the same, executing every 5 minutes.