date time



For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
 
# date  -s   "2 OCT 2006 18:00:00"
 
OR

# date --set="2 OCT 2006 18:00:00"

You can also simplify format using following syntax:
 
# date +%Y%m%d -s "20081128"

$ date --date="12/2/2014"
Tue Dec  2 00:00:00 PST 2014

$ date --date="2 Feb 2014"
Sun Feb  2 00:00:00 PST 2014

$ date --date="Feb 2 2014"
Sun Feb  2 00:00:00 PST 2014


Linux Set Time
To set time use the following syntax:

# date  +%T  -s  "10:13:13"

Set timezone using /etc/localtime configuration file [any Linux distro]

Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory.

Generic procedure to change timezone under Linux

Cd to /etc, run:
# cd /etc
Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtime
OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends):
# ln -sf /usr/share/zoneinfo/EST localtime
OR if you want to set up it to Asia/Kathmandu
# ln -sf /usr/share/zoneinfo/Asia/Kathmandu localtime
Various Date Command Formats
You can use formatting option to display date command in various formats using the following syntax:
$ date +%<format-option>
The following table displays various date command formatting options.
Format options
Purpose of Option
Output
date +%a
Displays Weekday name in short (like Mon, Tue, Wed)
Thu
date +%A
Displays Weekday name in full short (like Monday, Tuesday)
Thursday
date +%b
Displays Month name in short (like Jan, Feb, Mar )
Feb
date +%B
Displays Month name in full short (like January, February)
February
date +%d
Displays Day of month (e.g., 01)
07
date +%D
Displays Current Date; shown in MM/DD/YY
02/07/13
date +%F
Displays Date; shown in YYYY-MM-DD
2013-02-07
date +%H
Displays hour in (00..23) format
23
date +%I
Displays hour (01..12) format
11
date +%j
Displays day of year (001..366)
038
date +%m
Displays month (01..12)
02
date +%M
Displays minute (00..59)
44
date +%S
Displays second (00..60)
17
date +%N
Displays nanoseconds (000000000..999999999)
573587606
date +%T
Displays time; shown as HH:MM:SS
Note: Hours in 24 Format
23:44:17
date +%u
Displays day of week (1..7); 1 is Monday
4
date +%U
Displays week number of year, with Sunday as first day of week (00..53)
05
date +%Y
Displays full year i.e. YYYY
2013
date +%Z
alphabetic time zone abbreviation (e.g., EDT)
IS

vim

:set number   ##display line num

case insensitive search set on and off

:set ic
:set noic

Apache webserver 2.2.15.el6 (centos 6.4 x86) part1



Apache
yum install httpd -y

inside /etc/httpd/conf/httpd.conf
line 57
ServerRoot   /etc/httpd  ##ServerRoot is the path to the server’s configuration, error and log                                      files.. it can be changed [ no trailing / at end of path e.g /etc/httpd/  ]
line 65
PidFile  run/httpd.pid
##PidFile is the process identification number for the httpd. This process number
is important, because Apache spawns numerous child processes when running
to accommodate the web traffic. It allows you to monitor and manipulate your
server processes

Line 276
ServerName www.ninja.com:80
this setting you will have to change to get your server running. This
is where you declare the name of your website. I will use www.ninja.com
Line 292
DocumentRoot "/var/www/html"
Line 484
ErrorLog logs/error_log
Line 136
Listen 80

Virtual Hosts

Running several name-based web sites on a single IP address.

You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing,

Listen 80 #this is default

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
# Other directives here
</VirtualHost>

or  

NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40>   ##172.20.30.40 is real ip of system
DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here
</VirtualHost> 
 
