sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add -
apt update
apt install postgresql-9.4
screen cannot open your terminal ‘/dev/pts/0’ – please check
script /dev/null
screen
postgres check for corruption
postgresql check databases for errors
pg_dumpall -f /dev/null 2> /tmp/pg.err
mysqldump to remote server ssh
mysqldump --single-transaction sourcedb | ssh remote_server_ip 'mysql destinationdb'
syn flood attack
apt install hping3
hping3 -c 15000 -d 120 -S -w 64 -p 80 –flood –rand-source 192.168.1.100
upgrade/downgrade mongo
systemctl stop mongod.service
apt update
apt install mongodb-org=3.6.8 mongodb-org-mongos=3.6.8 mongodb-org-server=3.6.8 mongodb-org-shell=3.6.8 mongodb-org-tools=3.6.8
systemctl start mongod.service
mongo
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
vi /etc/apt/sources.list.d/mongodb-org-4.0.list
deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse
apt update mongodb*
apt upgrade
wtmp clear last 10
#include
#include
struct utmp foo;
main()
{
printf("%lu\n", sizeof foo);
return 0;
}
Perl:
$utmp_size = utmp_record_size_goes_here;
$wtmp_file = "wtmp filename goes here";
open WTMP, "+<", $wtmp_file or die "$wtmp_file: ", $!;
seek WTMP, -10 * $utmp_size, 2;
truncate WTMP, tell(WTMP);
close WTMP;
lock crontab job
* * * * * /usr/bin/flock -w 0 /tmp/cron.lock /usr/bin/php7.4 /path/to/cron.php
Parse error: syntax error, unexpected ‘elseif’ (T_ELSEIF) in
vim /etc/php/7.4/cli/php.ini;
short_open_tag=On;
ALTER tables without lock
pt-online-schema-change alters a table’s structure without blocking reads or writes. Specify the database and table in the DSN. Do not use this tool before reading its documentation and checking your backups carefully.
parted create partition one line
parted -s -a optimal -- /dev/sdX mkpart primary 1MiB -2048s
list slave mysql
show slave mysql
mysql> SELECT * FROM information_schema.PROCESSLIST AS p WHERE p.COMMAND = 'Binlog Dump';
+---------+------+-------------------------+------+-------------+---------+---------------------------------------------------------------+------+
| ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO |
+---------+------+-------------------------+------+-------------+---------+---------------------------------------------------------------+------+
| 3973053 | user | srv-mysql-slave1:53014 | NULL | Binlog Dump | 3743978 | Master has sent all binlog to slave; waiting for more updates | NULL |
+---------+------+-------------------------+------+-------------+---------+---------------------------------------------------------------+------+
resize xfs
grow xfs:
xfs_growfs /dev/vg_test/lv_test
Command: MLSD Error: The data connection could not be established: ECONNREFUSED – Connection refused by server
Command: MLSD
Error: The data connection could not be established: ECONNREFUSED - Connection refused by server
Error: Connection timed out after 60 seconds of inactivity
Error: Failed to retrieve directory listing
echo "40000 45000" > /etc/pure-ftpd/conf/PassivePortRange
echo "1.2.3.4" > /etc/pure-ftpd/conf/ForcePassiveIP
service pure-ftpd restart
mysql update user host
UPDATE mysql.db SET Host='%' WHERE Host='localhost' AND User='username';
FLUSH PRIVILEGES;