Add more Swap on linux Vm

How to add more swap on a linux Vm.
It can be used on a physical machine too but remember that swap is store on a file and not in a dedicate partition.

#########################sWap File
#Create Local Folder
mkdir -p /usr/local/swap/

#Create a 2Gb Local File to store swap
dd if=/dev/zero of=/usr/local/swap/swapfile1 bs=1024 count=2097152 #2gb 4194304
mkswap /usr/local/swap/swapfile1

#set Grant On File
cd /usr/local/swap/
chown root:root swapfile1
chmod 0600 swapfile1

#Enable Swap
swapon swapfile1

Add this line in /ect/fstab to load swap on system startup:


/usr/local/swap/swapfile1 swap swap defaults 0 0

Start a IHS as daemon

This is my IHS script for Linux

#!/bin/sh
### BEGIN INIT INFO
# Provides: ibm-http
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop IBM HTTP Server
### END INIT INFO
#
# IBM HTTP This init.d script starts the IBM HTTP Server

# Find the name of the script
NAME=`basename $0`
ihs_Path=/opt/ibm/HTTPServer

IBMHTTPCTL="${ihs_Path}/bin/apachectl"

set -e
if [ ! -x ${ihs_Path}/bin/httpd ] ; then
echo "No IBM HTTP Server installed"
exit 0
fi

start() {
echo -n $"Starting ${NAME} service: "
$IBMHTTPCTL -k start; > /dev/null
ret=$?
if [ $ret -eq 0 ]
then
echo "${NAME} Started."
else
echo "${NAME} Starting Failed!"
exit 1
fi
echo
}

stop() {
echo -n $"Stopping ${NAME} service: "
$IBMHTTPCTL -k stop > /dev/null

ret=$?
if [ $ret -eq 0 ]
then
echo "${NAME} Stop Success."
else
echo "${NAME} Stop Failed!"
exit 1
fi
echo
}

graceful() {
echo -n $"graceful ${NAME} service: "
$IBMHTTPCTL -k graceful
ret=$?
if [ $ret -eq 0 ]
then
echo "graceful Success."
else
echo "graceful Failed!"
exit 1
fi
echo
}

restart() {
echo -n $"Restart ${NAME} service: "
$IBMHTTPCTL -k restart
ret=$?
if [ $ret -eq 0 ]
then
echo "restart Success."
else
echo "restart Failed!"
exit 1
fi
echo
}

case "$1" in
start)
start
;;
stop)
stop
;;
graceful)
graceful
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|graceful|restart}"
exit 1
esac
exit 0

How to protect alias with htpasswd file

Just a simple reminder :

1) Create passwd file:
htpasswd2 -c /etc/apache2/htpasswd USER -> insert password

2) verify grant on path

3) create alias

Alias /protected /root/path
<Location /protected >
        AuthType Basic
        AuthName "download for protected "
        AuthUserFile /etc/apache2/htpasswd
        Require valid-user
</Location>

How to configure Apache Security on Ldap

This is a simply configuration of apahce to use Ldap authentication, You need to enable ldap and ldap_auth modules.

 

<Location /ldaplocation >
 
AuthType Basic
AuthName "ldap auth"
AuthBasicProvider ldap
AuthLDAPBindDN "CN=ldapbind,O=test,C=it"
AuthLDAPBindPassword mypasswordhere
AuthLDAPURL "ldap://ldaphost:389/?uid?sub?(objectClass=inetOrgPerson)"
 
Options Indexes
SetOutputFilter DEFLATE
  <Limit OPTIONS PROPFIND GET REPORT MKACTIVITY PROPPATCH PUT CHECKOUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE>
     Require valid-user
 </Limit>
</Location>

How to export Tivoli Directory Server to .ldif file

This script is simply and usefull to backup all users in a tivoli directory server to an ldif file.
When schedule by crontab it’s possible to add in command line destination folder by $1 param,
so you can have different versions of backup.

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
 
NOW=$(date +"%u")
LPATH=/tmp/juve_full_backup$NOW.ldif
RPATH=/backup/ldap/$1
LOG=/var/log/bckLdap$1"-"$NOW".log"
 
echo "------------------"Backup LDAP on DOW $NOW"----------------------------------">LOG
echo `date`>>$LOG
 
mkdir $RPATH
/opt/IBM/ldap/V6.3/sbin/idsdb2ldif -I juvetds1 -o $LPATH  >$LOG
mv $LPATH $RPATH