Recently in Linux Category

Rsyslog missing log

user-pic
Vote 0 Votes

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

取消 Rate Limit 限制

/etc/systemd/journald.conf 加入
RateLimitInterval=0
RateLimitBurst=0

/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

user-pic
Vote 0 Votes

openssl s_client -showcerts -connect google.com:443 < /dev/null

Certbot

user-pic
Vote 0 Votes

Certbot 已經成為 Let's Encrypt 的官方 Client
使用很簡單
cd /usr/local/bin
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
certbot-auto certonly --webroot -w /var/www/html -m yourname@email.com -d yourdomain.com -d www.yourdomain.com
若有更多域名, 繼續加 -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/yourdomain.com/cert.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/yourdomain.com/privkey.pem"
SSLCertificateChainFile "/etc/letsencrypt/live/yourdomain.com/chain.pem"
SSLCACertificateFile "/etc/letsencrypt/live/yourdomain.com/fullchain.pem"

Add time stamps in bash history

user-pic
Vote 0 Votes

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

history
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 https://google.com 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

user-pic
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.

curl -T to PUT file to PHP

user-pic
Vote 0 Votes

Sender
curl -T file http://host/upload.php

Receiver upload.php code
if ($_SERVER["REQUEST_METHOD"]=="PUT") file_put_contents(date("YmdHis") ,file_get_contents("php://input"));
// date("YmdHis") is output filename

Eanble tftp server in CentOS7

user-pic
Vote 0 Votes

yum -y install tftp-server

Edit /etc/xinetd.d/tftp, add -c if need create (put file in)
server_args = -cs /var/lib/tftpboot

systemctl enable tftp.socket
systemctl start tftp.socket

PS. xinetd is not necessary

Linux Named Pipe

user-pic
Vote 0 Votes

mkfifo fifo_file
cat fifo_file

In another shell session
date > fifo_file

You'll see date info in first shell session.
General Usage: piping data from program A to program B.

ref. Named pipe

OTP Client for Linux and Windows

user-pic
Vote 0 Votes

For Linux: OATH Toolkit
For Windows: WinAuth

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