หน้าเว็บ

วันอังคารที่ 26 กันยายน พ.ศ. 2560

วิธีใช้งาน Serial Port บน Linux

จากการที่ได้ทดลองใช้งาน config อุปกรณ์หลายๆ อย่างทางด้าน network วิธีแก้ปัญหาด้านการ config คือการใช้งาน console port แทนการใช้งาน config ด้วย ip ซึ่งจะเด้งหลุดออกมาบ่อย เนื่องจากการ config ip สำหรับการใช้งาน serial port ผ่าน computer desktop สามารถเข้าไปดูได้ที่ Device Manger ว่า serial port อยู่ port ที่เท่าไหร่ ซึ่งจะเอามาใช้งานที่ตัวโปรแกรม putty ได้เลย


เช่นตัวอย่าง มีทั้ง Com1 Com2 ที่มี port ติดมาให้กับเครื่อง desktop และมี USB Serial Port ที่เสียบเพิ่มเป็น Com4 เพิ่มขึ้นมาด้วย ส่วนใหญ่ใช้งานกับเครื่องที่ไม่มี serial port มาให้ รวมถึง notebook ด้วย

หากต้องการใช้งาน serial port บน linux ต้องใช้งานในสถานะของ root เท่านั้น (ผ่าน command line) ไม่อย่างนั้นต้องไปกำหนด chmod port นั้นๆ ให้สามารถใช้งานด้วยผู้อื่นได้ เช่นผ่านโปรแกรม putty ต้องกำหนดให้เป็น 666 จากเดิม 600







วันศุกร์ที่ 8 กันยายน พ.ศ. 2560

การ Upgrade Firmware SG500X-24 ด้วย tftp

หลังจากที่อัพเกรด switch cisco sg500x-24 ไปแล้วตัวนึง นานมากกกก ก็ลืมเขียนเอาไว้ จนวันนี้มานั่งทำอีกตัวนึงที่เหลือ เงิบเลย ไปไม่เป็นเลย วิธีการอัพ ซึ่งการอัพหลังจากเวอร์ชั่น 1.2.x++ ไปแล้ว ไม่สามารถอัพได้ผ่านหน้า webgui ต้องผ่านทางระบบ tftp เท่านั้น และเขียนลง image ทับลงไปแทนของเดิม แล้วค่อย active ตัวที่อัพอีกที

จากที่ได้ทดลองอัพแล้ว ไม่ผ่าน!!~ ก็เลยต้องไปอ่าน manual ในการอัพ ... ผลที่ได้คือ ต้องอัพไล่เวอร์ชั่นตามที่ระบุเอาไว้ ซึ่ง ก็ไม่ได้จะต้องอัพทุกอัน แต่จะมีบาง firmware ที่ต้องอัพเกรดก่อน ถึงจะอัพเวอร์ชั่นถัดไปได้ .... เอาซะหมดวัน วันนี้เลยมาเขียนคำสั่งเก็บเอาไว้ เผื่อวันข้างหน้า มันอัพเกรดอีก ก็จะได้อัพได้ เพราะเขียนเอาไว้เองนี่แหละ เฮ้อ มา เริ่มกันเลย ขั้นแรก รันโปรแกรม Open TFTP Server รอไว้ และเอาไฟล์ firmware ที่ดาวโหลดมา ใส่ไว้ใน folder ก่อน และต่อสาย console (ผมใช้สาย console โดยใช้ putty ในการรีโมท) ต่อสายกับ port com1 เสร็จแล้วต่อด้วยความเร็ว 115200kbps อย่าลืม ตั้ง backspace เป็น ctrl+H นะ เดี๋ยวจะกดไม่ได้ (ลืมประจำ) เมื่อเข้าได้แล้ว ให้ใส่ user password ที่ตั้งเอาไว้ หรือถ้าเป็นเครื่องใหม่ หรือเครื่องที่ reset ก็ใช้ cisco เป็นทั้ง user pass

ใช้คำสั่งในการดู version ว่าปัจจุบันใช้เวอร์ชั่นไหน และสำรองเวอร์ชั่นอะไร
show version
จากนั้น ให้ทำการอัพเกรด boot ก่อน
copy tftp://<tftp server/path/to/bootimage.rfb boot
เมื่ออัพเกรดบูทเสร็จแล้ว ให้เช็คด้วยคำสั่ง show version ว่าเป็นเวอร์ชั่นที่อัพหรือไม่ แล้วรันคำสั่ง
wr            # write ลงเครื่องเพื่อ savereload     # โหลดระบบใหม่เป็นการ reboot
เมื่อทำเสร็จแล้วให้เริ่มอัพเกรด firmware ต่อเลย
copy tftp://<tftp server/path/to/firmware.ros image
เมื่อเสร็จแล้ว ก็ทำการเขียนลงระบบเอาไว้
wr            # write ลงเครื่องเพื่อ savereload     # โหลดระบบใหม่เป็นการ reboot
เท่านี้ ก็เสร็จเรียบร้อยแล้วครับ เริ่มเข้าไปทำการ config ระบบได้เลย

default ip : 192.168.1.254
user : cisco
password : cisco











วันอังคารที่ 5 กันยายน พ.ศ. 2560

การใช้งาน Smart Card บน Ubuntu, LinuxMint (Dabian)