The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.example1.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first VirtualHost.
------------------------------------------------------------------------------------------------
For example, suppose that you are serving the domain www.domain.tld and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address. Then you simply add the following to httpd.conf:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
You can alternatively specify an explicit IP address in place of the * in both the NameVirtualHost and <VirtualHost> directives. For example, you might want to do this in order to run some name-based virtual hosts on one IP address, and either IP-based, or another set of name-based virtual hosts on another address.
Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example in the first <VirtualHost> block above, the ServerAlias directive indicates that the listed names are other names which people can use to see that same web site:
ServerAlias domain.tld *.domain.tld
then requests for all hosts in the domain.tld domain will be served by the www.domain.tld virtual host. The wildcard characters * and ? can be used to match names. Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server.
The complete list of names in the VirtualHost directive are treated just like a (non wildcard) ServerAlias.
Finally, you can fine-tune the configuration of the virtual hosts by placing other directives inside the <VirtualHost> containers. Most directives can be placed in these containers and will then change the configuration only of the relevant virtual host. To find out if a particular directive is allowed, check the Context of the directive. Configuration directives set in the main server context (outside any <VirtualHost> container) will be used only if they are not overridden by the virtual host settings.
Now when a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each <VirtualHost> section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.
As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches the NameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a <VirtualHost> container and list it first in the configuration file.


Name-based hosts on more than one IP address.
# This is the other address
NameVirtualHost 172.20.30.50

<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example1.com

# Other directives here ...

</VirtualHost>

<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example2.org

# Other directives here ...

</VirtualHost> 

Any request to an address other than 172.20.30.50 will be served from the main server. A request to 172.20.30.50 with an unknown hostname, or no Host: header, will be served from www.example1.com. 

Serving the same content on different IP addresses (such as an internal and external address).

The server machine has two IP addresses (192.168.1.1 and 172.20.30.40). The machine is sitting between an internal (intranet) network and an external (internet) network. Outside of the network, the name server.example.com resolves to the external address (172.20.30.40), but inside the network, that same name resolves to the internal address (192.168.1.1).
The server can be made to respond to internal and external requests with the same content, with just one VirtualHost section.

Server configuration

NameVirtualHost 192.168.1.1
NameVirtualHost 172.20.30.40

<VirtualHost 192.168.1.1 172.20.30.40>
DocumentRoot /www/server1
ServerName server.example.com
ServerAlias server
</VirtualHost>
Now requests from both networks will be served from the same VirtualHost.

Note:

On the internal network, one can just use the name server rather than the fully qualified host name server.example.com.
Note also that, in the above example, you can replace the list of IP addresses with *, which will cause the server to respond the same on all addresses.

Running different sites on different ports.

You have multiple domains going to the same IP and also want to serve multiple ports. By defining the ports in the "NameVirtualHost" tag, you can allow this to work. If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.

Server configuration

Listen 80
Listen 8080

NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080

<VirtualHost 172.20.30.40:80>
ServerName www.example1.com
DocumentRoot /www/domain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example1.com
DocumentRoot /www/domain-8080
</VirtualHost>

<VirtualHost 172.20.30.40:80>
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>

IP-based virtual hosting

The server has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.example1.com and www.example2.org respectively.

Server configuration

Listen 80

<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example1.com
</VirtualHost>

<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example2.org
</VirtualHost> 


Mixed port-based and ip-based virtual hosts

The server machine has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.example1.com and www.example2.org respectively. In each case, we want to run hosts on ports 80 and 8080.

Server configuration

Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080

<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example1.com
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName www.example1.com
</VirtualHost>

<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example1.org
</VirtualHost>

<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example2.org
</VirtualHost> 


Mixed name-based and IP-based vhosts

Server configuration

Listen 80

NameVirtualHost 172.20.30.40

<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example1.com
</VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/example2
ServerName www.example2.org
</VirtualHost>

<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName www.example3.net
</VirtualHost>

# IP-based
<VirtualHost 172.20.30.50>
DocumentRoot /www/example4
ServerName www.example4.edu
</VirtualHost>

<VirtualHost 172.20.30.60>
DocumentRoot /www/example5
ServerName www.example5.gov
</VirtualHost> 

 





 

Multiple SSL Certificate install on apache2 server  [Ubuntu 12.04]
Enable SSL on your webserver
sudo a2enmod ssl
Follow up by restarting Apache.
sudo service apache2 restart
Copy your SSL certificate and key to any location
Eg. Here we copied to /etc/apache2/ssl  
Make sure permission of those files are 400 or 600 [root only read/write]
In   sites/sites-available/<your domains>

vim btlg.com.au
<VirtualHost *:80>
ServerName btlg.com.au 
ServerAlias 
www.btlg.com.au
DocumentRoot /home/bootleg/public_html
</VirtualHost>
<VirtualHost *:443>
ServerName btlg.com.au
ServerAlias 
www.btlg.com.au
DocumentRoot /home/bootleg/public_html
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/btlg/281027f6c6f445.crt
SSLCertificateKeyFile /etc/apache2/ssl/btlg/www_btlg_com_au.key 
SSLCertificateChainFile /etc/apache2/ssl/btlg/sf_bundle-g2-g1.crt
</VirtualHost>

