ssh port forwarding

Updated: 16 November 2023

What’s ssh port forwarding and what’s the difference between ssh local and remote port forwarding

-R Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side.
-L Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side.

bash

Updated: 21 July 2023

Documentation

Bash guide for beginners
Bash reference manual
Bash reference manual

Miscellaneous

Shorten prompt in current terminal
PS1='\u:\W\$ '

Exit status of last command
echo $?

Repeat a command n times
for run in {1..100}; do command; sleep 5; done

Run A and then B, regardless of success of A
A; B

Run B if and only if A succeeded
A && B

Run B if and only if A failed
A || B

Run A in background.
A &

GoAccess

Updated: 16 January 2022

A visual web log analyzer.

https://goaccess.io/

Connect to your webserver via ssh and pipe the access log to goaccess running locally. Create a report in html format.

ssh user@ \
'cat /var/log/apache2/example.com-le-ssl.conf/access.log' | \
goaccess -a -o /home/chris/report.html --log-format=COMBINED --html-report-title="example.com logs" -

Query DNS data

Updated: 10 May 2023

DNS Lookup

DNS Lookup from Digital Ocean

dig

Query for information on all DNS records

dig your_domain_name.com ANY

Query for A records

dig your_domain_name.com A

host, nslookup and dig share similar functionality.

whois

Return information about a domain name registration, including the name servers it is configured to work with

whois your_domain_name.com

PHPDoc

Updated: 06 May 2024

PHPDoc reference

Generate php documentation with phpdoc tool and Docker

docker pull phpdoc/phpdoc
cd path/to/my-php-project
docker run --rm -v $(pwd):/data phpdoc/phpdoc -d src -t doc

Display cli manual

docker run --rm phpdoc/phpdoc --help