Examine traffic to a port on an interface:tcpdump -pni [interface] port [port] -A
Find old files:find [directory] -mtime +[days]
Spy on process output:strace -e trace=write -s1000 -fp [pid] 2>&1 | grep -o '".\+[^"]"'
Top Memory Consumers
Issue: frequently you need to know the top memory-consuming processes on a system at a point in time, typically for scripting.
Solution 1: dump processes and sort off the memory resident field, then reverse to show in descending order.
$ ps aux | sort -nk +4 | tail | sort -rnk +4
Solution 2: dump processes and sort off the memory resident field, then reverse to show in descending order for the top twenty processes.
$ ps aux | sort -nk +4 | tail -20 | sort -rnk +4
Raw Copy Status Update
Issue: sometimes when doing a raw copy with dd it appears that the process has either taken too long or hung. Before completely killing it (since there is no resume) it would be helpful to obtain some status information.
Solution 1: sending a SIGUSR1 signal to the dd process will get a status update.
Issue: receiving errors in the log about insecurity proof failed or no valid RRSIG resolving.
Solution: one of the DNS resolvers in the /etc/bind/named.conf.options is not set up to handle DNSSEC but BIND is trying to use DNSSEC. Either disable DNSSEC or remove the offending resolver.
Issue: DNS queries are not resolving though the service is running.
bind may be trying to use an IPv6 address to do lookups but no IPv6 is supported on your network. Adjust the default options for bind to use only IPv4 for lookups.
# run resolvconf?RESOLVCONF=no# startup options for the serverOPTIONS="-u bind -4"
Issue:pip or pip3 fails to install a package, citing an error message like:
[...]File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 139: ordinal not in range(128)[...]
Solution: this has to do with an unset system locale encoding. Depending on your needs your solution will vary.
If you only need the settings for the current session, simply change the LC_ALL variable to the default system locale. Assuming your locale has been set to en_US.UTF-8 you can set it as such:
$ export LC_ALL="en_US.UTF-8"
To persist those changes, you'll want to modify your system settings in addition to the above.
In some systems you may not have the desired locale built. On those systems (such as Docker images) you'll need to generate and then set the locale: