Recently in Linux Category

Shadowsocks server

Vote 0 Votes

pip install shadowsocks

create /etc/shadowsocks.json

ssserver -c /etc/shadowsocks.json -d start

cd /etc/yum.repos.d

yum -y install httpd

Linux mount disk image

Vote 0 Votes

若要 mount 一個以 dd dump 出來的 image
(例如 dd if=/dev/sda of=disk.img)
先用 fdisk -l disk.img 看一下 Sector size 是多少, 通常是 512
要 mount 那一個分割區, 就用 offset 參數指定 512*Start 位置
例如 partition 1 Start 2048, offset 就是 512*2048 = 1048576
mount -o loop,offset=1048576 disk.img /mnt

DNS delegation check

Vote 0 Votes

dig +trace

Rsyslog missing log

Vote 0 Votes

比較新的 Linux 都是使用 systemd journal 來處理 log, 其預設是有 Rate Limit 的,
若系統的 Log 量很多, 有可能會被達到限制條件而被過濾掉,
若觀察到 Log 有時卡住沒有新的出現, 可能就是這個狀況
journalctl -u systemd-journald
若有看到 Suppressed xxx messages 就表示有被濾掉

取消 Rate Limit 限制

/etc/systemd/journald.conf 加入

/etc/rsyslog.conf 加入
$imjournalRatelimitInterval 0
$imjournalRatelimitBurst 0

systemctl restart systemd-journald
systemctl restart rsyslog

ref. Missing logs?!? Learning about linux logging systems

Fetch remote ssl certificate

Vote 0 Votes

openssl s_client -showcerts -connect < /dev/null


Vote 0 Votes

Certbot 已經成為 Let's Encrypt 的官方 Client
cd /usr/local/bin
chmod a+x certbot-auto
certbot-auto certonly --webroot -w /var/www/html -m -d -d
若有更多域名, 繼續加 -d 參數指定
憑證會產生在 /etc/letsencrypt/live/

剩下不到30天內到期可以執行 Renew 指令
certbot-auto renew

Apache 設定
Uncomment Include conf/extra/httpd-ssl.conf in httpd.conf
conf/extra/httpd-ssl.conf 內容
SSLCertificateFile "/etc/letsencrypt/live/"
SSLCertificateKeyFile "/etc/letsencrypt/live/"
SSLCertificateChainFile "/etc/letsencrypt/live/"
SSLCACertificateFile "/etc/letsencrypt/live/"

Add time stamps in bash history

Vote 0 Votes

echo HISTTIMEFORMAT=\"%F %T \" >> /etc/profile

996 2017-12-14 12:49:18 ifconfig
997 2017-12-15 12:06:55 ifconfig
998 2017-12-15 12:49:08 ifconfig
999 2017-12-15 12:51:11 ifconfig
1000 2017-12-15 13:38:41 ifconfig

# curl -v 2>&1 | egrep -i "issuer:|expire"
* expire date: Feb 01 00:11:00 2018 GMT
* issuer: CN=Google Internet Authority G2,O=Google Inc,C=US

Screen reattach a session

Vote 0 Votes

Useful when connection drop

screen -Dr
Reattach a session. If necessary detach and logout remotely first.

screen -DR
Attach here and now. In detail this means: If a session is running, then reattach.
If necessary detach and logout remotely first.
If it was not running create it and notify the user. This is the author's favorite.

About this Archive

This page is an archive of recent entries in the Linux category.

Life is the previous category.

Misc is the next category.

Find recent content on the main index or look in the archives to find all content.

Linux: Monthly Archives

Monthly Archives