Friday, May 29, 2015

Backup, check space and delete old file backup

1.Backup file

------------------------script backup.sh---------------------------------------------------------
###mount -o username=administrator,password=xxxx //IP address/Path /mnt/backup

LISTS="/home"
BACKUPLAST=2
BACKUP_PATH="/media/Backup"

DAY_DELETE=`date -d "+%Y%m%d"`
DAY_BACKUP=`date "+%Y%m%d"`
DELETE="${BACKUP_PATH}/${DAY_DELETE}.tar.bz2"
BACKUP="${BACKUP_PATH}/${DAY_BACKUP}.tar.bz2"

if [ -s ${DELETE} ]
then
   rm -rf ${DELETE}
fi
if [ -s ${BACKUP} ]
then
   rm -rf ${BACKUP}
fi
#tar cfvz ${BACKUP} ${LISTS}
tar -jPcf ${BACKUP} ${LISTS}

--------------------------------------------------------------------------------------------------

2. Check space and send mail every day
-------------------------checkspace.sh----------------------------------------------------------
df -H >checkspace.txt
echo "Check disk space complete" | mutt -a "checkspace.txt" -s "Check disk space complete" -- email@domain.com
---------------------------------------------------------------------------------------------------

3. delete old file backp
------------------------script removeoldfilebackup.sh--------------------------------------------
find /media/Backup/ -type f -mtime +7 -name '*.bz2' -execdir rm -- {} +
ls -lt /media/Backup > listbackup.txt
echo "Delete old file backup complete" | mutt -a "listbackup.txt" -s "Delete old file backup complete" -- email@domain.com
-----------------------------------------------------------------------------------------------

* find /location/* -type f -mtime +7 -exec rm -rf {} \;
find /location/findname.log -type f -mtime +7 -exec rm -rf {} \;

4.crontab -l
0 */3 * * * /sbin/service dovecot reload
0 0 * * * /root/./backup.sh
0 4 * * * /root/./checkspace.sh
0 5 * * * /root/./removeoldfilebackup.sh

Sunday, May 24, 2015

Reset surface to default

Reference: Microsoft
Reset from the Windows sign-in screen
Notes
  • If you’ve lost your password, you may not have to reset your Surface. See I forgot my password before
    performing these reset steps.
  • If you don't have a keyboard connected to your Surface Pro or Surface 3, you'll need to use the on-screen keyboard to do these reset steps. From the Windows sign-in screen, tap or click the Ease of access icon Ease of access icon in the lower-left corner of the screen, and then tap or click On-Screen Keyboard.

