2019




snmpwalk -v2c -c public localhost

Talk to the SNMP daemon on macOS 10.14.

sftp -q backup@spack.org:/backup.zip /vol/backups/

Silently download /backup/zip from spack.org and save it /vol/backups. Good for cron.

docker cp /usr/bin/telnet.netkit  zabbix-appliance_zabbix_1:/tmp

Copy the telnet binary to a docker instance which doesn't have it for debugging.

grep security /etc/apt/sources.list > /tmp/security.list; sudo apt-get -s upgrade -oDir::Etc::Sourcelist=/tmp/security.list

Create a temporary sources.list file which only contains security related updates. Then run apt-get in simulation mode to show what those updates are. Run without the -s to actually install security updates.

ansible-playbook -K -l joker.spack.org stuff.yml

Only run the playbook stuff.yml on the host joker.spack.org and prompt of a sudo password before running.

ansible all -m setup

Gather facts from all configured hosts (replace all with a hostname to run against a single host).

ansible all  -m shell -a 'echo $TERM'

Get the value of $TERM from all hosts.

hostname -I

A way to get the IP address of a host which doesn't have ifconfig or ip installed.

ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"Mb") }'

Print the total MB used of php-fpm processes.

git remote add origin git@bitbucket.org:adamshand/ansible.git; git push -u origin master

Connects a local repository to a remote one and pushes contents of local repo.

git remote set-url origin git@bitbucket.org:spackorg/ansible.git

Changes the remote repo that the local repo is connected to.

curl https://github.com/adamshand.keys

Download adamshand's ssh public key from Github.

curl https://api.github.com/users/adamshand/keys

Download adamshand's ssh public key from Github in JSON.

lsbom -fls /private/var/db/receipts/org.insecure.nmap.*bom

[Mac] show all files installed as part of a package.

log show -predicate '(processImagePath contains "configd") && (eventMessage contains "en0: SSID pekapeka")' -style compact -last 1d | awk '{print $1,$2,$6,$8}' | sed 's/:[0-9][0-9].[0-9][0-9][0-9]//' | uniq

[mac] uses the new log subsystem to print a tidy list of the connections to the “pekapeka” Wi-Fi network in the last day.

networksetup -listallhardwareports | awk '/Wi-Fi/ {getline; print $2}'

[mac]Prints the name of the Wi-Fi interface on a Mac.

nettop -m tcp -t wifi -d -p java -p httpd

Provides a top-like view of network traffic. Shows only TCP traffic on WiFi interfaces from processes named “java” or “httpd”.

nc -z foo.example.com 80-90

Scan ports 80 to 90 on host foo.example.com to see if they are listening and report.


2014 by adam shand. sharing is an act of love, please share.