Posts

Showing posts with the label Admin

Ubuntu : Backup & Restore

คำสั่ง mt (Magnatic Tape) ปกติระบบจะ mount ไว้ให้ที่ /dev/st0 mt -f /dev/st0 status # ตรวจสอบสถานะ mt -f /dev/st0 rewind # สั่งหมุน tape กลับ mt -f /dev/st0 erase # ลบข้อมูล (นานมาก) mt -f /dev/st0 offline #สั่งเด้ง tape ออก Cleaning Cartridge # บางรุ่นอาจไม่เหมือนกัน ใส่เข้าไป พอมัน load เข้าไปแล้วทำความสะอาดเสร็จจะเด้งออกมาเอง (Cleaning Cartridge เป็นแบบใช้แล้วใช้เลย rewind กลับมาใช้อีกไม่ได้) คำสั่ง Backup & Restore Backup ใช้ -c tar -cvf backup_filename data_to_backup เช่น tar -cvf backup.tar /home/nikom กรณีต้องการให้บีบอัดไฟล์ด้วย เพิ่ม parameter -z tar -cvzf backup.tar.gz /home/nikom Restore เปลี่ยน -c เป็น -x (เข้าไปใน directory ที่จะ restore ก่อน เพราะสั่งตรงไหน restore มาตรงนั้น) tar -xvf backup_filename เช่น tar -xvf backup.tar restore ไฟล์ที่บีบไว้ ใช้ -z เหมือนกัน tar -xvzf backup.tar.gz Tape backup ลง tape tar -cvf /dev/st0 data_to_backup ดูรายการใน tape tar -tvf /dev/st0 restore จาก tape tar -tvf /dev/st0 backup_filename backup & restore กับ tape ก็ใช้ -z สำห...

Expanding the size of a virtual disk

Image
เมื่อ OS ใน Virtual Box เต็ม จะทำอย่างไรกันดีเล่าพี่น้อง ความจริงวิธีที่จะทำ มันไม่ตรงกับหัวข้อครับ เพราะมันไม่ใช่การขยาย แต่มันเป็นการสร้างใหม่ 1.เลือก VDI Image เป้าหมายที่ต้องการขยาย 2.สร้าง VDI Image อันใหม่ให้มีขนาดที่ต้องการ 3.เพิ่ม Image อันใหม่เป็น Slave และ เพิ่ม linux Image เข้าไปใน CD สำหรับใช้ Boot ตามตัวอย่างใช้ Parted Magic 4.เปิด terminal พิมพ์ nano /proc/paritions เพื่อดูขนาด harddisk 5.ใช้คำสั่ง dd โดยสังเกตขนาดตามรูป จะโอนจาก 10G(hda) ไปเป็น 30G(hdb) ก็ใช้คำสั่ง dd if=/dev/hda of=/dev/hdb 6.รอจนเสร็จแล้ว shutdown 7.สร้าง OS อันใหม่ แล้วเพิ่ม VDI Image อันใหม่ กับ image ของ Parted Magic boot อีกทีเพื่อ resize partition เพราะ image ใหม่มีขนาด 30 GB ก็จริง แต่ขนาด partition ยังเท่าเดิม 8.เสร็จแล้วก็ shutdown แล้วเอา image ของ Parted Magic ออกก็จะได้ OS ใหม่ใหญ่กว่าเดิมไว้ใช้งาน

Ubuntu : Install OCS Inventory NG

OCS Inventory NG เป็น Asset Management Software แบบ Open Source สำหรับจัดการข้อมูล Hardware และ Software ในระบบเครือข่าย รองรับ Client ที่เป็น Windows, Linux, MacOS ฯลฯ * Relevant inventory information. * Powerful deployment system allowing to distribute software installation or scripts on computers without overloading the network. * Web Administration Console. * Multiple operating systems support, including Microsoft Windows, Linux, *BSD, Sun Solaris, IBM AIX, HP-UX, MacOS X. * Lightweight bandwith usage: 5 KB for a full Windows inventory. * High performance: about 1 000 000 of computers inventoried per day using a server bi-Xeon 3 GHz and 4 GB RAM. * 3-Tier architecture using current standards, HTTP/HTTPS protocol and XML data formatting. * Based on well known products such as Apache web server, MySQL database server, PHP and PERL scripting languages. * Web service accessible through SOAP interface. * Plugins support through API. * ... h...

