Notes
Written by Simone
I'll update this post whenever I see fits, A.K.A. when I have other bits of information which don't require a whole post.
Operations on files and directories
Move files and directories to the current/parent directory in Linux
Current dir
find . -type f -exec mv {} . \;
Parent dir
find . -type f -exec mv {} .. \;
Recursive chmod on files and dirs
To change all the directories to 755 (-rwxr-xr-x
):
find /var/www/blog -type d -exec chmod 755 {} \;
To change all the files to 644 (-rw-r--r--
):
find /var/www/blog -type f -exec chmod 644 {} \;
Certbot common commands
Register single domain:
certbot certonly --standalone -d domain.tld --dry-run
Renew single domain:
certbot renew --cert-name domain.tld --dry-run
- Remove “–dry-run” when ok.
Revoke certificate:
certbot revoke --cert-path /etc/letsencrypt/archive/${YOUR_DOMAIN}/cert1.pem
Check certificate's expiry date:
cat /etc/letsencrypt/live/domain.tld/cert.pem | openssl x509 -noout -enddate
GIT
To reset your git repository to given commit id, do:
git reset --hard <commit-id>
git push origin master --force
Ignoring files that are already tracked
git update-index --assume-unchanged <your file here>
Delta Chat Mail sieve
require ["fileinto"];
# rule:[DeltaChat]
if header :contains "Chat-Version" "1.0"
{
fileinto "DeltaChat";
stop;
}
Postfix mail queue
To view postfix mail queue in case of problems and remove a particular message from it, do as follows:
# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
6DCF32201B* 4824 Thu Oct 19 22:54:44 roughnecks@woodpeckersnest.eu
debian@spacenet.it
-- 4 Kbytes in 1 Request.
# postsuper -d 6DCF32201B
postsuper: 6DCF32201B: removed
postsuper: Deleted: 1 message
To delete all emails in the queue, use this command:
# postsuper -d ALL
Check Preferred Outgoing IP (when multiple are set on <interface>
)
curl ifconfig.me
The correct command to add a new Linux user (in this case without a shell)
adduser --shell /usr/sbin/nologin <username>
I always forget which command is the complete one, useradd
or adduser
Wireguard IPv6
Written by Simone
Here's my configuration, working fine with my Android 9 Phone
server.conf
root@pandora:~# cat /etc/wireguard/wg0.conf
[Interface]
# specify generated private key for server
PrivateKey = <sekret>
# IP address for VPN interface
Address = 172.16.100.1/32, fd42:42:42::1/64
MTU = 1420
# UDP port WireGuard server listens
ListenPort = 51820
# possible to set any commands after WireGuard starts/stops
# set routing rules like follows to access to local network via VPN session
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;
[Peer]
# REDMI
# specify public key for client
PublicKey = <sekret>
# clients' VPN IP addresses you allow to connect
# possible to specify subnet ⇒ [172.16.100.0/24]
AllowedIPs = 172.16.100.6/32, fd42:42:42::6/128
PersistentKeepalive = 25
client.conf
root@pandora:~# cat /etc/wireguard/redmi.conf
[Interface]
#Private IP Address
Address = fd42:42:42::6/128, 172.16.100.6/32
#Client's Private Key
PrivateKey = <sekret>
#Server's listening port
ListenPort = 51820
[Peer]
#Server's Public Key
PublicKey = <sekret>
AllowedIPs = ::0/0, 0.0.0.0/0
#Server's IP:port
Endpoint = woodpeckersnest.space:51820
sysctl.conf
root@pandora:~# sysctl -p
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.eth0.accept_ra = 2