วันจันทร์ที่ 28 กรกฎาคม พ.ศ. 2557

CentOS All Config For P2DC

vi /etc/sysconfig/network

กด i 1 รอบเพื่อพิม

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=colo70-53.p2dc.com
GATEWAY=110.164.70.33

กด esc แล้วพิม :wq

vi /etc/sysconfig/network-scripts/ifcfg-eth0
แก้และเพิ่มตามที่ถ้ายังไม่มีก็พิมเพิ่มลงไป
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=110.164.70.53
NETMASK=255.255.255.0

แล้วก็ save

vi /etc/resolv.conf

nameserver 110.164.252.222
nameserver 110.164.252.223

แล้วก็ save 

แล้วก็ service network restart

วันศุกร์ที่ 18 กรกฎาคม พ.ศ. 2557

find 50 file last modify linux

find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r | head -n 50

Vmware ESXi exted HDD

Vmware ESXi exted HDD
To extend the logical volume:

Note: These steps only apply to EXT3 file systems.
 
Caution: VMware recommends having a complete backup of the virtual machine prior making these changes.
  1. Power off the virtual machine.
  2. Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
  3. Power on the virtual machine.
  4. Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:
    # fdisk -l
  5. Create a new primary partition:
    1. Run the command:
      # fdisk /dev/sda (depending the results of the step 4)
       
    2. Press p to print the partition table to identify the number of partitions. By default there are 2: sda1 and sda2.
    3. Press n to create a new primary partition. 
    4. Press p for primary.
    5. Press 3 for the partition number, depending the output of the partition table print.
    6. Press Enter two times.
    7. Press w to write the changes to the partition table.
  6. Restart the virtual machine.
  7. Run this command to verify that the changes were saved to the partition table and that the new partition has an 83 type:

    # fdisk -l
  8. Run this command to convert the new partition to a physical volume:

    # pvcreate /dev/sda3
  9. Run this command to extend the physical volume:

    # vgextend VolGroup00 /dev/sda3

    Note: To determine which volume group to extend, use the command vgdisplay.
  10. Run this command to verify how many physical extents are available to the Volume Group:
    # vgdisplay VolGroup00 | grep "Free"
  11. Run the following command to extend the Logical Volume:

    # lvextend -L+#G /dev/VolGroup00/LogVol00

    Where # is the number of Free space in GB available as per the previous command.

    Note: to determine which logical volume to extend, use the command lvdisplay.
  12. Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:

    # resize2fs /dev/VolGroup00/LogVol00
    Note: Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.
  13. Run the following command to verify that the / filesystem has the new space available:

    # df -h /

วันอาทิตย์ที่ 8 มิถุนายน พ.ศ. 2557

Automatic cPanel backup (domain & MySQL) with cron & PHP

<?php

// PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server.
// This script contains passwords.  KEEP ACCESS TO THIS FILE SECURE! (place it in your home dir, not /www/)

// ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED *********

// Info required for cPanel access
$cpuser = "username"; // Username used to login to CPanel
$cppass = "password"; // Password used to login to CPanel
$domain = "example.com"; // Domain name where CPanel is run
$skin = "x"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme

// Info required for FTP host
$ftpuser = "ftpusername"; // Username for FTP account
$ftppass = "ftppassword"; // Password for FTP account
$ftphost = "ftp.example.com"; // Full hostname or IP address for FTP host
$ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive)

// Notification information
$notifyemail = "you@example.com"; // Email address to send results

// Secure or non-secure mode
$secure = 0; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP

// Set to 1 to have web page result appear in your cron log
$debug = 0;

// *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********

if ($secure) {
   $url = "ssl://".$domain;
   $port = 2083;
} else {
   $url = $domain;
   $port = 2082;
}

$socket = fsockopen($url,$port);
if (!$socket) { echo "Failed to open socket connection... Bailing out!\n"; exit; }

// Encode authentication string
$authstr = $cpuser.":".$cppass;
$pass = base64_encode($authstr);

$params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&submit=Generate Backup";

// Make POST to cPanel
fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
fputs($socket,"Host: $domain\r\n");
fputs($socket,"Authorization: Basic $pass\r\n");
fputs($socket,"Connection: Close\r\n");
fputs($socket,"\r\n");

