Ubuntu – 指令操作更新

系統:Ubuntu 16.04

指令如下:

查看 cpu core 結果

ps -aeF

查看 lsof 程序的結果

lsof -c "nginx"

不顯示 ps aux  grep 後的結果

ps aux | grep “[n]ginx”

使用grep指令找尋多選擇方式顯示

grep “0x0003\|0x8003\|0x0011\|0x000b\|0x1007\|0x0009”

使用find指令找尋檔案大小排序

之前找資料找到的有用指令,但忘記是那個參考網站,雖然很好用,但用find指令比用du指令找尋還慢

find / -type f -exec du {} \; 2>/dev/null | sort -n | tail -n 10 | xargs -n 1 du -h 2>/dev/null

使用find指令保留30天備份

find ./ -atime +30 -exec rm -f {} \;


使用hdparm指令測試硬碟效能

在雲端provider機器上,若需要知道硬碟效能的話,可以打簡單的指令

測試硬碟效能:hdparm -Tt /dev/vda1

/dev/vda1:
Timing cached reads: 15734 MB in 2.00 seconds = 7876.66 MB/sec
Timing buffered disk reads: 312 MB in 3.02 seconds = 103.26 MB/sec

other test

dd if=/dev/zero of=/tmp/output conv=fdatasync bs=384k count=1k; rm -f /tmp/output

————————————————————————————–

使用perl 字串更換內容字元

把未碼改掉

perl -pi -e 's/m0$/M0/g' hostlist

把此行列刪除掉

perl -pi -e 's/BMV_0201.*K0\n$//g' hostlist

————————————————————————————–

使用OpenSSL指令確認伺服器本機SSL憑證資訊以及時間

指令

# openssl x509 -in kalayserver.pem -text -noout

Certificate:
 Data:
 Version: 3 (0x2)
 Serial Number: 3634694749968046761 (0x3271079e1ed29aa9)
 Signature Algorithm: sha256WithRSAEncryption
 Issuer: C=US, ST=Arizona, L=Scottsdale, O=GoDaddy.com, Inc., OU=http://certs.godaddy.com/repository/, CN=Go Daddy Secure Certificate Authority - G2
 Validity
 Not Before: Jan 8 03:41:00 2018 GMT
 Not After : Mar 24 07:28:01 2021 GMT

參考:https://support.asperasoft.com/hc/en-us/articles/216128468-OpenSSL-commands-to-check-and-verify-your-SSL-certificate-key-and-CSR