Archive for the ‘How_to’ Category

How to install snmp in centos/debian

Wednesday, December 21st, 2011

In centos yum install net-snmp-utils In debian apt-get install snmpd Take a Backup of Original Configuration file and Create a new one cd /etc/snmp mv snmp.conf snmp.bk mcedit snmp.conf Create a new config file from scratch agentAddress udp:192.0.0.xxx:161 rocommunity public 192.0.0.0/24 syslocation "MysqlServer, unit1" Now Restart the snmpd server In Centos /etc/init.d/snmpd start In Debian [...]

Centos:Yum behind a proxy

Wednesday, November 2nd, 2011

if your servers are behind a proxy and you need to provide username and password for the proxy server , then you need to configure yum.conf file with bellow syntax http_proxy=http://username:password@proxyaddress:port/ proxy_username=username proxy_password=password if you dont need to provide username and password for proxy server then : http_proxy=http://proxyserveraddress:port/

Centos:How to add newly created logical volume into fstab

Wednesday, November 2nd, 2011

When you create a Logical volume , you need to add it into /etc/fstab file for it to stay as mounted when server reboot. suppose you have create a logical volume like bellow   lvdisplay — Logical volume — LV Name /dev/POSREP-DB/DB VG Name POSREP-DB LV UUID 0IEKZw-tEoI-jJWt-OGXT-F0B7-hEic-hCbteW LV Write Access read/write LV Status available [...]

Linux:how to setup openvpn in centos or debain

Sunday, May 1st, 2011

In debain apt-get install openvpn In Centos yum install openvpn Create Certificate in debain (a) The default directory for easy-rsa certificates is "/usr/share/doc/openvpn/examples/easy-rsa/2.0/". Now copy that directory into /etc/openvpn   #cp -R /usr/share/doc/openvpn/examples/easy-rsa/ /etc/openvpn/ # cd /etc/openvpn/2.0/   (b). Now we will create the certificate for CA   #. ./vars   #./clean-all   #./build-ca   [...]

Linux: Mutt(How to attach file from command line)

Wednesday, January 5th, 2011

If you want to attach a file in mutt from command line : echo "Body of email" | mutt -a attach.txt -s "subject" user@gmail.com -a : please provide the full path for attachment.

Linux:How to exclude packages from yum update

Tuesday, January 4th, 2011

If you want to exclude packages from yum update then you can type –exclude command as bellow : yum update –exclude=openssl,openssl-devel,bind,bind-chroot,bind-utils,bind-libs Or yum update –exclude=openssl –exclude=openssl-devel –exclude=bind –exclude=bind-chroot –exclude=bind-utils –exclude=bind-libs Or

Linux: How to configure sendmail to receive email (Basic Steps)

Monday, December 13th, 2010

Ref:http://www.sendmail.org/tips/virtualHosting (a) Edit /etc/mail/sendmail.mc and modify bellow lines , It will allow sendmail to received email from outside of localhost. DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl to   DAEMON_OPTIONS(`Port=smtp, Name=MTA’)dnl (b) Edit /etc/mail/virtualtable type , this will map virtual addresses into real addresses joe@yourdomain.com jschmoe Here, sendmail will receive email , and any email comming with address joe@yourdomain.com will [...]

Linux:How to configure centralized yum repo server (Centos)

Friday, November 26th, 2010

Local yum repository is used for local network and to make sure that all your server has same rpm for benchmarking and patching purpose.Its also save bandwidth because all the rpm will be store in one server(Central Repo Server) and rest of the servers will install those rpm from local repo server. Hence they don’t [...]

Linux:How to install vncserver

Monday, November 15th, 2010

Ref: http://wiki.centos.org/HowTos/VNC-Server (a)Install vnc-server packages yum install vnc-server (b)Create your VNC users useradd user1 (c)Set your users’ VNC passwords: Login to each user, and run vncpasswd. This will create a .vnc directory. vncpasswd (d)Edit the server configuration Edit /etc/sysconfig/vncservers, and add the following to the end of the file. VNCSERVERS="2:root 3:user1" VNCSERVERARGS[2]="-geometry 640×480" VNCSERVERARGS[3]="-geometry 640×480" [...]

How to run perl/Python script from Linux Apache server

