Centos Net Install URLs Here are the Net Install URLs for Centos If you want to use the Net Install Disc for installation : Centos 5.x : Website Name : mirror.centos.org Centos Directory: /centos/5.x/os/i386 Centos 6.x : **URL- 32 Bit : ** http://mirror.centos.org/centos/6.x/os/i386 **URL
PHP Installing PHP Time Zone Database Instead of relying on system time zone database, you can use php timezone database which gets updated more frequently. Here is how to do that : pecl install timezonedb If you do not have pecl command installed ( For Eg. Centos ) Run the following command : php /usr/share/php/peclcmd.php install
Implementing Disk Quota In order to implement Disk Quota on Linux Systems, you would need to remount the file system with usrquota and grpquota options. vi /etc/fstab /dev/VolGroup00/LogVol02 /home ext3 defaults,usrquota,grpquota 1 2 mount -o remount /home The next step is to initialize the quota database : quotacheck -cug
Linux Disabling SELINUX In order to disable selinux , run the following commands : To Disable SeLinux For Current Session only : setenforce permissive or echo 0 > /selinux/enforce To Disable Selinux permanently: vi /etc/sysconfig/selinux SELINUX=disabled
Crontab Format If you have hard time remembering the crontab format , you can actually get the format form the info page of crontab. Run this command and you will see the format of the crontab. info crontab | grep –A 6 –i “allowed values”
Starting and Stopping NFS Service You can restart nfs using command “service nfs restart” in linux. The command could create problems sometimes. A better way to restart nfs and related service is : Stopping NFS Services service nfslock stop service nfs stop service portmap stop umount /proc/fs/nfsd **Starting NFS Services ** service portmap start service
Bash script to check for valid IP Script to check for valid ip !/bin/bash function validateIP() { local ip=$1 local stat=1 if [[ $ip =~ [1] {1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then OIFS=$IFS IFS='.' ip=($ip) IFS=$OIFS [[ ${ip[0]} -le 255 && ${ip[1]} -le 255
Bash Command and output History You can keep track of bash command and output history by using script command. Login to a server and run script /tmp/commandouput.log Now you can continue working. Once you logout and come back into the server, you can view that file to see the command and the output
Running interactive command or script over ssh In order to run interactive command or script which require you to input something , you can use -t option with ssh. eg. ssh -t x.y.z.a 'sh /some/script.sh'
Resize Image with Bash Script You can use bash script to resize images. Prerequisite : yum install ImageMagick Files with .JPG extension , file will be overwritten with new image !/bin/bash for i in *.JPG; do convert $i -resize 10% $(basename $i .JPG).JPG; done In : $(basename $i .JPG).JPG , the second .JPG is the new
Using IFS variable in shell scripts IFS variable comes handy when you want to split a string into array or create a loop. <br></br> #!/bin/bash<br></br> IFS=$','<br></br> dirs='/usr/scripts,/var/lib,/usr/local'<
Mounting Windows Share to Linux In order to Mount a windows share to Linux , create a share in your windows \\serverip\shareddrive Now in the linux server create a directory where you want to mount the share mkdir /mnt/winshare Now mount the share by typing the following command: mount -t cifs -o username=<
Linux filesystem check utility fsck is a unix file system check utility. It is used to repair , recover and fix disk issues. The following examples display various use cases and options that can be used with fsck. Check a filesystem : fsck /dev/sda1 **Check all filesystems : ** fsck -A ( It is recommended to exclude root
SED Tutorial with examples SED: SED is a powerful stream editor. SED Options : -i : does in-place replacement -n : no printing -f : scriptname ( when there are large number of sed commands) Syntax: sed command filename SED Examples Remove n lines from the top of a file : sed -i nd filename where n is the number
gluster troubleshooting Gluster Filesystem Troubleshooting Path or prefix of it is already a part of volume: This occurs when you are trying to add a previously removed brick to the volume. You can clear this out as mentioned below : setfattr -x trusted.glusterfs.volume-id /path/to/share setfattr -x trusted.gfid /path/to/share gluster
Apache - Disable script execution upload directory For Apache: <Directory /path/to/directory> php_flag engine off For Nginx : location /path/to/directory/ { location ~ .*.(php)?$ { deny all; } }
Linux Top Command O : Sort by any top output column M : Sort by Memory usage R : Reverse order K : Kill a task with PID r : Renice a process 1 : Display All CPUs/Cores d : Change refresh rate. : On Demand refresh z or b : HIghlight running processes c : Display Absolute path of command and
sender policy framework Sample SPF Record for a single Email Server Publish a TXT Record with following text. v=spf1 mx mx:mail.example.com -all
mysql Shell Script to Check the Status of MySQL Replication !/bin/bash emailAddress="emailtoNotify@domain.com [emailAddress=%22emailtoNotify@domain.com]" cmd=mysql -e 'show slave status\G' | grep Slave_SQL_Running | awk '{print $2}' if [ "$cmd" == "No" ];then MSG="Mysql Replication Broken on hostname, please check asap" echo
Turn on ping response on windows servers with windows firewall turned on netsh firewall set icmpsetting 8
Manually Installing vmware remote console plugin If you are not able to install vmware remote console plugin, then you can manually install the plugin by navigating to the directory and running the installer: %programdir%\VMware\VMware Server\tomcat\webapps\ui\plugin\vmware-vmrc-win32-x86
PHP cannot start session without errors Web server is not able to access your session directory. Change the permissions. chown -R root:apache /var/lib/php/session
Linux Configure PPTP VPN Server 1. Install ppp yum install ppp 2. Download pptpd rpm wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.i686.rpm 3. Set the local and remote ip in /etc/pptpd.conf vi /etc/pptpd.conf localip <local ip address of server> remoteip < range
networking VLAN VLAN means virtual local area network.Vlans are used to separate multiple networks while being on the same physical network. View existing Vlans : router(config)#show vlan Configuring a Vlan: router(config) #configure terminal router(config)#vlan router(config)#interface range gigabitEthernet 1/0/2-6 router(config)#switchport access vlan
mysql Shell Script to Create and Grant Privilege to a new user !/bin/bash #Script to Create a user and assign privilege to a MySQL Database read -p "Please Enter Database Name:" dbname mysql -Bse "USE $dbname" 2> /dev/null if [ $? -eq 0 ]; then read -p "Please enter the username you wish to create : " username