Go

Usage ~/.zshrc 1 2 3 export GOPATH=$HOME/go export GOROOT=$HOME/local/go export PATH=$GOROOT/bin:$PATH Upgrade 1 2 3 go get -u go mod tidy go mod graph Documents Create a Go module Getting started with multi-module workspaces Environment variables

Podman

Install 1 2 3 4 # For Ubuntu sudo apt install crun podman buildah fuse-overlayfs # For ArchLinux sudo pacman -S crun podman buildah fuse-overlayfs Usage commands 1 2 3 4 5 6 podman image prune # removes all dangling images podman system reset # clean podman images # show images podman ps -a # show containers podman save --format=oci-archive -o CODE-$(date "+%4Y%m%d%H%M%S").tar CODE podman load -i tmp/XXX.tar.xz # import image Config ~/.

Tinkey

Authenticated Encryption with Associated Data (AEAD) Message Authentication Code (MAC) JSON Web Tokens (JWT) 1 2 3 4 5 6 7 8 # list key-templates tinkey list-key-templates # aead tinkey create-keyset --key-template AES256_GCM --out-format binary --out aes.bin # mac tinkey create-keyset --key-template HMAC_SHA512_512BITTAG --out-format binary --out hmac.bin # jwt tinkey create-keyset --key-template JWT_ES512 --out-format binary --out jwt.bin

VSftpd

Install 1 2 sudo apt install vsftpd apache2-utils libpam-pwdfile sudo chown -R ftp:ftp /srv/ftp Set password 1 2 3 4 5 # -c if it is first time sudo htpasswd -b -B /etc/vsftpd/.passwd WHO-AM-I CHANGE-ME # verify password sudo htpasswd -v -b /etc/vsftpd/.passwd WHO-AM-I CHANGE-ME sudo touch /etc/vsftpd/chroot_list /etc/pam.d/vsftpd 1 2 auth required pam_pwdfile.so pwdfile /etc/vsftpd/.passwd account required pam_permit.so /etc/vsftpd/user_list(NO MORE SPACES) 1 WHO-AM-I /etc/vsftpd.conf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 pam_service_name=vsftpd hide_ids=YES anonymous_enable=NO local_enable=YES dirmessage_enable=YES userlist_enable=YES userlist_file=/etc/vsftpd/user_list userlist_deny=NO listen_port=21 pasv_min_port=12100 pasv_max_port=12200 vsftpd_log_file=/var/log/vsftpd.

Swap

Enable swap file 1 2 3 4 dd if=/dev/zero of=/swap.fs bs=1M count=4096 # crete a 4G raw file chmod 600 /swap.fs mkswap /swap.fs swapon /swap.fs /etc/fstab 1 /swap.fs none swap defaults 0 0

OpenSearch

Install Download & Get Started 1 2 3 tar xf opensearch-X-linux-x64.tar.gz sudo mv opensearch-X /opt/opensearch sudo chown -R www-data:www-data /opt/opensearch Configuration /usr/lib/systemd/system/opensearch.service 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [Unit] Description=OpenSearch is the flexible, scalable, open-source way to build solutions for data-intensive applications. Documentation=https://opensearch.org/docs/opensearch/index/ Wants=network-online.target [Service] Type=simple Environment=OPENSEARCH_JAVA_HOME="/opt/opensearch/jdk" WorkingDirectory=/opt/opensearch User=www-data Group=www-data ExecStart=/opt/opensearch/bin/opensearch [Install] WantedBy=multi-user.target /opt/opensearch/config/opensearch.yml Disable https 1 2 3 network.host: 0.0.0.0 discovery.

Redis

Setup cluster nodes setup data folder 1 2 3 4 cd /var/lib sudo mkdir redis-{1,2,3,4,5,6} sudo chown redis:redis redis-{1,2,3,4,5,6} sudo chmod 750 redis-{1,2,3,4,5,6} /etc/redis/node-X.conf 1 2 3 4 5 6 7 8 9 10 11 12 bind 0.0.0.0 port 637X daemonize no protected-mode no dir /var/lib/redis-X cluster-enabled yes cluster-config-file /tmp/redis-node-X.conf cluster-node-timeout 5000 appendonly yes appendfsync everysec /usr/lib/systemd/system/redis-node-X.service 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [Unit] Description=Advanced key-value store After=network.

