Quickhacks
Useful one-liners to do things faster, or blocks of code to facilitate more complex operations.
Update each docker compose service nested in a directory
find $MY_DOCKER_DIRECTORY -mindepth 1 -maxdepth 1 -type d -exec bash -c "cd '{}' && docker-compose pull && docker-compose up -d" \; && docker image prune -f
Change $MY_DOCKER_DIRECTORY
with your own path. Example directory:
/My/Docker/Directory/
├── Jellyfin/
│ └── docker-compose.yml
| └── ...
├── Dashy/
│ └── docker-compose.yml
| └── ...
└── Pi-hole/
└── docker-compose.yml
└── ...
How it works
Suppose you have multiple docker-compose services inside $MY_DOCKER_DIRECTORY
like in the tree structure above.
The command above will go inside each sub-folder (cd '{}'
), pull the latest images available (docker compose pull
) and update the services (docker compose up -d
) .
Once every service has been updated, it will remove old images (docker image prune -f
) to free up space.
Notes
This command will go and execute inside every sub-folder in $MY_DOCKER_DIRECTORY
so make sure that each one of them has a docker-compose.yml
file in it.
Copy multiple files from a remote ssh server
scp -r USER@REMOTE_IP:/remote/path/* /local/path
Change:
USER
with the user on the remote machineREMOTE_IP
with the IP of the remote machine/remote/path/
with the path containing the files on the remote machine/local/path
with the path where you want to paste the files on the local machine
How it works
Pretty self-explanatory. Copies files from inside the /remote/path/
directory on the server to the /local/path
directory on your local machine.
Chroot properly to repair a Linux system
sudo mount /dev/sda3 /mnt
sudo mount /dev/sda1 /mnt/boot
cd /mnt
sudo mount -t proc proc proc/
sudo mount --rbind /sys sys/
sudo mount --rbind /dev dev/
sudo cp /etc/resolv.conf etc/resolv.conf
sudo chroot /mnt
# You can now proceed to fix your installation
Change:
/dev/sda3
with your system root partition/dev/sda1
with your system boot partition
If in doubt, use lsblk -f
to check your partitions.
When done, remember to exit
and unmount every directory in reverse order using umount -f
.
Why
Sometimes it happens that Grub breaks, network isn't working anymore, or you're having problems with initramfs/mkinitcpio.
Before you chroot
in your linux partition to repair your installation, it's important to mount the necessary directories or else most of the fixes you'll try will most likely not work and give you errors.
The block of code above should give you access to everything you need to fix the problems just mentioned.
Notes
Tested on an Artix system.