vim example.com.au
<VirtualHost *:80>
ServerName btlg.com.au 
ServerAlias
example.com.au
DocumentRoot /home/example.com/public_html
</VirtualHost>
<VirtualHost *:443>
ServerName
example.com.au
ServerAlias www.example.com.au
DocumentRoot /home/example.com/public_html
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/example/281027f6c6f445.crt
SSLCertificateKeyFile /etc/apache2/ssl/example/www_example_com_au.key 
SSLCertificateChainFile /etc/apache2/ssl/btlg/sf_bundle-g2-g1.crt
</VirtualHost>


Restart apache2 and browse to your domain with http or https

Restricting  virtual host by ip address example

<virtualhost *:80>
ServerName mail.rpmanpower.com
ServerAlias mail.rpmanpower.com
ServerAdmin zadmin@localhost
DocumentRoot "/etc/zpanel/panel/etc/apps/webmail"
<Location />
Order deny,allow
Deny from all
Allow from 182.93.95.225 198.50.239.107
</Location>
</virtualhost>

this will restrict access to all ip address to mail.rpmanpower.com
EXCEPT 182.93.95.225 198.50.239.107  thest TWO CAN ACCESS

Deny only one ip 192.168.16.100
<Location /server-status>
    SetHandler server-status
    Order Allow,Deny
    Deny from  192.168.16.100
    Allow from 192.168.16.0/24
</Location>
Deny from all is not needed. In fact it will screw up because everything will match all, and thus denied (and I think Apache is trying to be smart and do something stupid). I have always found Apache's Order, Allow and Deny directives confusing, so always visualize things in a table (taken from the docs):
Match      | Allow,Deny result   | Deny,Allow result
-------------------------------------------------------
Allow only | Allowed             | Allowed
Deny only  | Denied              | Denied
No match   | Default: Denied     | Default: Allowed
Match both | Final match: Denied | Final match: Allowed
With the above settings:
  • Requests from 192.168.16.100 get "Match both" and thus denied.
  • Requests from 192.168.16.12 get "Allow only" and thus allowed.
  • Requests from 123.123.123.123 get "No match" and thus denied.

Apache 2.4.X  restricting URLS (ubuntu 14.04.X)

open up the apache host ffile and add below to allow only listed IP to access this url

 Example 2:
===========

<VirtualHost *:80>
...
ServerName hottiehunter.com
        ServerAlias  www.hottiehunter.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/hottiehunter/public
<Location /admin>
             Require ip 202.51.76.236 110.44.116.70 202.51.76.238

</Location>

 <Directory /var/www/hottiehunter/public>
        Options -Indexes
        </Directory>



Example 2
========

Alias /PMA /usr/share/phpmyadmin
<Location /PMA>
Require ip 202.51.76.236 110.44.116.70 202.51.76.238
</Location>

<Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        DirectoryIndex index.php

<IfModule mod_php5.c>
                AddType application/x-httpd-php .php
....
......


NICE RENICE

The process scheduling priority range is from -20 to 19. We call this as nice value.
A nice value of -20 represents highest priority, and a nice value of 19 represent least priority for a process.
By default when a process starts, it gets the default priority of 0.
# nice -5 perl script.pl    {for 5}
# nice --10 perl test.pl {for -10}
 
$ ps -fl -C "perl test.pl" 
 
Change running pprocesses  

# renice -n -19 -p 3534
 
# renice -n 5 -g apache  (of group apache) 
 
# renice -n 5 -u hari    {of user hari}


Traffic control and HTB

"tc" is the command-line tool to interact with the Linux kernel's traffic control subsystem, and the "htb" is queuing disciplines that can be used within the "tc" command to shape and prioritize network traffic.

primary egress(outgoing traffic) queuing discipline on any device is known as the root qdisc.

HTB make sure that each class gets at least the minimum of the amount of service assigned to it when requested by that class. When a class requests less than the amount assigned, the remaining (excess) bandwidth is distributed to other classes which request service

