useful commands
Curated list of useful commands for different use cases
1. Get PID of process
$ pgrep -a <command>
$ ps w | grep <command>
$ lsof -i4 -P -n | grep LISTENING | grep :<port>
$ lsof -i4 -P -n | grep ESTABLISHED | grep :<port>
# eg.
$ pgrep -a ssh
$ ps w | grep ssh
$ lsof -i4 -P -n | grep LISTENING | grep :22
$ lsof -i4 -P -n | grep ESTABLISHED | grep :222. Process kill signals
# SIGTERM (15) - graceful stop
$ kill -s SIGTERM <pid>
$ kill -SIGTERTM <pid>
$ kill -15 <pid>
# SIGKILL (9) - force kill
$ kill -s SIGKILL <pid>
$ kill -SIGKILL <pid>
$ kill -9 <pid>
# SIGINT (2) - ctrl+c
$ kill -s SIGINT <pid>
$ kill -SIGINT <pid>
$ kill -2 <pid>3. Transfer file(s) between 2 hosts
3.1 Netcat
3.2 Secure Copy Protocol (scp)
scp)3.3 wget + Python3 server
Last updated