Tuesday, March 26, 2019

Some useful commands came across while having fun



[Windows] Delete folders recursively 
  • rmdir /s [directory_name]

[Windows] Which ports being used by what apps, and vice versa
  • netstat -aon | findstr '[port_number]'
  • If the port is being used by any application, then that application’s detail will be shown with PID as the last column
  • tasklist | findstr '[PID]'. Replace the [PID] with above
  • Follow the inverse odder to track which application uses which ports too

[Windows] grep a file content. /N is for showing line numbers 
  • type test.txt | findstr /N "text you wanna search in test.txt"
  • npm list -g | grep express
  • curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data 
  • curl -d "param1=value1&param2=value2" -X POST http://localhost:3000/data (POST application/x-www-form-urlencoded)
  • curl -d "@data.json" -X POST http://localhost:3000/data (with data file) 

[Mac] 
  • Removes all .git files/folders -> $ find . | grep .git | xargs rm -rf