// Grab response even if we don't do anything with it.
while (!feof($socket)) {
  $response = fgets($socket,4096);
  if ($debug) echo $response;
}

fclose($socket);

?>

วันศุกร์ที่ 25 เมษายน พ.ศ. 2557

Bypass ios 7

http://maypalo.com/2013/02/17/download-tinyumbrella-shsh-blobs-ios-6-1-1/
https://sites.google.com/site/msftguy/file/ssh_rd_rev04b.jar
PuTTy

Step 1: Back up your iPhone before attempting this guide and make sure to put it in airplane mode.
Step 2: Connect the iPhone to the computer and hit restore (if you have already done this and are on the “Welcome to iOS 7″ screen, you don’t need to do it again).
Step 3: Put your iPhone in to DFU mode.
  1. Hold the Power button for 3 seconds
  2. Hold the Home button without releasing the Power button for 10 seconds
  3. Release the Power Button but keep holding the Home button
Step 4: Download the Java utility and run it.
Step 5: Once it is completed you should see the following on your computer.
Java utility iPhone
Step 6: Download PuTTy and run it.
Step 7: Put in local host as hostname and port the java utility specified.
PuTTy iPhone
Step 8: A window will pop up asking you for username and password:
  1. Username: root.
  2. Password: alpine.
Step 9: Right after that run mount.sh in the terminal, then type in the following commands
cd mnt1/Applications.
rm -R Setup.app
If that does not work, type set and hit the tab button, it should auto complete.
Step 10: Now delete setup.app.
Step 11: Hold the power and home button to reset the phone.
Step 12: When the iPhone is turned on, it will show it in recovery mode. It is fine, don’t need to panick.
Step 13: Download TinyUmbrella and run it.
Step 14: Exit from the recovery mode using TinyUmbrella.
TinyUmbrella
Step 15: Your iPhone should boot up properly now.
If you have followed the steps correctly your iPhone should be hacktivated (activated) and up & running. The hacktivation method is not the proper way to activate an iPhone so you might find some problems later on while using it.

วันศุกร์ที่ 7 มีนาคม พ.ศ. 2557

XCode Set Font Size


XCode Set Font Size


[myView setFont:[UIFont systemFontOfSize:12]];

[myView setFont:[UIFont boldSystemFontOfSize:12]];

[myView setFont:[UIFont fontWithName:@"Helvetica" size:12]];

วันศุกร์ที่ 24 มกราคม พ.ศ. 2557

fix vsftp & iptables fix

setenforce 0

/etc/vsftpd/ftpusers
/etc/vsftpd/user_list

vi /etc/sysconfig/iptables-config

IPTABLES_MODULES="ip_conntrack_ftp"

ขั้นตอนการติดตั้ง FTP Server บน CentOS 6 ด้วยโปรแกรม vsftpd
1. ดาวน์โหลดโปรแกรม vsftpd
1
# yum install vsftpd

2. Start Service vsftpd 
1
# service vsftpd start

3. เปิดการใช้งาน vsftpd ใน Multi-user levels
1
# chkconfig vsftpd on
 ขั้นตอนการสร้าง Account FTP ให้กับแต่ละคน (FTP แบบ Authentication Required)
1. แก้ไขไฟล์ vsftpd.conf โดยพิมพ์คำสั่ง แก้ไขค่าตามคำอธิบายด้านล่าง และทำการบันทึก
1
# nano /etc/vsftpd/vsftpd.conf

1.1 ascii_upload_enable=YES ลบเครื่องหมาย # ออก
1.2 ascii_download_enable=YES ลบเครื่องหมาย # ออก
1.3 ftpd_banner=Welcome to blah FTP service. ลบเครื่องหมาย # ออก
1.4 use_localtime=YES เพิ่มไว้ที่บรรทัดสุดท้าย

2. สร้าง Account ใหม่ขึ้นมาสำหรับการทดสอบ
1
2
3
4
5
6
7
# useradd ftp1
# passwd ftp1
Changing password for user ostechnix.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.

3. Restart Service vsftpd
1
# service vsftpd restart

4. Update SELinux configuration เพื่อเปลี่ยน User ไปที่ $HOME directories
1
# setsebool -P ftp_home_dir on