# Create the root qdisc, here eth0 is internet link
tc qdisc add dev eth0 root handle 1: htb default 1000
The default 1000 means that any traffic that is not otherwise classified will be assigned to class 1:1000



handles are written X : Y where x is an integer identifying a qdisc(queuing discipline) and y is an integer identifying a class belonging to that qdisc. The handle for a qdisc must have zero for its y value and the handle for a class must have a non-zero value for its y value. The "1:" above is treated as "1:0".tc class add dev eth0 parent 1: classid 1:1 htb rate 2mbit ceil 2mbit burst 1k


here burst=1kilobyte (burst < mtu=1500 B) to avoid fragmentation# Define variables


### Define variables
INTERNET_INTERFACE="eth1" ### Interface connected to the internet
LOCAL_NETWORK_INTERFACE="eth0" ### Interface connected to the local network
GENERAL_RATE="5mbit" ### General rate for all machines except specific ones
SPECIFIC_MAC_PC="aa:bb:cc:11:22:33" ### Specific MAC address of the PC with 10Mbps rate
SPECIFIC_MAC_LAPTOP="dd:ee:ff:44:55:66" ### Specific MAC address of the laptop with 15Mbps rate

### Enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

### Clear existing tc configuration
tc qdisc del dev $INTERNET_INTERFACE root
tc qdisc del dev $LOCAL_NETWORK_INTERFACE root
tc qdisc del dev ifb0 root

### Create ifb device
modprobe ifb numifbs=1
ip link set dev ifb0 up

### Configure HTB qdisc on the internet interface (upload)
tc qdisc add dev $INTERNET_INTERFACE root handle 1: htb default 9999

### Create default class for general rate (upload)
tc class add dev $INTERNET_INTERFACE parent 1: classid 1:9999 htb rate $GENERAL_RATE ceil $GENERAL_RATE burst 5k

### Create class for PC with specific MAC address (10Mbps) (upload)
tc class add dev $INTERNET_INTERFACE parent 1: classid 1:11 htb rate 10mbit ceil 10mbit burst 5k

### Create class for laptop with specific MAC address (15Mbps) (upload)
tc class add dev $INTERNET_INTERFACE parent 1: classid 1:12 htb rate 15mbit ceil 15mbit burst 5k

### Create filters to match specific MAC addresses and assign them to their respective classes (upload)
tc filter add dev $INTERNET_INTERFACE parent 1:0 protocol ip prio 1 u32 match u32 0 0 flowid 1:11 match mac $SPECIFIC_MAC_PC flowid 1:11
tc filter add dev $INTERNET_INTERFACE parent 1:0 protocol ip prio 1 u32 match u32 0 0 flowid 1:12 match mac $SPECIFIC_MAC_LAPTOP flowid 1:12

### Configure HTB qdisc on the local network interface (download)
tc qdisc add dev $LOCAL_NETWORK_INTERFACE root handle 1: htb default 9999

### Create default class for general rate (download)
tc class add dev $LOCAL_NETWORK_INTERFACE parent 1: classid 1:9999 htb rate $GENERAL_RATE ceil $GENERAL_RATE burst 5k

### Create filter to match all traffic and assign it to the default class (download)
tc filter add dev $LOCAL_NETWORK_INTERFACE parent 1:0 protocol ip prio 1 u32 match u32 0 0 flowid 1:9999

### Redirect incoming traffic to ifb0 for shaping (download)
iptables -A FORWARD -i $INTERNET_INTERFACE -j ifb0

### Configure HTB qdisc on ifb0 (download)
tc qdisc add dev ifb0 root handle 1: htb default 9999

### Create default class for general rate on ifb0 (download)
tc class add dev ifb0 parent 1: classid 1:9999 htb rate $GENERAL_RATE ceil $GENERAL_RATE burst 5k

### Create filter to match all traffic on ifb0 and assign it to the default class (download)
tc filter add dev ifb0 parent 1:0 protocol ip prio 1 u32 match u32 0 0 flowid 1:9999

+-------+   +------+                 +------+
|ingress|   |egress|   +---------+   |egress|
|qdisc  +--->qdisc +--->netfilter+--->qdisc |
|eth1   |   |ifb1  |   +---------+   |eth1  |
+-------+   +------+                 +------+