Ffmpeg

Convert to mp3 1 2 3 4 ffmpeg -i audio.wav -acodec libmp3lame audio.mp3 ffmpeg -i audio.ogg -acodec libmp3lame audio.mp3 ffmpeg -i audio.ac3 -acodec libmp3lame audio.mp3 ffmpeg -i audio.aac -acodec libmp3lame audio.mp3 Mp3 split & warp 1 2 mp3splt 8am.mp3 0.0 88.44 -o 2023-11-03_8am mp3wrap aaa track1.mp3 track2.mp3 track3.mp3

LVM

Show status 1 2 3 pvdisplay vgdisplay lvdisplay Resizing 1 2 3 4 5 6 7 8 # xfs not support lvresize -L -40G MyVolGroup/MyThinPool resize2fs /dev/MyVolGroup/mediavol 10G xfs_growfs /dev/MyVolGroup/mediavol -L 10G lvextend -l +100%FREE MyVolGroup/MyThinPool resize2fs /dev/MyVolGroup/mediavol xfs_growfs /dev/MyVolGroup/mediavol

Ssh

Generating a new SSH key 1 2 3 4 5 6 7 ssh-keygen -t ed25519 -C "your_email@example.com" ssh-copy-id USER@HOST # or mkdir ~/.ssh chmod 755 ~/.ssh cat /tmp/id_ed25519.pub >> ~/.ssh/authorized_keys Proxy Install pproxy 1 2 3 4 5 6 python -m venv $HOME/local/python3 source $HOME/local/python3/bin/activate pip install pproxy pip install asyncssh pproxy -l http://:8008 -r ssh://XXX.XXX.XXX.XXX#deploy::$HOME/.ssh/id_ed25519 pproxy -l socks5://:8008 -r ssh://XXX.XXX.XXX.XXX#deploy::$HOME/.ssh/id_ed25519 Git 1 2 3 4 git config --global http.proxy http://0:8008 git config --global https.

Shell

bash redirect to file 1 cmd >>file.log 2>&1 Compressing compressed to volumes 1 2 # 100m 1G tar jcf - 2017.log | split -d -b 100m - logs.tar.bz2. uncompressed by volumes 1 cat logs.tar.gz* | tar jx Check which listen to the port 1 2 lsof -nP -iTCP -sTCP:LISTEN lsof -nP -i:[port-number] random 32-bits password 1 cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 Reboot 1 2 3 who -b last -x | head | tac sudo journalctl --list-boots set timezone 1 sudo timedatectl set-timezone UTC

Journald

Server /lib/systemd/system/systemd-journal-remote.service 1 ExecStart=/lib/systemd/systemd-journal-remote --listen-http=-3 --output=/var/log/journal/remote/all.journal /etc/systemd/journal-remote.conf 1 2 3 4 5 6 7 8 9 10 [Remote] Seal=false SplitMode=none Compress=yes SystemKeepFree=5% SystemMaxFileSize=1G # ServerKeyFile=/etc/letsencrypt/live/server.your_domain/privkey.pem # ServerCertificateFile=/etc/letsencrypt/live/server.your_domain/fullchain.pem # TrustedCertificateFile=/etc/letsencrypt/live/server.your_domain/letsencrypt-combined-certs.pem 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 sudo apt install systemd-journal-remote sudo systemctl enable systemd-journal-remote # Recommenced not less than 253 sudo sudo dpkg -l systemd-journal-remote # create storage dir sudo mkdir -p /var/log/journal/remote sudo chown -R systemd-journal-remote:systemd-journal-remote /var/log/journal/remote # firewall sudo ufw allow in 19532/tcp sudo ufw allow in 80/tcp # for server certs # sudo chown -R systemd-journal-remote:systemd-journal-remote /etc/systemd/journal-remote-ssl Client /etc/systemd/journal-upload.