A running guide of Linux commands focused on Red Hat Based Distros that I often forget.
SSH Control Characters
As with all SSH control characters all commands must follow a return character.
Kill the current SSH connect. Great for when something hangs and you’re waiting for a timeout.
List all forwarded SSH connections.
journal --since 9:00 --until 12:00
Show system logs between those times
journal -u postfix --since yesterday -f
Show all postfix logs since yesterday and follows logs
journal -k -n 20
Kernel messages since last boot limiting to 20 messages
<c-b> :setw synchronize-panes (on/off)
Synchronize text input on all panes.
sar -d -f /var/log/sa/sa15 -s 19:00:00 -e 21:00:00
Get diskstats on the last 15th of the month between the hours of 7pm and 9pm.
nmap -sP -oG scan-results.txt 10.0.0.0/24,10.0.1.0/24
Quick ping scan of two subnets with greppable outputs written to a file.
nmap -sA -F -Pn <host>
TCP ACK scan common ports without an initial ping scan. Good for mapping out a stateful firewall.
nmap -sU -A -v <host>
Scan all UDP ports with an additional service discovery scan and with verbose output. Can be combined with a TCP scan using the
Wrapper around ifconfig and ip. Very useful for quick access to important info.
nmap --script ssl-enum-ciphers -p 443 <hostname>
Cycles through all the ciphers the webserver will respond too on port 443. Ensuring vulnerable SSL protocols aren’t used.
tcpdump 'host 10.0.1.2 and (dst port 80 or 443)' -w dump.pcap
Capture traffic destine for 80/443 for host IP 10.0.1.2 writing raw output to a file.
netcan be used as well.
Merging in other’s changes
git fetch # Checkout repo metadata git checkout <feature/branch> # Change working HEAD to branch to be merged git fetch # Fetch branch to be merged git rebase master # Flatten branch and set master as base. Use -i squash or delete commits. git checkout master # Change head to master branch git merge <feature/branch> # Move master branch up to HEAD git push origin master # Push new rebased master to origin server
Rebase onto master
git checkout -b <feature/new_branch> # Create new feature branch ... Do Some Work ... git pull --rebase origin master # Shortcut for fetch + rebase
Often Forgotten Linux Utilities
lsof -c ssh -i TCP:22
Filter to TCP port 22 and command strings with ssh.
Tools for finding hardware block devices and filesystems.
dmesg -n 1or
Suspend logging to console until next reboot. Change can be made permanent in