Ubuntu : Install FreeNX

FreeNX เป็นคนละตัวกับ NXServer ของ nomachine ครับ (ของ nomachine จำกัดแค่ 2 session เอง) 1.เพิ่ม repository nano /etc/apt/sources.list เพิ่ม deb http://ppa.launchpad.net/freenx-team/ppa/ubuntu VERSION main deb-src http://ppa.launchpad.net/freenx-team/ppa/ubuntu VERSION main เพิ่ม key แล้ว update apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2a8e3034d018a4ce apt-get update 2.ติดตั้ง server aptitude install freenx 3.ติดตั้ง client (ใช้ของ nomachine) wget http://64.34.161.181/download/3.4.0/Linux/FE/nxserver_3.4.0-12_i386.deb dpkg -i nxclient_3.4.0-5_i386.deb 4.กรณีต้องการเปลี่ยน SSH key dpkg-reconfigure freenx-server เลือก Create new custom keys จะได้ key อยู่ที่ /var/lib/nxserver/home/custom_keys/client.id_dsa.key สำหรับเอาไป import เข้า nxclient อาจ copy ไปโดยให้คำสั่ง ที่ server cp /var/lib/nxserver/home/custom_keys/client.id_dsa.key ~/ ที่ client scp user@freenx-server:~/client.id_dsa.key ~/

Ubuntu : Join Domain

Join domain ให้ Ubuntu เป็นสมาชิกของ domain แก้ไขไฟล์ /etc/resolv.conf sudo nano /etc/resolv.conf ป้อนข้อมูลดังนี้ search sci.com nameserver 192.168.0.254 แก้ไขไฟล์ /etc/hostname sudo nano /etc/hostname ป้อนข้อมูลดังนี้ ubuntu name.sci.com Join domain โดยใช้คำสั่งดังนี้ sudo apt-get install likewise-open sudo /etc/init.d/likewise-open restart sudo domainjoin-cli join sci.com administrator sudo update-rc.d likewise-open defaults

Ubuntu : Centralized Log Server & PHPSyslogViewer

ติดตั้ง Ubuntu 8.04 Server 1.Boot จากแผ่นติดตั้ง เลือกภาษาที่จะใช้ในการติดตั้ง : English 2.เลือกการติดตั้ง : Install Ubuntu Server 3.เลือกภาษาสำหรับระบบ : English 4.เลือกประเทศ : other -> Thailand 5.Detect keyboard layout : No -> Thailand -> Thailand 6.เลือกปุ่มเปลี่ยนภาษา : Alt+Shift 7.ตั้งชื่อ Server : Go Back (เพื่อกลับไปตั้งค่า IP) 8.ตั้งค่า Network : Configure network manually 8.1 IP Address : 192.168.0.251 8.2 Netmask : 255.255.255.0 8.3 Gateway : 192.168.0.3 8.4 Name server : 192.168.0.254 9.ตั้งชื่อ Server : Server1 10.Domain : sci.com 11.จัดการ Partition : Guided - use entire disk -> Yes 12.ตั้งชื่อ user : System Administrator -> sa 13.ตั้งรหัสผ่านและยืนยัน : *** -> *** 14.ตั้งค่า proxy : 15.เลือก Software ที่จะติดตั้ง : OpenSSH server 16.Restart (หลังจากนี้สามารถ ssh มาจากเครื่องอื่นได้) 17.Login ด้วย User ที่สร้าง 18.กรณีไม่ได้ตั้งค่า IP ในขั้นตอนที่ 8 ตั้งค่าได้โดยใช้คำสั่ง sudo nano /etc/network/interfaces แก้ไขให้เป็นดังนี้ # The loopback network...

Squid : Custom error page

