Linux geral

Progresso de cópia

com cp e pv

cp -r /the/source /the/destination | pv -lep -s $(du -sb /the/source | awk '{print $1}') >/dev/null

com rsync

rsync -aP /the/source /the/destination

com cp e bar

cp -r /the/source /the/destination | bar

Matando todos os processos de um usuário

sudo kill -9 $(pgrep -u username)

Mostrando o certificado SSL (https ou não)

# site em https
openssl s_client -showcerts -servername docs.rda.run -connect docs.rda.run:443 < /dev/null

# qualquer outro serviço tls também funciona
openssl s_client -showcerts -servername tlshost.example.org -connect tlshost.example.org:49056 < /dev/null

Mostrando o service tag da Dell

sudo dmidecode -s system-serial-number

Usando um lockfile para rodar um script apenas um por vez

#!/bin/bash

lockfile="$0.lockfile"

if [[ -e "$lockfile" ]] && ! kill -0 "$(< "$lockfile")" 2>/dev/null; then
	echo "Warning: lockfile exists but the process is dead, continuing."
	rm -f "$lockfile"
elif [[ -e "$lockfile" ]]; then
	echo "My important work is already running. Exiting."
	exit 1
fi

printf '%s\n' "$$" > "$lockfile"

# adicione aqui todas as coisas importantes.

rm -f "$lockfile"

exit 0

Visualizando o crontab de todos os usuários

for user in $(cut -f1 -d: /etc/passwd); do echo $user; sudo crontab -u $user -l; done

Simulando o trim() do java em bash

echo " test test test " | sed -e 's/^ *//' -e 's/ *$//'

referência: StackOverflow