Recently in Linux Category

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

Compile PHP with couchdb

user-pic
Vote 0 Votes

cd php-5.6.23
git clone https://github.com/akissa/php-couchdb
mv php-couchdb ext/couchdb
rm configure
./buildconf --force
./configure --enable-couchdb

Compile PHP with mongodb

user-pic
Vote 0 Votes

cd php-5.6.23
wget -qO- https://pecl.php.net/get/mongo-1.6.14.tgz | tar zxv
mv mongo-1.6.14 ext/mongo
rm configure
./buildconf --force
./configure --enable-mongo

mongo extension 已經被 mongodb 取代, 不過仍有維護及安全性更新

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