Useful Code Snippets
0 4 * * * /usr/bin/docker compose -f /home/garret/prod/docker-compose.yml down
4 4 * * 1 /usr/bin/docker compose -f /home/garret/prod/docker-compose.yml pull
9 4 * * 2-7 /usr/bin/docker compose -f /home/garret/prod/docker-compose.yml up -d
@reboot /usr/bin/docker compose -f /home/garret/prod/docker-compose.yml up -dDocker compose cron sample (user)
6 4 * * 1 /usr/bin/apt-get update -y
11 4 * * 1 /usr/bin/apt-get upgrade -y
16 4 * * 1 /usr/sbin/reboot nowDocker compose cron sample (root)
#backup
sudo dd if=/dev/sda status=progress | bzip2 > /media/disk/image.bz2
#restore
bzcat /media/disk/image.bz2 | sudo dd of=/dev/sda status=progressBackup an entire disk
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj /C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname"Create self-signed certificate
adb devices
adb shell
pm list packages | grep demo.app
pm uninstall -k --user 0 com.my.demo.app
----------------------------------------------
adb shell cmd package install-existing com.my.demo.appAndroid remove software
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
echo "done"
Put proper permissions on web folder
apt-get --print-uris --yes -d --reinstall install -y build-essential > dependencies
sed -i 's/ .*//' "dependencies"
<clean up the file with sed and manual inspection>
wget -i dependencies
sudo apt-get --print-uris --yes -d --reinstall install -y linux-headers-$(uname -r) > headers
sed -i 's/ .*//' "headers"
wget -i headers
dpkg -i *Download all dependancies for a package, debian offline install
{
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Status}}\\t{{.Names}}"
}
Neater docker ps output
docker exec -it <id> psql -U postgres
\l
\dt+ *.*
SELECT * FROM <tablename>;Database snippets