1. Add new user and database to Mysql
    Create database ‘database’;
    CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON database.* TO ‘rss’@‘localhost';
    FLUSH PRIVILEGES;
    
  2. List listening ports
    netstat -ap tcp | grep -i "listen"
    
  3. 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>
      
  4. 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
    
  5. 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"
    
  6. Hibernate Mac -> Here
  7. Find blogger feed url - add this to end
    /feeds/posts/default?alt=rss
    
  8. Download all files in directory
    wget - r - np -nH cut-dirs -R index.html http://hostname/aaa/bbb/ccc/ddd
    
  9. Generate dhparam
    openssl dhparam -dsaparam -out /etc/ssl/private/dhparam.pem 4096
    
  10. Check system logs for a service
    journalctl -u <service.name> -f
    
  11. 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
    
  12. Setup rTorrent with ruTorrent
  13. Jekyll
    • Run on custom host
      bundle exec jekyll serve -H 10.8.0.1
      
  14. Nmap
    • Scan for open ports
      nmap -sS -sU -PN -p 1-65535 thedoc.eu.org
      
  15. Open port on SSH
    ssh -L <localPort>:127.0.0.1:<remotePort> sshConfig
    
  16. UFW
    • Allow from specific subnet
    sudo ufw allow from <subnet/24> to any port <port-no>
    
    • Delete rule
    sudo ufw delete allow <port>
    
  17. To add users to a group
    sudo usermod -aG <grp_toadd> user
    sudo chmod g+rw <folder>
    
  18. Forward SSH port to localhost
    ssh -L <localPort>:localhost:<remotePort> <server_config>
    
  19. Change text in any file using bash/sed
    sed -i 's/original/new/g' file.txt
    
  20. Repeat a command in bash every n seconds
    while :; do clear; <command> ; sleep < n seconds >; done
    
  21. Adb commands to control package manager
    pm list packages
    pm path package.name
    adb install -r package.apk
    pm disable --user 10 package.name
    
  22. 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