Image
หน้าตาสำหรับแสดงผลกรณีมี error ของ squid เช่น กรณีถูกบล็อก(ERR_ACCESS_DENIED) แก้ไขได้ที่ /usr/share/squod/errors/ โดยสามารถใช้ Variable ได้ด้วย ดังนี้ %B URL with FTP %2f hack %c Squid error code %d seconds elapsed since request received (not yet implemented) %e errno %E strerror() %f FTP request line %F FTP reply line %g FTP server message %h cache hostname %H server host name %i client IP address %I server IP address %L contents of err_html_text config option %M Request Method %m Error message returned by external auth helper %p URL port %P Protocol %R Full HTTP Request %S squid default signature %s caching proxy software with version %t local time %T UTC %U URL without password %u URL with password (Squid-2.5 and later only) %w cachemgr email address %z dns server error message ตัวอย่าง ERR_ACCESS_DENIED ERROR: The requested URL could not be retrieved Web นี้ถูก block ในช่วงเวลา 8:00-12:00 น. และ 13...

Squid : Custom error page

Image
หน้าตาสำหรับแสดงผลกรณีมี error ของ squid เช่น กรณีถูกบล็อก(ERR_ACCESS_DENIED) แก้ไขได้ที่ /usr/share/squod/errors/ โดยสามารถใช้ Variable ได้ด้วย ดังนี้ %B URL with FTP %2f hack %c Squid error code %d seconds elapsed since request received (not yet implemented) %e errno %E strerror() %f FTP request line %F FTP reply line %g FTP server message %h cache hostname %H server host name %i client IP address %I server IP address %L contents of err_html_text config option %M Request Method %m Error message returned by external auth helper %p URL port %P Protocol %R Full HTTP Request %S squid default signature %s caching proxy software with version %t local time %T UTC %U URL without password %u URL with password (Squid-2.5 and later only) %w cachemgr email address %z dns server error message ตัวอย่าง ERR_ACCESS_DENIED ERROR: The requested URL could not be retrieved Web นี้ถูก block ในช่วงเวลา 8:00-12:00 น. และ 13...

Logon Script : Map Network Drive

' MapNetworkDrive.vbs ' VBScript to map a network drive to a UNC Path. ' Author Guy Thomas http://computerperformance.co.uk/ ' Version 2.3 - September 2005 ' -----------------------------------------------------------------' Option Explicit Dim objNetwork Dim strDriveLetter, strRemotePath strDriveLetter = "P:" strRemotePath = "\\server2\public_data" ' Purpose of script to create a network object. (objNetwork) ' Then to apply the MapNetworkDrive method. Result J: drive Set objNetwork = CreateObject("WScript.Network") objNetwork.MapNetworkDrive strDriveLetter, strRemotePath WScript.Quit ' End of Example VBScript.

Service ports for firewall configuration

DHCP *UDP 67, 2535 DNS *UDP 53 *TCP 53,139, 445 Symantec Systen Center *TCP 2967

Squid and Active Directory

acl all src 0.0.0.0/0.0.0.0 acl manager proto cache_object acl localhost src 127.0.0.1/255.255.255.255 acl to_localhost dst 127.0.0.0/8 acl SSL_ports port 443 # https acl SSL_ports port 563 # snews acl SSL_ports port 873 # rsync acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl Safe_ports port 631 # cups acl Safe_ports port 873 # rsync acl Safe_ports port 901 # SWAT acl purge method PURGE acl CONNECT method CONNECT acl webblocked url_regex '/etc/squid/webblocked.txt' acl day_am time 08:00-12:00 acl day_pm time 13:00-17:40 http_access deny webblocked day_am http_access d...

eXtplorer : PHP, AJAX File Manager

Image
แนะนำ file manager น่าใช้ครับ ใช้ร่วมกับ Joomla ได้ด้วย eXtplorer is a web-based File Manager. You can use it to * browse directories & files on the server and * edit, copy, move, delete files, * search, upload and download files, * create and extract archives, * create new files and directories, * change file permissions (chmod) and much more... You can even use eXtplorer to login to the FTP server (like net2ftp) and work as if you were using an FTP client. Access via WebDAV is also possible (requires some extra work and a database!). eXtplorer is released under a dual-license: You can choose wether you want to use eXtplorer under the Mozilla Public License (MPL 1.1) or under the GNU General Public License (GNU/GPL). Note that if you decide to distribute/use eXtplorer under the MPL, you are not allowed to use the ExtJS Javascript library. eXtplorer needs at least PHP 4.3 on the server and an up-to-date browser with Javascript enabled to run. http://extplore...