INTERNET_INTERFACE="eth1" LOCAL_NETWORK_INTERFACE="eth0" iptables -F iptables -t nat -F # Enable IP forwarding echo 1 > /proc/sys/net/ipv4/ip_forward # Set up iptables rules to redirect traffic to tc classes iptables -t mangle -A PREROUTING -i $INTERNET_INTERFACE -j MARK --set-mark 1 iptables -t nat -A POSTROUTING -o $INTERNET_INTERFACE -j MASQUERADE iptables -A FORWARD -i $INTERNET_INTERFACE -o $LOCAL_NETWORK_INTERFACE -m mark --mark 1 -j ACCEPT iptables -A FORWARD -i $LOCAL_NETWORK_INTERFACE -o $INTERNET_INTERFACE -j ACCEPT



Reference: http://luxik.cdi.cz/~devik/qos/htb/manual/userg.htm ,















PPTP

download pptpd for redhat based 64bit
http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.4.0-1.el6.x86_64.rpm

download pptpd for redhat based 32bit
http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.4.0-1.el6.i686.rpm

OS: CentOS 6 64bit
VPN server:  192.168.0.2
VPN client IP: 192.168.10.10 - 192.168.10.70
VPN username: vpnuser
Password: myVPN$99
1. Install ppp via yum:
$ yum install ppp -y
2. Download and install pptpd (the daemon for point-to-point tunneling). You can find the correct package at this website http://poptop.sourceforge.net/yum/stable/packages/  OR go above link at top of page:
$ cd /usr/local/src
$ wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.x86_64.rpm
$ rpm -Uhv pptpd-1.3.4-2.el6.x86_64.rpm
3. Once installed, open /etc/pptpd.conf using text editor and add following line:
localip 192.168.10.1        //your ip 
remoteip 192.168.10.10-70    //ip for remote distribution
4. Open /etc/ppp/options.pptpd and add  authenticate method, encryption and DNS resolver value:
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
5. create user to access the VPN server. Open /etc/ppp/chap-secrets and add the user as below:
vpnuser pptpd myVPN$99 *
The format is: [username] [space] [server] [space] [password] [space][IP addresses]
6. We need to allow IP packet forwarding for this server. Open /etc/sysctl.conf via text editor and change line below:

net.ipv4.ip_forward = 1

7. Run following command to take effect on the changes:
$ sysctl -p
8. Allow IP masquerading in IPtables by executing following line:
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ service iptables save
$ service iptables restart
 
Update: Once you have done with step 8, check the rules at /etc/sysconfig/iptables. Make sure that the POSTROUTING rules is above any REJECT rules.
9. Turn on the pptpd service at startup and reboot the server:
$ chkconfig pptpd on
$ init 6
Once the server is online after reboot, you should now able to access the PPTP server from the VPN client. >> monitor /var/log/messages for ppp and pptpd related log

If you would also like your PPTP clients to talk to each other, add the following iptables rules:
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -I INPUT -s 10.0.0.0/8 -i ppp0 -j ACCEPT
iptables -A FORWARD --in-interface eth0 -j ACCEPT













PAM - pluggable authentication module part 1