Step 1: From the Windows sign-in screen, tap or click Power Power icon in the lower right corner of the sign-in screen.
Step 2: Press and hold the Shift key.
(If you're using the on-screen keyboard, tap or click the Shift key.)
Step 3: While the Shift key is still pressed, tap or click Restart.
If you get the prompt Restart anyway, tap or click Restart anyway.
After Surface restarts, the Choose an option screen will appear.
Step 4: Tap or click Troubleshoot.
Step 5: Tap or click Reset your PC.
Surface restarts and the Surface logo displays while Windows prepares to reset your Surface.
Step 6: On the Reset your PC screen, tap or click Next.
Step 7: Choose either Just remove my files or Fully clean the drive. The option to clean the drive is more secure, but takes much longer. For example, if you are recycling your Surface, you should choose to clean the drive. If you are keeping your Surface, you just need to remove your files.
Step 8: Tap or click Reset.
Surface restarts and the Surface logo displays while the reset process completes (this can take several minutes).  

Saturday, May 23, 2015

create usb boot with dd command

Format disk to fat32 before create usb boot
format fat32 command
sudo mkfs.vfat -I -F32 /dev/sdx
format NTFS
sudo mkfs.ntfs /dev/sdx
format ext4
sudo mkfs.ext4 -L label /dev/sdx
sudo mkfs.ext4 -F -O ^64bit -L 'Label disk' '/dev/sdx1'

#fdisk -l
build usb boot
#
#sudo umount /dev/sdc
#dd if=ubuntu-mate-14.04.2-LTS-desktop-i386.iso of=/dev/sdc bs=1M
or
#sudo dd if=./ubuntu.iso of=/dev/sdd bs=8129

#complete
1076+1 records in
1076+1 records out
1128595456 bytes (1.1 GB) copied, 220.276 s, 5.1 MB/s


if= source file iso, img 
of= flash drive
bs= Read & Write rate

#clone to image file
dd if=/dev/sdb of=/home/hades/Downloads/OS/hilen-boot.img bs=1M
7633+1 records in
7633+1 records out

8004304896 bytes (8.0 GB) copied, 370.764 s, 21.6 MB/s


แบบมี status ว่าทำได้กี่ %
1.ต้องติดตั้ง package pv dialog (sudo apt-get install pv dialog)
#(pv -n lubuntu-15.04-alternate-i386.iso | dd of=/dev/sdb bs=1M) 2>&1 | dialog --gauge "Running dd command (copyfile), please wait..." 10 70

2. pv -tpreb lubuntu-15.04-alternate-i386.iso | dd of=/dev/sdb bs=1M
#pv -tpreb lubuntu-15.04-alternate-i386.iso | dd of=/dev/sdb bs=1M
 651MB 0:01:30 [7.18MB/s] [=================================================================>] 100%            
0+5209 records in
0+5209 records out
682622976 bytes (683 MB) copied, 92.9512 s, 7.3 MB/s

3. sudo dd if=file.iso |pv| sudo dd of=/dev/sdX bs=1M

* สามารถ Clone disk to disk ได้ด้วย
* dd มันอ่านข้อมูลเป็น block แล้วก้อปไปใส่อีกตัวตรงๆ
ถ้าไฟล์เล็กๆเยอะๆ dd จะไวกว่ามาก เพราะมันไม่สนจำนวนไฟล์ มันอ่านข้อมูลเป็น block จาก hdd เลย
ข้อเสียคือมันจะทำทั้งลูก ต่อให้มีข้อมูลอยู่ 1kb มันก็ทำทั้งลูกอยู่ดี

Friday, May 15, 2015

clear save password samba on ubuntu

when you login share file and save permanent password user and then you want to clear user and password
How to do?

#cd /home/user/.gnome2/
#mv keyrings keyrings_mv   --> clear user and password

Wednesday, May 13, 2015

reset password root mysql

run command folowing

1. service myql stop
2. mysqld_safe --skip-grant-tables
3.mysql --user=root mysql
4.
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;

5. service mysql restart6. test login myql -uroot -p7. test login on phpmyadmin


----------------------------------------------------------------
How to reset the root password for mysql:
Stop mysql:
1. service mysql stop

Run mysql with skip grants to be able to login without any password
2. mysqld_safe --skip-grant-tables &

Login as root
3. mysql -u root

4. mysql commands:
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD-HERE") where User='root';
mysql> flush privileges;
mysql> quit

Stop mysql
5. service mysql stop

Start mysql normally:
6. service mysql start

Try to login using your new password:
7. mysql -u root -p     


Reference site

Sunday, May 10, 2015

remmina Protocol plugin RDP is not installed (Kali)

1. after insall remmina
    1.1 don't forget install remmina-plugin-rdp


2. just install package libfreerdp1_1.0.1-1.1+deb7u3_amd64.deb3
3. see picture click amd64
 


4. shoose Asia see picture

5. install package : sudo dpkg -i libfreerdp1_1.0.1-1.1+deb7u3_amd64.deb

Install line on kali, ubuntu

how to install line on ubunt

1. Install wine
#apt-get install wine
2. Downlaod line
gotot website: db.tt/G5doCA01
save file LINE.zip
unzip file LINE.zip and copy folder LINE to /home/youehome/.wine/drive_c/Program Files/
3. Edit line script
#cd /usr/bin
#mv line line_mv
#vim line

-------------------------------------------Create new script ---------------------------------------------

#!/bin/bash
wine /home/yourhome/.wine/drive_c/Program\ Files/LINE/Line.exe 2>&1
/dev/null


------------------------------------------Save and exit --------------------------------------------------
Change permission
#chomod u+x line
#chmod o+x line
4. Create short cut to desktop (see picture)
for create short cut ubuntu 15.04 read here!


* Icone line



3. add font thai
4. add font thai 2
copy font thai to drive /home/my user/.wine/drive_c/windows/

sed -i "s/font-family:[^;]*;/font-family:'tahoma';/g" ~/.wine/drive_c/Program\ Files/LINE/res/skin/basic/css/*