My Own Unix Tricks and Tips

  • sending stderr and stdout to /dev/null:      ./script.sh > /dev/null 2>&1 or job <arg1> <arg2> &>/dev/null
  • batch renaming of files:      for i in *.avi; do j=`echo $i | sed 's/find/replace/g'`; mv "$i" "$j"; done
  • grep recursively down a directory tree:      find . -exec grep my_pattern {} \; -print
  • how to find out how many files a user/process has open:      lsof
  • tcpdump to look via Wireshark:      sudo tcpdump -i enp0s3 dst bixan.com -w /tmp/dump.pcap
  • how to use scrappad on cli (caution: data won't be saved):      cat > /dev/null
  • how to display maven dependency tree:      mvn dependency:tree -Dverbose
  • how to re-download maven dependency:      mvn dependency:purge-local-repository
  • how to recreate a mysql database schema from the database:      mysqldump -n -d -h <host, e.g. xjdz3.dailyrazor.com> -B <database-name> -r ./mysqldump.sql -p
  • how to create self signing ssl cert:      keytool -genkeypair -alias testCert -keyalg RSA -storetype PKCS12 -keystore keystore.p12 -storepass password
  • How to run a local http server for testing?:

    1. You must have Python 3+ installed.
    python3 -m http.server <port>

    2. Another way is to run a node-based http-server (https://github.com/http-party/http-server). This server is especially good for running React SPA. React SPA requires all requests to route through index.html. This server provides that via a hack -
    http-server --proxy http://localhost:8080?