Category Archives: System Administration

nmap

nmap -sP 192.168.2.0/24 用來偵測開機的ip mac,適合當不知道guest vm的ip時,先查除vm的網卡mac,再找出對應的ip

Posted in System Administration | Leave a comment

jq

這邊主要是介紹一個不錯的command line util: jq jq主要是command line JSON filter,適合用在bash script處理json,特別是要取得特定的field,和處理formatting bash script一般處理文字常用sed, awk,但是遇到json,單純的字串處理很難應付複雜的結構。 參考: https://stedolan.github.io/jq/manual/

Posted in System Administration | Leave a comment

tmux notes

tmux是一個終端管理的工具,類似screen但功能更強,特別是多了pane以及畫面同步的機制。 <prefix>: default ctrl+b (註: screen為 ctrl+a) create a new window: <prefix> + c next: <prefix> + n prev: <prefix> + p detach: <prefix> + d kill: <prefix> + x (<prefix> + k) jump: <prefix> + number list windows and … Continue reading

Posted in System Administration | Leave a comment

docker install on CentOS 6.9

在epel-repo有帶1.7的docker yum -y install epel-release yum -y install docker-io #升級成1.9.1 參考 https://www.jianshu.com/p/31248c006c06 curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 chmod +x docker-1.9.1 mv /usr/bin/docker /usr/bin/docker-1.7 cp ./docker-1.9.1 /usr/bin/docker docker pull centos:6.9 有問題 先關掉service service stop docker #看起來是必須升級kernel rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm yum … Continue reading

Posted in System Administration | Leave a comment

bash exclamation (!)

在bash處理有帶!的字串要注意他本身有其他功用(history expansion),作為字串夾在double quote時 https://www.gnu.org/software/bash/manual/bashref.html#Double-Quotes Enclosing characters in double quotes (‘”’) preserves the literal value of all characters within the quotes, with the exception of ‘$’, ‘`’, ‘\’, and, when history expansion is enabled, ‘!’. 要注意的是escape !不可用 \ backslash\! 會是 \! … Continue reading

Posted in System Administration | Leave a comment

windows elevate UAC

在windows csharp的程式中,如果要一開始限定執行為administrator系統管理權限,可以在manifest檔註記參考 https://stackoverflow.com/questions/2818179/how-do-i-force-my-net-application-to-run-as-administrator <requestedExecutionLevel level=”requireAdministrator” uiAccess=”false” /> 或是用程式強制重新起始為系統管理權限(放在Main起始處)參考 https://itneverworksfirsttime.wordpress.com/2012/02/27/using-uac-to-request-administrative-privileges-from-c/ 另外實測時,如果是32bit程式,在某些情況會被windows7判定為安裝程式而跳出”This program might not have installed correctly”https://docs.microsoft.com/en-us/windows/desktop/SbsCs/application-manifests可用manifest繞過Program Compatibility Assistant(PCA)https://support.microsoft.com/en-my/help/2545347/excluding-programs-from-the-program-compatibility-assistant-pca

Posted in System Administration | Leave a comment

remote deploy with ssh

遠端佈署時,常常更新完檔案要重新啟動服務,使用ssh execute remote command 可以整合在script方便automation ssh $HOST COMMANDssh $HOST COMMAND1; COMMAND2; … scp SCRIPT.sh $HOST:ssh $HOST SCRIPT.sh #將多個command 放在script 以上使用SSH Key-Based Authentication的方式驗證

Posted in System Administration | Leave a comment

find files modified in 1 day

找出最近更動的檔案(1 day),這在清查設定檔或是程式被更動時方便使用的指令 find . -mtime -1 -ls 參考:https://stackoverflow.com/questions/16085958/scripts-find-the-files-have-been-changed-in-last-24-hours

Posted in System Administration | Leave a comment

git tips

delete a tag locally and remotely git push –delete origin tagNamegit tag -d tagName

Posted in System Administration | Leave a comment

socks5 proxy

SOCKS5 rfc可參考1996年 rfc 1928 (其他: rfc 3089 socks based gateway)須注意socks5本身並未加密,最好是透過ssh port forwarding SOCKS5 proxy設置最簡單的方式 是 putty ssh tunnel ssh -D 1080 user@server 注意port number 1024以下的權限問題(root) -D [bind_address:]port Specifies a local “dynamic” application-level port forwarding. This works by allocating a socket … Continue reading

Posted in System Administration | Leave a comment