Skip to main content

Posts

Single Mysql Command to restore the last 5 records from one database to another.

1. Get the structure of test_table from the source database.  > use database1;  > show create table test_table; 2. Copy the Complete CREATE TABLE `test_table` query 3. Remove the "AUTO_INCREMENT=xxxxxxx" Portion from the query. 4. Insert this query to the new database;  > use database2;  > Paste the CREATE TABLE query and press enter. 5. Now the tricky part, the below command will select the last 5 records from the test_table  of database1 and insert into the test_table of database2.  > insert into database1.test_table select * from database2.test_table order by cur_date desc limit 5; Thats all Folks, Cheers.

Dirty Cow Vulnerability CVE-2016-5195

Why it is called Dirty Cow?   " A race condition was found in the way the Linux kernel's memory subsystem handled the copy-on-write (COW) breakage of private read-only memory mappings. An unprivileged local user could use this flaw to gain write access to otherwise read-only memory mappings and thus increase their privileges on the system. " Who found the Dirty COW vulnerability? Phil Oester How to mitigate this vulnerability? You need to update the kernel and make sure the kernel is patched for this vulnerability. # yum update kernel # uname -r // for getting the installed kernel. # rpm -qa | grep kernel-name // for getting the package of the installed kernel. # rpm -q --changlog | grep -i 'CVE-2016-5195'   - [mm] close FOLL MAP_PRIVATE race (Larry Woodman) [1385116 1385117] {CVE-2016-5195} If this have a result like above , that means the cow is clean now :p How to Build and use the systemtap workaround First you have to insta...

Shell Script with Python module to find total ip address between two ip Addresses

################################################### # Script Name : noOfHosts # Created By : Jino Joseph # Created Date : 08-Jul-2014 # Last Modified : 08-Jul-2014 # Purpose : To find the Total number of Hosts between two ip addresses. ################################################### #!/bin/bash sed -i 's/\t/#/g' ips.txt for i in `cat /root/ips.txt`; do IPFROM=$(echo $i | awk -F '#' '{print $1}'); IPTO=$(echo $i | awk -F '#' '{print $2}'); python -c " import ipaddress import sys ip1 = int(ipaddress.IPv4Address(unicode('"$IPFROM"'))) ip2 = int(ipaddress.IPv4Address(unicode('"$IPTO"'))) host = ip2 - ip1 Nhost = host + 1 sys.stdout.write(str(Nhost)) " echo " $IPFROM $IPTO"; done ################################################### This will give the result as "Number of IP" , "FromIP" , "ToIP". Each lines of ips.txt file ...

How to upgrade php version from 5.3 to 5.5 on DirectAdmin platform

Following is the instructions to upgrade your Dedicated Server’s PHP from version 5.3 to 5.5 on DirectAdmin platform: Step 1: ssh to the server Step 2: Enter following commands: #cd /usr/local/DirectAdmin/custombuild #./build set php5_ver 5.5 #./build update #./build php n #services httpd restart Once it’s done, confirm the upgrade by: #php -v

Mitigate Small DOS Attacks . Script to check IP connections along with Location.

This script will check the last 10 highest number of IP connections and will give the location of the IP address with connections more than 50. root@xxxx [~]# cat checkddos #!/bin/bash ################################################### # Script Name :checkddos # Created By : Jino Joseph # Created Date : 01-Jul-2013 # Last Modified : 01-Jul-2013 # Purpose : Finds the IPs with connections higher than 50 show the ip location ################################################### netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head -10 | sed -e 's/^[ \t]*//' | sed -e 's/ /#/g' > result.txt for i in `cat result.txt`; do echo $i > temp.txt; No=$(cat temp.txt | gawk -F '#' '{print $1}'); IP=$(cat temp.txt | gawk -F '#' '{print $2}'); Num=${No/\.*} if [ $Num -gt 50 ] && [ $IP != '127.0.0.1' ] then echo -e " $IP : $Num \n " url="http://www.ipaddressloc...

What are cPanel release tiers & How can we change that?

We are all at least generally familiar with the software development cycles, and different software developers use different release schedules according to the testing phase the software is in at the time. For example, some developers use an alpha, beta, release candidate (RC) type of release schedule, and each of these may have varying levels of releases. The cPanel release schedule is very similar to the manner in which Linux distributions are released. cPanel updates in a variety of release tiers. Server administrators may then choose which release version is applicable to their system requirements. The following are cPanel’s current release tiers: ########################################### Stable Release Current Edge Long-term support Each of the above cPanel release tiers represents various stages of the software development cycle. While the final decision to which release version to deploy is entirely up to the organizational decision-makers, i...