Thursday, September 2nd, 2010

For httpd.conf ( /usr/local/apache/conf – if you compile by source OR /etc/httpd/conf/httpd -: if you compile by yum) ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/" If you want to run cgi script from under your domain , example , www.fosiul.com/cgi-bin/test.cgi , do as bellow <VirtualHost *:80> ServerAdmin fosiul@example.co.uk DocumentRoot /usr/local/apache/htdocs/example/ ServerName www.example.co.uk ServerAlias example.co.uk ……………………………….. ………………………………..   <Directory "/usr/local/apache/htdocs/example/"> [...]

Linux:How to configure/secure public primary/secondary bind dns server

Wednesday, September 1st, 2010

Localhost Resolver : (a) install bind yum install bind bind-chroot bind-devel (b) Copy named.conf and related files from /usr/share/doc/bind-9.3.6/sample/etc/ cp /usr/share/doc/bind-9.3.6/sample/etc/* /var/named/chroot/etc/ (c) File lists in /var/named/chroot/etc are as bellows : [root@publicdns1 etc]# ls localtime named.rfc1912.zones rndc.conf named.conf named.root.hints rndc.key Check the Ownership of files. Ownership should be root:named as bellow: [root@publicdns1 etc]# pwd /var/named/chroot/etc [...]

Linux:How to configure logrotate for ModSecurity(source install)

Monday, April 26th, 2010

Problem: When you install Mod-security from source , by default log-rotate will not rotate those logs file as the path for log files are not defined logrotate configuration file by default. So if you want to allow logo-ratate to rotate your modsecurity log files. here is the steps: 1. Create a file modsecurity under /etc/logrotate.d [...]

Linux:How to create multiple OpenVPN instances

Monday, April 26th, 2010

Problem : How to configure openvpn to create multiple instances and listen more then 2 ports(1194,1195) ?? Solution: you need more then 2 openvpn configuration file. example : openvpn.conf and openvpn1.conf Now you need to define different port , Server Ip address,ifconfig-pool-persist, and log files For openvpn.conf : port 1194 proto tcp dev tun server [...]

Linux:How to use aide to check file system integrity

Monday, March 15th, 2010

Installing Aide: Yum install aide Creating the database: aide -c /etc/aide.conf –i Output : AIDE database at /var/lib/aide/aide.db.new.gz initialized. This process creates a new file, aide.db.new.gz in /var/lib/aide/.You must rename this file to aide.db.gz, which is the correct name for the AIDE database. Testing Aide: aide -c /etc/aide.conf –C

Linux-How to conferm 64bit/32bit capability of CPU

Wednesday, February 17th, 2010

How many CPU in the system : commands : cat /proc/cpuinfo   [root@server ~]# cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) CPU 3.40GHz stepping : 3 cpu MHz : 3401.008 cache size : 2048 KB physical id : 0 siblings : 2 [...]

How to install apache2-php-mysql from source

Thursday, September 10th, 2009

Prerequisite : yum install gcc-c++ gcc make ncurses-devel openssl-devel glibc* libc-* Packages required for php: yum install libjpeg-devel libpng-devel curl-devel libmcrypt-devel krb5-devel Apache Server Installation from Source: Apache installation directory is : /usr/local/apache a) Download the apache source file from : http://httpd.apache.org/download.cgi b) Download the source file in to /tmp directory. c) I am guessing [...]

How to backup linux Server remotely

Monday, September 7th, 2009

Bellow article will show how to backup a Linux server remotely by using RSYNC with public key base authentication. To make this backup process automatic we need a password less authentication system so that we don’t have to insert username and password before backup starts. How to create Key base authentication: Here are the steps [...]

Tools for securing Linux server and its services

Thursday, August 27th, 2009

a) Fail2Ban: Which will ban IP address after few failure attempts website : http://www.fail2ban.org/wiki/index.php/Main_Page b)Rootkit Hunter : It will scan your server for any unauthorized scripts. Website :http://www.chkrootkit.org/ To download : http://sourceforge.net/projects/rkhunter/ c)PortSentry : This tool will block IP who is trying to scan your server for open ports. Ref : http://www.securityfocus.com/infocus/1580 http://www.securityfocus.com/infocus/1586 How to [...]

How to Rebuilding failed Linux software RAID

Friday, August 14th, 2009

Ref: http://aplawrence.com/Linux/rebuildraid.html Recently I had a hard drive fail. It was part of a Linux software RAID 1 (mirrored drives), so we lost no data, and just needed to replace hardware. However, the raid does requires rebuilding. A hardware array would usually automatically rebuild upon drive replacement, but this needed some help. When you look [...]

Centos/Redhat/Debain Internet Connection Sharing

Friday, August 14th, 2009

Network Setup : eth0 = 192.168.2.1 [ Isp router] eth1 = 10.0.0.2 [ Internal network] Check if IPv4 forwarding is ON or OFF : cat /proc/sys/net/ipv4/ip_forward if result = 0 then will have to On it by this command : echo “1″ > /proc/sys/net/ipv4/ip_forward Now have to Enable IP masquerading by adding rules in iptables [...]

How to sent email to a distribution group by sendmail

Wednesday, August 12th, 2009

goto /etc/mail vi virtualtable all@yorudoman.co.uk allusers Now go to /etc/mail vi allusers.txt user1 user2 user3 [ Here you will have to just write the username (system username)] [If you have lots of user then you can use script to copy all username from /etc/password to /etc/mail/allusers.txt file] Now save the file vi /etc/newaliases Insert this [...]

How to make VIM as IDE for Bash and Perl

Wednesday, August 12th, 2009

For Bash IDE: 1. Download bash-support.zip file from this site : http://www.vim.org/scripts/script.php?script_id=365 2. Unzip bash-support.zip file in /etc/vim directory also either copy the bash-support from /etc/vim to the user’s home directory [ cd /home/user, mkdir .vim, cp -r /etc/vim/bash-support /home/user/.vim] Or unzip bash-support.zip in user’s home directory [ /home/user/.vim] 3. Open your script in gvim [...]

How to add a new hardrive in linux with LVM

Wednesday, August 12th, 2009

The steps are : Create Physical volume Or Extend the existing volume: Create a Physical volume by: pvcreate /dev/hdc ( Here the new partition name is /dev/hdc) Creating a Volume Group : vgcreate /dev/VolGroup01 /dev/hdc OR to extended the existing Volume Group :vgextend /devVolgroup01 /dev/hdc Create Logical Volume : check how much free PE you [...]

How to Setup a transparent proxy with Squid

Wednesday, August 12th, 2009

by LinuxTitli [Last updated: December 5, 2007] Setup : i) System: HP dual Xeon CPU system with 8 GB RAM (good for squid). ii) Eth0: IP:192.168.1.1 iii) Eth1: IP: 192.168.2.1 (192.168.2.0/24 network (around 150 windows XP systems)) iv) OS: Red Hat Enterprise Linux 4.0 (Following instruction should work with Debian and all other Linux distros) [...]

How to install openssh-server in knoppix

Tuesday, August 11th, 2009

In knoppix, cd /etc/apt/ nano sources.list add any good debain repo such as deb http://http.us.debian.org/debian stable main contrib non-free then : Save the file then : apt-get update then type: apt-get install openssh-server also , give a password to root because currently knoppix does not have any root password. repo ref: http://www.debian.org/doc/manuals/apt-howto/ch-basico.en.html

How to find expensive I/O process for I/O bottol neck

Tuesday, August 11th, 2009

To find the most expensive process which causing the I/O bottol neck : 1. iotop ( http://guichaz.free.fr/iotop/) Iotop requires Python ≥ 2.5 and a Linux kernel ≥ 2.6.20 with the TASK_DELAY_ACCT and TASK_IO_ACCOUNTING options enabled. 2. idstat from sysstat packages But Iotop provides more user friendly output then idstat.

How to Change Ip from Dynamic to Static

Tuesday, August 11th, 2009

In Debain : /etc/networking/interfaces auto eth0 iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 then /etc/init.d/networking restart In Centos: vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=Static HWADDR=00:0C:29:81:90:33 ONBOOT=yes IPADDR=192.168.1.1 NETMASK=255.255.255.0 NETWORK=192.168.1.0 GATEWAY=192.168.1.1 BROADCAST=192.168.1.255 then : /etc/network/restart