Friday, February 20, 2015

Vm Ware system

Copy form : Siamimprove

จากที่เราได้ทำความรู้จักกับ Storage ของ VM  มาแล้วเมื่อเราสร้าง VM ขึ้นมา 1 เครืื่อง ตัว ESX  เองจะสร้างไฟล์ต่าง ๆที่เกี่ยวข้องขึ้นมา โดยจะเก็บอยู่ใน Folder เดียวกันตามชื่อเครื่องที่เราตั้งขึ้นมา

Image
 
ประเภทไฟล์ต่าง ๆ มีดังนี้

ไฟล์ .vmx

   เป็นไฟล์ Configuration ของ VM

ไฟล์ .vswp
   เป็น Swap ของ VM

ไฟล์ .nvram
   เป็นไฟล์ จำลอง BIOS  ของ VM

ไฟล์ .vmem
   เป็นหน่วยความจำที่นำเอาพื้นที่ Disk ไปใช้แทน

ไฟ์ .vmss
   เป็นไฟล์ของ VM ถ้ามีคำสั่งให้ Suspend

ไฟล์ .vmsd
   เป็นไฟล์ข้อมูลของการทำ Snapshot

ไฟล์ -Snapshotxx.vmsn
    เป็นไฟล์สถานะของหน่วยความจำจากการทำ Snapshot

ไฟล์ .log
    เป็นไฟล์ Log ต่าง ๆ

ไฟล์ .vmdk
   เป็นไฟล์ Virtual Disk  (มีความสำคัญมากที่สุดบนโลกของ VMware)

Sunday, February 15, 2015

Datastores of Vmware

The datastores are mounted under /vmfs/volumes
use command copy with scp
scp -r /path/filename user@domain.com:/directory
-r คือ Recursive ซึ่งเป็นการ copy directory และ subdirectory ด้วย

Example: scp -r ARSHQ1F-1  /vmfs/volumes/datastore/

More

Tuesday, January 20, 2015

usb boot able by unetbootin

Create boot from USB from ubuntu
* Install by apt-get
sudo add-apt-repository ppa:gezakovacs/ppa
sudo apt-get update
sudo apt-get install unetbootin

Ref:
unetbootin

1.#Install unetbootin by download from website http://unetbootin.sourceforge.net/#install
2. how to use
chmod +x unetbootin-linux-608
3. execute program
./unetbootin-linux-608







Wednesday, January 14, 2015

encrypt file การเข้ารหัสไฟล์เอกสาร

1. Install programe

sudo aptitude install ccrypt

2. Zip file
tar cjvf file.tar.bz2 file  for creat file .bz2

3. Encrypt file

sudo ccrypt file.tar.bz2

4. Decrypt file

sudo ccrypt -d .file.tar.bz2.cpt


Wednesday, January 7, 2015

เซทให้ส่งเมลได้เฉพาะภายในโดเมนหรือบางโดเมน

1. แก้ไขไฟล์ /etc/postfix/main.cf

myhostname = mailgw.domain.com
mydomain = domain.com
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain $mydomain
#mynetworks = hash:/etc/postfix/network_table
mynetworks = 192.168.0.0/24, 10.10.10.0/24
relay_domains = domain.com
transport_maps = hash:/etc/postfix/transport
append_at_myorigin = no
broken_sasl_auth_clients = yes
smtpd_banner = My companee
relayhost = 192.xx.xx.xx
disable_dns_lookups = yes
smtpd_restriction_classes = local_only, local_plus
local_only = reject_unauth_destination
local_plus = check_recipient_access hash:/etc/postfix/local_plus reject_unauth_destination
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/restricted_users
header_checks = regexp:/etc/postfix/header_checks

2. สร้างไฟล์ที่ยอมให้ส่งเมลไปยังที่ไดได้บ้าง /etc/postfix/local_plus

# /etc/postfix/local_plus
# this file contains allowed destinations for users restricted to local_plus
# postmap this file after changes
domain.com OK
domain.org OK
domain.in.th OK

#postmap /etc/postfix/local_plus

3. สร้างไฟล์ที่ไม่ให้ user คนนั้น ๆ ส่งเมลออกภายนอกได้ /etc/postfix/restricted_users

email@domain.com local_plus
email@domain.in.th local_plus