หลังจากที่ทางกระทรวง ได้มีการพัฒนาการใช้งาน smart card ในการ login เข้าสู่ระบบแล้ว เนื่องจากไฟล์การใช้งาน และการติดตั้งนั้น มีไว้เฉพาะ windows เท่านั้น ซึ่งจะต้องมีการติดตั้ง java เพื่อเรียกใช้งานด้วย สามารถใช้ได้ทั้ง JDK และ JRE (ปกติ user ทั่วไปใช้ JRE) แต่ทีนี้ปัญหาก็คือ สำหรับผู้พัฒนาบางคน (เช่นผม) ใช้งาน linux desktop เพื่อใช้ในการ config network หรือ server ที่ให้บริการ จึงทำให้ต้องมาหาวิธีเพื่อทำให้ smart card มันใช้งานบน linux desktop ได้ด้วย ก็ค้นๆ หาๆ จนไปเจอในเวปนี่ล่ะ - -" จำไม่ได้เพราะ copy เอาไว้แต่คำสั่ง ขออภัยจริงๆ ไม่รู้จะอ้างถึงที่มาจากตรงไหน แต่พูดได้เต็มปากว่า copy เค้ามานะครับ มาเริ่มกันเลย

ติดตั้ง package สำหรับใช้งาน smart card ซึ่งไม่ได้ใช้งานจากตัวติดตั้งที่ดาวโหลดมาจากเวป hdc นะครับ ใช้ในตัวของ ubuntu,mint ไปได้เลย มันใหม่กว่า
sudo apt install pcscd pcsc-tools
หลังจากนั้น เสียบ smart card กับเครื่องคอม แล้วก็เสียบบัตรประชาชนเพื่อทดสอบว่าสามารถใช้งานได้ด้วยคำสั่ง
sudo pcsc_scan
ถ้าไม่มีอะไรผิดพลาด จะมีการแสดงรายละเอียดของบัตรขึ้นมาให้เห็น ก็แสดงว่าสามารถอ่านบัตรได้แล้ว ให้กด Ctrl+c ยกเลิกการทดสอบ

ติดตั้ง java ในกรณีที่ยังไม่ได้ติดตั้ง สามารถเลือกใช้งานได้ทั้ง JRE หรือ JDK ถ้าเป็นผู้พัฒนาแอพ จากนั้นให้ทำการเรียกใช้งาน
java -Dsun.security.smartcardio.library=/lib/x86_64-linux-gnu/libpcsclite.so.1 -jar javadaemon.jar 8080
อย่าลืมเข้าไปอยู่ใน path ที่เอามาจาก windows ด้วยนะ โดยปกติอยู่ใน SmartCard/printdaemon

** ถ้าหากเรียกใช้งานบ่อย ให้ทำไฟล์ shell script เอาไว้เรียกจะสะดวกเวลาใช้งานมากกว่า

หลังจากที่เรียกใช้งานได้แล้ว ก็เข้าสู่ HDC ได้โดยใช้งานบัตรประชาชนครับ เมื่อใช้งานเสร็จ ก็ปิดหน้าต่าง shell script ที่เปิดอยู่ หรือกด Ctrl+c เพื่อยกเลิกแล้ว exit ออก เพียงเท่านี้ก็สามารถใช้งานได้แล้วล่ะครับ



วันอาทิตย์ที่ 13 สิงหาคม พ.ศ. 2560

ให้ userdir ใช้งาน php ได้ เป็นคนๆ ไป

<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_value engine Off
    </Directory>
# เพิ่มเป็น user ไป
    <Directory /home/your_user_name/public_html>
        php_admin_value engine On
    </Directory>
</IfModule>


อนุญาตให้เป็นคนๆ ไป ให้เพิ่มตัวนี้ ถ้า user ไหนไม่ได้ใช้งาน php ก็ไม่ต้องเพิ่ม

วันศุกร์ที่ 23 มิถุนายน พ.ศ. 2560

เพิ่มพื้นที่ให้ /boot

To free up space on the root file system you can try to execute apt-get clean.
If that doesn't work you can go to /var/cache/apt/archives and manually remove a few files from the cache to get some space back, e.g.:
sudo rm linux-headers-*
It won't hurt to remove all of the .deb files here if you need to--that is what apt-get clean does. They will be automatically be re-downloaded by apt if they are again needed.

Freeing Up Space on the /boot File System

The Original Poster has a separate /boot partition, and that is what is full and preventing the apt system from working. It will be necessary for him to free up space there.
If there almost enough space, go to /boot and remove a config file or two:
sudo rm config-3.2.0-19-generic-pae
for example, but using the name of one of the kernel versions you intend to remove anyway. This will free up a little space (about 144K apiece).
If you need more space individually remove old vmlinuz initrd, abi and System.map files until you have enough space (about 22 megs for one of my i386 kernel versions).
Whatever you do, don't remove them all. You should at least keep the latest two matching versions of each kind of file, for each kind of kernel you use.
Then proceed with your apt-get install commands. As mentioned above they may have to re-download some of the debs you deleted, but if so that will happen automatically. When you have apt working again, clean up by using apt-get to remove the packages corresponding to the files you removed--so everything matches.

The config file in /boot is the kernel config that was used by the kernel team to build the kernel of the same name. It should be harmless to remove unless you want it for reference or to aid you in building your own kernels.
Finally you are manually removing an old kernel package or two from the /boot partition to make even more room for the new one.