Centralized Log ภาคที่ 3 : Syslog-NG

1.ติดตั้ง Syslog-NG ที่ Log Server และ Server อื่น ๆ ที่เป็น linux apt-get install syslog-ng 2.Config Log Server (/etc/syslog-ng/syslog-ng.conf) options { recv_time_zone (+07:00); send_time_zone (+07:00); sync (0); time_reopen (100); log_fifo_size (1000); long_hostnames (off); use_dns (no); use_fqdn (no); create_dirs (yes); chain_hostnames(yes); keep_hostname (yes); }; source s_sys { file ("/proc/kmsg" log_prefix("kernel: ")); unix-stream ("/dev/log"); internal(); #udp(ip(0.0.0.0) port(514)); #tcp(ip(0.0.0.0) port(514) keep-alive(yes)); }; destination d_mysql { pipe("/var/log/mysql.pipe" template("INSERT INTO logs (host, facility, priority, level, tag, datetime, program, msg) VALUES ( '$HOST', '$FACILITY', '$PRIORITY', '$LEVEL', '$TAG', '$YEAR-$MONTH-$DAY $HOUR:$MIN:$SEC', '$PROGRAM', '$MSG' );\n") template-escape(yes)); }; filter f_filter1 { facility (kern); }; filter f_f...

Centralized Log ภาคที่ 2 : PHP SYSLOGVIEWER

1.ดาวน์โหลดและติดตั้ง PHP SYSLOGVIEWER wget http://jaist.dl.sourceforge.net/sourceforge/phpsyslogviewer/phpsyslogviewer-7.2.1.tar.bz2 tar xjvf phpsyslogviewer-7.2.1.tar.bz2 cd phpsyslogviewer-7.2.1 2.สร้างฐานข้อมูล mysql -u root -p mysql > create database syslogng; mysql > exit; mysql -u root -p syslogng 3.สร้างรายชื่อผู้ใช้ vi install/newuser.sql.php php install/newuser.sql.php (ถ้ายังไม่มี php-cli ต้องลงก่อน apt-get install php5-cli) php install/newuser.sql.php | mysql -u root -p syslogng 4.สร้างและตั้งค่าหน้าเว็บ cp -R htdocs /var/www/phpsyslogviewer vi /var/www/phpsyslogviewer/config.php chown root:www-data /var/www/phpsyslogviewer/config.php chmod 440 /var/www/phpsyslogviewer/config.php 5.ลองเข้าดูได้ที่ http://192.168.0.251/phpsyslogviewer 6.เพิ่มความเร็วให้การป้อนข้อมูลลง mysql wget http://jaist.dl.sourceforge.net/sourceforge/phpsyslogviewer/speedupd-7.3.2.tar.bz2 tar xjvf speedupd-7.3.2.tar.bz2 cd speedup-7.3.2ฝ apt-get install debhelper cmake libdaemon-dev libconfuse-d...

Centralized Log ภาคที่ 1 : NTP

ติดตั้ง NTP (Network Time Protocol) ตาม พรบ.ว่าด้วยการกระทำผิดเกี่ยวกับคอมพิวเตอร์ พ.ศ. 2550 กำหนดให้ ต้องตั้งนาฬิกาของอุปกรณ์บริการทุกชนิดให้ตรงกับเวลาอ้างอิงสากล (Stratum 0) โดยผิดพลาดไม่เกิน 10 มิลลิวินาที 1.ติดตั้ง apt-get install ntp (ที่ Log Server และ Server อื่น ๆ) 2.ตั้งค่า Log Server ( /etc/ntp.conf ) # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help driftfile /var/lib/ntp/ntp.drift # Enable this if you want statistics to be logged. #statsdir /var/log/ntpstats/ #statistics loopstats peerstats clockstats #filegen loopstats file loopstats type day enable #filegen peerstats file peerstats type day enable #filegen clockstats file clockstats type day enable # You do need to talk to an NTP server or two (or three). server 203.185.69.60 dynamic server time.navy.mi.th dynamic server time.nist.gov dynamic server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 broadcastdelay 0.008 keys /etc/ntp/keys # Access control configuration; see /usr/share/doc/ntp-doc/html/...

Ubuntu : Squid error page

Image
เข้าไปแก้ไขได้ที่ /usr/share/squid/errors/English/ แล้วก็เลือก file ที่ต้องการแก้ไข เช่น หน้าสำหรับแสดงว่าถูก block ปกติจะชื่อ ERR_ACCESS_DENIED ตัวอย่าง ERROR: The requested URL could not be retrieved รายการ web ที่ถูก block ในช่วงเวลา 8:00-12:00 น. และ 13:00-17:40 น

GeSHi Language Aliases

ทั้ง phpBB ของที่ทำงานและ wordpress ของที่นี่ ต่างก็ใช้ Syntax Hilight ของ GeSHi โดย phpBB เป็น phpBB3.0.5 ติดตั้ง mod bbGeSHi 0.7.5 และ wordpress ใช้ plugin wp-syntax .0.9.8 เวลาใช้มักจะลืมตัวย่อของภาษาอยู่เรื่อย ก็เลยต้อง list ไว้กันลืมซะหน่อย ABAP - abap Actionscript - actionscript ADA - ada Apache Log - apache AppleScript - applescript APT sources.list - ASM (m68k) - asm ASM (pic16) - asm ASM (x86) - asm ASM (z80) - asm ASP - asp AutoIT - autoit Backus-Naur form - Bash - bash Basic4GL - BlitzBasic - blitzbasic Brainfuck - bnf C - c C for Macs - c_mac C# - cpp C++ - csharp C++ (with QT) - cpp-qt CAD DCL - caddcl CadLisp - cadlisp CFDG - cfdg CIL / MSIL - COBOL - ColdFusion - cfm CSS - css D - d Delphi - delphi Diff File Format - diff DIV - div DOS - dos DOT language - dot Eiffel - eiffel Fortran - fortran FourJ's Genero - genero FreeBasic - freebasic GetText - glSlang - GML - gml gnuplot - Groovy - groovy Haskell - haskell HQ9+ - ...

Determing SQL Server Database and Table Size

Example 1 (SQL Server table) Run the following SQL statement from Teratrax Database Manager, Query Analyzer, or SQL Server Management Studio. Replace the names in bold with your own: USE db1 GO EXEC sp_spaceused N'dbo.orders' GO Results * name: Table name for which space usage information was requested * rows: Number of rows existing in the table * reserved: Total amount of reserved space for table data and indexes * data: Amount of space used by table data * index_size: Amount of space used by table indexes * unused: Total amount of space reserved for table but no yet used Example 2 (SQL Server database) You can also run sp_spaceused without any parameters to display information about the whole database. Replace the names in bold with your own: USE db1 GO EXEC sp_spaceused GO Results First Recordset: * database_name: Name of the current database * database_size: Size of the current database in megabytes. database_size includes both data and log ...

Delete Domain Controller using ntdsutil.exe

1.ntdsutil 2.metada cleanup 3.connections 4.connect to server 5.quit 6.select operation target 7.list domains 8.select domain 9.list sites 10.select site 11.list servers in site 12.select server 13.quit 14.remove selected server 15.quit 16.quit

How To Setup Multiple Virtual Hosts In Apache

กรณีต้องการให้เครื่อง localhost เครื่องเดียว เรียกได้หลาย domain ทำได้ดังนี้ 1.ตั้งค่า virtualhost ใน apache ที่ไฟล์ /etc/apache2/https.conf NameVirtualHost 127.0.0.1:80 ServerName test.sci.com DocumentRoot "/var/www/test" ServerName cc.sci.com DocumentRoot "/var/www/cc" 2.แก้ไขไฟล์ /etc/hosts เพื่อให้เรียกใช้ตามชื่อ ที่ ตั้งไว้ในข้อ 1 127.0.0.1 test.sci.com 127.0.0.1 cc.sci.com นอกจากนี้ก็มีตัวอย่างอีกหลายแบบ ดูได้ที่ http://httpd.apache.org/docs/2.0/vhosts/examples.html