we begin by considering an example. We take an application that grants some service to users; login is one such program. Login does two things, it first establishes that the requesting user is whom they claim to be and second provides them with the requested service: in the case of login the service is a command shell (bash, tcsh, zsh, etc.) running with the identity of the user.
Traditionally, the former step is achieved by the login application prompting the user for a password and then verifying that it agrees with that located on the system; hence verifying that as far as the system is concerned the user is who they claim to be. This is the task that is delegated to Linux-PAM.
From the perspective of the application programmer (in this case the person that wrote the login application), Linux-PAM takes care of this authentication task -- verifying the identity of the user.
The flexibility of Linux-PAM is that you, the system administrator, have the freedom to stipulate which authentication scheme is to be used. You have the freedom to set the scheme for any/all PAM-aware applications on your Linux system. That is, you can authenticate from anything as naive as simple trust (pam_permit) to something as paranoid as a combination of a retinal scan, a voice print and a one-time password! 
Linux-PAM deals with four separate types of (management) task. These are: authentication management; account management; session management; and password management.
Here is a figure that describes the overall organization of Linux-PAM:
  +----------------+
  | application: X |
  +----------------+       /  +----------+     +================+
  | authentication-[---->--\--] Linux-   |--<--| PAM config file|
  |       +        [----<--/--]   PAM    |     |================|
  |[conversation()][--+    \  |          |     | X auth .. a.so |
  +----------------+  |    /  +-n--n-----+     | X auth .. b.so |
  |                |  |       __|  |           |           _____/
  |  service user  |  A      |     |           |____,-----'
  |                |  |      V     A
  +----------------+  +------|-----|---------+ -----+------+
                         +---u-----u----+    |      |      |
                         |   auth....   |--[ a ]--[ b ]--[ c ]
                         +--------------+
                         |   acct....   |--[ b ]--[ d ]
                         +--------------+
                         |   password   |--[ b ]--[ c ]
                         +--------------+
                         |   session    |--[ e ]--[ c ]
                         +--------------+
      If a program is going to use PAM, then it has to have PAM
      functions explicitly coded into the program. If you have
      access to the source code you can add the appropriate PAM
      functions. If you do not have access to the source code, and
      the binary does not have the PAM functions included, then
      it is not possible to use PAM.
    
 More @ http://www.linux-pam.org/Linux-PAM-html/sag-overview.html

In a nutshell, PAM the Pluggable Authentication Modules.
As its name implies it uses a plug-in style architecture. PAM makes it so that each program does not have to implement its own authentication mechanism. Instead it just checks the PAM stack.
Because PAM is pluggable you can configure the authentication stack however you like. Authenticating against LDAP, NIS, RADIUS, MySQL, Oracle, BerkelyDB, SQLite, RSA tokens, x509 certificates, flat files, one time passwords, Google two-factor, phases of the moon, etc. can all be configured in any combination.
PAM can also trigger actions such as mounting filesystems, creating directories, logging, or any other action when the stack is activated, fails or succeeds.
PAM is the authentication Swiss Army Knife, giving infinite flexibility to custom tailor authentication in any way necessary, for any application.
Without it every program would have to independently support all of these features, and that would be a sad world indeed.

Configure Multiple IP Adresses on single interface

#cd /etc/sysconfig/network-scripts
step1 --> #cp  ifcfg-eth0   ifcfgeth0:1

#cat ifcfg-eth0

DEVICE="eth0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
HWADDR=00:0C:29:28:FD:4C

step 2 -->
#vim ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.0.101
NETMASK=255.255.255.0
NETWORK=192.168.0.0
ONBOOT=yes

To setup up a range of ip address range assigned to n.w interface
#cp  ifcfg-etho ifcfg-etho-range0

                        #vim ifcfg-eth0-range0

#DEVICE="eth0"
BOOTPROTO=none
NM_CONTROLLED=no
ONBOOT=yes
TYPE="Ethernet"
IPADDR_START=192.168.0.120
IPADDR_END=192.168.0.190
NETMASK=255.255.255.0
IPV6INIT=no
USERCTL=no
CLONENUM_START=22   #{if   eth0:1,eth0:2 ..eth0:21 are already occupied} it will start from eth0:22
#GATEWAY=192.168.0.1


#service network reload
  you can also give different range/n.w address ..see the example below

Poor man's VPN / SSH SOCKS proxy config / Dynamic port forwarding

Scenario :  LAN1 = 192.168.0.0/24
#Machine1 doesnt have access to internet & LAN1

#Machine2 RHEL6 SSH srv has access to internet and LAN1

Task :
browse internet securely through ssh connection/SOCKS proxy/Dynamic port forwarding
--------------------------In server-----------------------
enable packet forwarding/ Masquerading 
<for temporary>
@SRV #echo 1 > proc/sys/net/ipv4/ip_forward

<for permanent>
@SRV #vim /etc/sysctl.conf
net.ipv4.ip_forward = 1

@SRV #iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE

@SRV #service iptables save

 ------------------------In client --machine 1------------------------

 #ssh  -D  9001  user@192.168.0.100      
9001 is machine1 local port (you can put any free/un-used port)


In firefox(chrome or other browsers ) go to settings, network,manual proxy settings --> 
socks host = Localhost
port = 9001  (defined above)
socksv5

see below for working screen shot + configuration is same if you are connecting to internet from unsecure connections ..(your ssh server need to have public ip address) --this method is also known as poor mans VPN