tcpdump -i any port 3306
Author Archives: Vitalijus Ryzakovas
curl resolve
curl resolver:
curl --resolve example.com:80:127.0.0.1 http://example.com/
sponge install linux
apt-get install moreutils
parse error: Invalid numeric literal at line 1,
curl remove -i:
curl -X POST -H 'Content-type:application/json' -d @my_file https://192.168.100.100/api.php | jq .
hosts file per user
if you just need SSH shortcut:
vim ~/.ssh/config file
Host myhost
Hostname 192.168.100.12
ssh: connect to host port 22: connection timed out to null
ssh: connect to host 192.168.100.1 port 22: Connection timed out
ssh 192.168.100.1 hostname 2>/dev/null
bash do not create file if empty result
tee empty file
use ifne
grep -ri website /etc/apache2 | ifne tee /tmp/outout.log
rm also can help:
grep -ri website /etc/apache2 > /tmp/outout.log ; [[ $? -ne 0 ]] && 'rm' -f /tmp/outout.log
varnish systemd 80 port
mkdir /etc/systemd/system/varnish.service.d
vim /etc/systemd/system/varnish.service.d/varnishd.conf
[Service]
ExecStart=
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -F -a :80 -T 127.0.0.1:8081 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,256m
systemctl daemon-reload && systemctl start varnish
install keepalive 2 ubuntu
add-apt-repository ppa:hnakamur/keepalived
upstream repository: https://github.com/acassen/keepalived
deb source repository: https://github.com/hnakamur/keepalived-deb
More info: https://launchpad.net/~hnakamur/+archive/ubuntu/keepalived
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmprfmnb5nq/secring.gpg' created
gpg: keyring `/tmp/tmprfmnb5nq/pubring.gpg' created
gpg: requesting key 1017341E from hkp server keyserver.ubuntu.com
gpg: /tmp/tmprfmnb5nq/trustdb.gpg: trustdb created
gpg: key 1017341E: public key "Launchpad PPA for Hiroaki Nakamura" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
mv -v /usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt /tmp/
'/usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt' -> '/tmp/DST_Root_CA_X3.crt'
update-ca-certificates
Updating certificates in /etc/ssl/certs...
W: /usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt not found, but listed in /etc/ca-certificates.conf.
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
apt update
sed leave only 1000 last lines
instead sed use tail:
tail -n 1000 file.log | sponge file.log
ubuntu iptables remove all rules
iptables allow all:
iptables -P INPUT ACCEPT && iptables -P FORWARD ACCEPT && iptables -P OUTPUT ACCEPT && iptables -t nat -F && iptables -t mangle -F && iptables -F && iptables -X && iptables-save > /etc/iptables/rules.v4
mysql extract table from dump
sed -n -e '/DROP TABLE.*`my_table`/,/UNLOCK TABLES/p' mydump.sql > table.sql
make sure table is correct:
egrep -h "DROP TABLE|CREATE TABLE" table.sql
DROP TABLE IF EXISTS `my_table`;
CREATE TABLE `my_table` (
bash pass array as command line argument
domains=(domain1.com domain2.com domain3.com)
printf ' -d %s' ${domains[*]} | xargs certbot --apache
it runs such command:
certbot --apache -d domain1.com -d domain2.com -d domain3.com
bash grep after match line to array
alias_Domains=(`grep -m1 -oP '(?<=ServerAlias ).*' /etc/apache2/sites-enabled/website.conf`)