Find Which Process Is Listening on a Port in Linux
"Address already in use" again? How to find the owner of a port with ss, lsof and fuser, decode /proc/net/tcp by hand, and why some ports show no process.
Archive
"Address already in use" again? How to find the owner of a port with ss, lsof and fuser, decode /proc/net/tcp by hand, and why some ports show no process.
match looks like a shorter switch, but it compares strictly, never falls through, returns a value and throws when nothing matches. Here is what that means in practice.
amend, reset --soft, --mixed, --hard, revert and restore each undo something different. A tested walk-through, plus how the reflog recovers from a bad reset.
Work out the network, broadcast address and prefix length of an IPv4 address inside a query, using INET_ATON(), INET_NTOA() and a little bitwise arithmetic.
Find processes by their full command line in pure Bash by reading /proc/PID/cmdline, with the NUL bytes handled properly and the 2009 bugs fixed.
Test whether a directory is empty in pure Bash with nullglob and dotglob, handle hidden and unreadable directories, and know when find -quit is faster.
Bash's ${#var} counts characters, PHP's strlen() counts bytes. A clean strlen() function, a strbytes() companion, and the locale traps in between.
A strtolower() for Bash 4 and the stock macOS Bash 3.2, why ${var,,} depends on your locale, and when declare -l, tr, awk or nocasematch fit better.
A strtoupper() that works on Bash 4+ and macOS's Bash 3.2, plus ${var^^pattern} for uppercasing only some characters and declare -u for variables.
Check whether a string contains a substring regardless of case, with a Bash 4 version, a Bash 3.2 fallback using nocasematch, and a PHP-style stristr().