#postmap /etc/postfix/restricted_users

4. แก้ไขไฟล์ /etc/postfix/transport

domain.com                      smtp:mail.mailserver.com:25

#postmap /etc/postfix/transport



Monday, December 15, 2014

Config postfixamdin on Debian 7.7 (postfix+mysql+dovecot)

Read on:
1. debian-wheezy-mail-server-postfix-dovecot-sasl-mysql-postfixadmin-roundcube-spamassassin-clamav-greylist-nginx-php5
2. http://rimuhosting.com/knowledgebase/linux/mail/postfixadmin


1. fix multi domain can't send mail
Error:
: unknown user: “maxime”

fix mydestination = localhost

2. create Local DNS for test mail

setup-dns-server-debian-7-wheezy

     2.1 cat /etc/bind/named.conf.local
//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone    "nanyang.com"   {
        type master;
        file    "/etc/bind/nanyang.com";
 };
zone    "sirivatana.com"   {
        type master;
        file    "/etc/bind/sirivatana.com";
 };

zone   "122.168.192.in-addr.arpa"        {
       type master;
       file    "/etc/bind/db.192.168.122";
 };

zone   "122.168.192.si.in-addr.arpa"        {
       type master;
       file    "/etc/bind/db.192.168.122.si";
 };
------------------------------------------------------------------------
     2.2 cat /etc/bind/nanyang.com
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     pop3s.nanyang.com. root.nanyang.com. (
                         121220143      ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL

        IN      A       192.168.122.10
;
@       IN      NS      pop3s.nanyang.com.
@       IN      MX      10      pop3s.nanyang.com.
@       IN      A       192.168.122.10
@       IN      AAAA    ::1
pop3s   IN      A       192.168.122.10
mail    IN      A       192.168.122.10
dns     IN      A       192.168.122.10
www     IN      A       192.168.122.10
--------------------------------------------------------------------------
     2.3 cat /etc/bind/db.192.168.122
;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     pop3s.nanyang.com. root.pop3s.nanyang.com. (
                         121220142      ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      pop3s.
@       IN      A       192.168.122.10
10      IN      PTR     pop3s.nanyang.com.

3. setup Superuser postfixadmin

3.1#cp config.inc.php.bak config.inc.php
--------------------------Edit file----------------------
$CONF['configured'] = true; $CONF['postfix_admin_url'] = 'https://192.168.122.10/postfixadmin';
$CONF['database_type'] = 'mysqli'; $CONF['database_host'] = 'localhost'; $CONF['database_user'] = 'postfix_admin'; $CONF['database_password'] = ''; $CONF['database_name'] = 'postfix'; $CONF['domain_path'] = 'YES'; $CONF['domain_in_mailbox'] = 'NO'; $CONF['fetchmail'] = 'NO';
------------------------------------------------

3.2 run setup.php from browser: https://192.168.122.10/postfixadmin/setup.php
Step 1 Click Generate password hash


Step 2 add Gen passwd to config.inc.php

add $CONF['setup_password'] = '13a402059836b65b6531a7a16d66dfbb:223b34da76ccf8daeb193737e2266be3dc2e7e6b'; to file config.inc.php and save and then create Supper user postfixadmin



Step 3 add Super user postfixadmin done!
* ในการสร้าง user จะมีพาสเวิร์ด 2 ส่วนคือ
1. ส่วน Setup password ต้องจำให้ได้ว่า ตอนแรกใส่พาวเวิร์ดอะไรไว้ เพราะมันเข้ารหัสไว้ เช่น '13a402059836b65b6531a7a16d66dfbb:223b34da76ccf8daeb193737e2266be3dc2e7e6b';
2. Password Admin: พาสเวิร์ดที่ตั้งไว้ให้กับ Super Admin


4. Dovecot

You really want to change in /etc/dovecot/conf.d/10-mail.conf:

mail_location = maildir:/home/vmail/%d/%n:INDEX=/home/vmail/%d/%n/indexes
to
mail_location = maildir:/home/vmail/%Ld/%Ln:INDEX=/home/vmail/%Ld/%Ln/indexes

otherwise if someone will send you email with mixed case such as AbCdE@ExAmPle.com then dovecot will create a NEW directories for the same user.

5. vacation
postfixadmin-setup-with-correct-vacation-settings-on-freebsd

Error: Command output: Can't locate
    MIME/EncWords.pm
#apt-get install libmime-encwords-perl

Command output: Can't locate
    Email/Valid.pm
#apt-get install libemail-valid-perl

Command output: Can't locate
    Mail/Sender.pm
Run command....
# perl -MCPAN -e shell
Y to all

  cpan> install Mail::Sender
  cpan> quit

#apt-get install libmail-sendmail-perl libdbd-pg-perl libemail-valid-perl libmime-tools-perl liblog-log4perl-perl liblog-dispatch-perl libgetopt-argvfile-perl libmime-charset-perl libmime-encwords-perl

Tuesday, November 18, 2014

script add new user on centos


---------------------------adduser.sh----------------------------------------------------
#!/bin/bash
# Script to add a user to Linux system

if [ $(id -u) -eq 0 ]; then
        read -p "Enter realname : " realname
#       read -p "Enter company : " company
        read -p "Enter username : " username
        read -s -p "Enter password : " password
        egrep "^$username" /etc/passwd >/dev/null
        if [ $? -eq 0 ]; then
                echo "$username exists!"
                exit 1
        else
                sender=email@mydomain.com
                pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
                useradd -p $pass $username -c "$realname" -m -g group -s /sbin/nologin
                [ $? -eq 0 ] && echo "User has been added to system!" && echo | mail -s "Welcome new email, Do not reply mail" < user.txt mooy@mydomain.com -c image@mydomain.com -- -f $sender  || echo "Failed to add a user!"
        fi
else
        echo "Only root may add a user to the system"
        exit 2
fi

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

----------------------------------user.txt------------------------------------
Hi
You email address: mooy@mydomain.com
password: m12345


By.
Auto Generate mail.
-----------------------------------------------------------------------------

Monday, November 17, 2014

How to generate user & password on ubuntu

Install package makepasswd
apt-get install makepasswd

makepasswd -count 100 --chars 6 --string=คำที่ต้องการนำไป Gen ใช้คำ ข้อความ ตัวอักษรเล้กใหญ่ หรือตัวเลข > passwor.txt


Monday, November 10, 2014

nstmp folder

nstmp คือ temp file ที่เกิดขึ้นเมือเรา compact mail thunderbird มันจะสร้างขึ้นอัตโนมัติใน Folder เมลนั้นในรูปแบบ nstmp1, nstmp2
แล้วมันมีประโยชน์อย่างไร?
     ขณะที่เรา compact mail อยู่ เกิดเครื่องดับ โปรแกรมปิดอัตโนมัติ คิดดูแล้วกันว่าจะเกิดอะไรขึ้นกับเมลที่เรากำลัง compact อยู่ เมื่อเปิดเมลขึ้นมาใหม่ เปิดโปรแกรมมองเห็นข้อมูลได้นับว่าโชคดี แล้วถ้าเปิดเมลไม่ได้ละ?
    นี่คือประโยชน์ของไฟล์ nstmp ให้เข้าไปยัง Folder ที่เรา compact ไปเมื่อก่อนหน้านี้ แล้วมองหาไฟล์ nstmp1, nstmp2, ... ทำการลบไฟล์เหล่านี้ออก ปิดเปิดเมลใหม่อีกครั้ง จะกลับไปยังสถานการณ์แรกที่จะทำการ compact.

    การ compact ทำงานอย่างไร?
    ในโปรแกรม Thunderbird การลบไฟล์ต่าง ๆ นั้นไม่ได้หมายความว่า "ลบ" ใน Thunderbird มันคือการซ่อนไฟล์ ฉะนั้น จึงเห็นว่าการลบเมลอยู่เป็นประจำ ทำไมเนื้อที่เมลยังคงเพิ่มขี้นอยู่เรื่อย ๆ ได้ยิน user พูดอยู่เสมอว่า "ทำการลบเมลอยู่ตลอดนะ ทำไมเมลยังเต็ม"
    ฉะนั้น การ compact mail ใน Thunderbird คือการลบเมลออกไปนั้นเอง ใน Thunderbird version 5 ขึ้นไปมี Feature auto compact mail ซึ่งเราสามารถกำหนดได้ว่าให้มัน compact ทุก ๆ Mb. 


ตัวอย่าง