Difference between revisions of "Command Snips"

From copec
Jump to: navigation, search
(Create New Database and User)
 
(10 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
== Shell ==
 
== Shell ==
 +
=== Linux Kernel CPU Reset ===
 +
  echo 1 > /proc/sys/kernel/sysrq
 +
  echo b > /proc/sysrq-trigger
 +
 +
=== tcpdump ipv6 ===
 +
  tcpdump -i <interface name> -n -vv '(udp port 546 or 547) or icmp6'
  
 
=== Date String Stamp ===
 
=== Date String Stamp ===
Line 24: Line 30:
 
CREATE DATABASE new_db_name;
 
CREATE DATABASE new_db_name;
 
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'good_password';
 
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'good_password';
 +
CREATE USER 'new_user'@'%' IDENTIFIED BY 'good_password';
 
GRANT ALL PRIVILEGES ON new_db_name.* TO 'new_user'@'localhost';
 
GRANT ALL PRIVILEGES ON new_db_name.* TO 'new_user'@'localhost';
 +
GRANT ALL PRIVILEGES ON *.* TO 'root'@' WITH GRANT OPTION;
 +
GRANT ALL PRIVILEGES ON new_db_name.* TO 'new_user'@'%';
 
FLUSH PRIVILEGES;</nowiki>
 
FLUSH PRIVILEGES;</nowiki>
  
Line 39: Line 48:
 
*For human consumption:
 
*For human consumption:
 
  mysqldump --defaults-file=/etc/mysql/debian.cnf --skip-opt <databasename>
 
  mysqldump --defaults-file=/etc/mysql/debian.cnf --skip-opt <databasename>
 +
 +
=== Binary Logs ===
 +
*Purge all logs:
 +
PURGE BINARY LOGS BEFORE now();
 +
*Disable logging: /etc/mysql/conf.d/mysql_skip_log_bin.cnf:
 +
<nowiki>
 +
[mysqld]
 +
skip_log_bin</nowiki>
  
 
== OpenSSL Testing ==
 
== OpenSSL Testing ==
https://easyengine.io/tutorials/mail/server/testing/smtp/
+
* [https://easyengine.io/tutorials/mail/server/testing/smtp/ https://easyengine.io/tutorials/mail/server/testing/smtp/]
  
 
== RAID ==
 
== RAID ==
Line 56: Line 73:
  
 
== MacOS ==
 
== MacOS ==
* [[https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically]]
+
* [https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically]
 +
 
 +
== Linux kexec reboot ==
 +
alias kreboot="echo Loading kexec; kexec -l /vmlinuz --initrd=/initrd.img --reuse-cmdline; echo Rebooting; kexec -e"

Latest revision as of 14:40, 22 March 2024

For infrequent things I tend not to remember off the top of my head.

Shell

Linux Kernel CPU Reset

 echo 1 > /proc/sys/kernel/sysrq
 echo b > /proc/sysrq-trigger

tcpdump ipv6

 tcpdump -i <interface name> -n -vv '(udp port 546 or 547) or icmp6'

Date String Stamp

`date '+%Y-%m-%d-%Hh%M'`
  • For Example:
mysqldump ... > bleh.`date '+%Y-%m-%d-%Hh%M'`.sql 
zfs snapshot -r tank@copec-snap_`date '+%Y-%m-%d-%Hh%M'`

Lock gnome >3.8 remote

DISPLAY=:0 dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

Re-Mount / RW (I always forget the exact syntax...)

  • Might want to add standard mount options to the "-o" like "discard" or "noatime"
mount -o remount,rw /

MySQL

Create New Database and User

For database 'new_db_name' and user 'new_user':

mysql --defaults-file=/etc/mysql/debian.cnf 
CREATE DATABASE new_db_name;
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'good_password';
CREATE USER 'new_user'@'%' IDENTIFIED BY 'good_password';
GRANT ALL PRIVILEGES ON new_db_name.* TO 'new_user'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'root'@' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON new_db_name.* TO 'new_user'@'%';
FLUSH PRIVILEGES;

Update User Password

SET PASSWORD FOR 'username'@'%.example.com' = PASSWORD('good_password');

Mysqlchecks

mysqlcheck --all-databases --repair
mysqlcheck --all-databases --optimize

Dumps

  • For human consumption:
mysqldump --defaults-file=/etc/mysql/debian.cnf --skip-opt <databasename>

Binary Logs

  • Purge all logs:
PURGE BINARY LOGS BEFORE now();
  • Disable logging: /etc/mysql/conf.d/mysql_skip_log_bin.cnf:
[mysqld]
skip_log_bin

OpenSSL Testing

RAID

mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Mirror Website

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://example.org

Systemd

  • Flush DNS cache using the systemd stub resolver:
systemd-resolve --flush-caches
systemd-resolve --statistics

MacOS

Linux kexec reboot

alias kreboot="echo Loading kexec; kexec -l /vmlinuz --initrd=/initrd.img --reuse-cmdline; echo Rebooting; kexec -e"