Cheatsheet
-
Add new user and database to Mysql
Create database ‘<database>’; CREATE USER '<user>'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON <database>.* TO <user>@‘localhost'; FLUSH PRIVILEGES;
-
Enable logging without restarting
SET GLOBAL general_log = 'ON'; SET GLOBAL slow_query_log = 'ON';
-
Disable runtime logging
SET GLOBAL general_log = 'OFF'; SET GLOBAL slow_query_log = 'OFF';
-
https://www.pontikis.net/blog/how-and-when-to-enable-mysql-logs
-
-
List listening ports
netstat -plntu | grep -i "listen"
- Docker
-
Update after files change
docker-compose up -d --build
-
Logs
docker-compose logs -f -t
-
Destroy all docker images
docker stop $(docker ps -a -q) docker rm $(docker ps -a -q) docker rmi $(docker images -q) docker exec <name> <command>
-
-
Mailgun Setup
apt-get update apt-get install postfix libsasl2-modules
-
Add to /etc/postfix/main.cf
smtp_sasl_auth_enable = yes relayhost = smtp.mailgun.org smtp_sasl_security_options = noanonymous smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
echo 'smtp.mailgun.org <mail>:<password>' > /etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd postmap /etc/postfix/sasl_passwd service postfix restart sudo apt-get install -y mailutils echo "Mail test" | mail -s "Subject" root echo "This is testing SMTP Relay." | mail -s "Postfix Mailgun" $MAIL
-
-
Send mail on every sudo command
visudo -f /etc/sudoers.d/my_sudoers Defaults mail_always Defaults mailerpath=/usr/sbin/sendmail Defaults mailto="root" Defaults mailerflags="-t"
- Hibernate Mac -> Here
-
Find blogger feed url - add this to end
/feeds/posts/default?alt=rss
-
Download all files in directory
wget - r - np -nH cut-dirs -R index.html http://hostname/aaa/bbb/ccc/ddd
-
Generate dhparam
openssl dhparam -dsaparam -out /etc/ssl/private/dhparam.pem 4096
-
Check system logs for a service
journalctl -u <service.name> -f
-
Remove commited directories from git remote branch
git rm -r --cached some-directory git commit -m 'Remove the now ignored directory "some-directory"' git push origin master
- Setup rTorrent with ruTorrent
- Jekyll
-
Run on custom host
bundle exec jekyll serve -H 10.8.0.1
-
- Nmap
-
Scan for open ports
nmap -sS -sU -PN -p 1-65535 thedoc.eu.org
-
-
Open port on SSH
ssh -L <localPort>:127.0.0.1:<remotePort> sshConfig
- UFW
-
Allow from specific subnet
sudo ufw allow from <subnet/24> to any port <port-no>
-
Delete rule
sudo ufw delete allow <port>
-
https://www.digitalocean.com/community/tutorials/ufw-essentials-common-firewall-rules-and-commands
-
-
To add users to a group
sudo usermod -aG <grp_toadd> user sudo chmod g+rw <folder>
-
Forward SSH port to localhost
ssh -L <localPort>:localhost:<remotePort> <server_config>
-
Change text in any file using bash/sed
sed -i 's/original/new/g' file.txt
-
Repeat a command in bash every n seconds
while :; do clear; <command> ; sleep < n seconds >; done
-
Adb commands to control package manager
pm list packages pm path package.name adb install -r package.apk pm disable --user 10 package.name
- Android Studio : Solve support library issue
- Execute in Terminal
./gradlew -q dependencies app:dependencies
- Then search for conflicting dependencies version
- add the latest version for conflicting dependencies explicitly in build.gradle
- Execute in Terminal