The workshop archive: hands-on notes from fifteen years of building things, spanning Linux, Kubernetes, AWS, databases, and the home lab. I keep these here because the best architecture advice comes from people who have actually done the work. For current writing on technology strategy and AI adoption, see Posts.
I know there’s many ways to do this, but I quite like this method for a batch file rename:
ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/bash If you want to do a dry run first, then just omit the pipe to bash:
ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2'
Sometimes SCP, SFTP or other methods of file transfer aren’t available. Using netcat and tar, files can be archived and sent over the network on the fly, like this:
On the destination server: mkdir /destination/directory cd /destination/directory nc -l 7000 | tar x On the source server: cd /source/directory tar cf - * | nc destination-hostname 7000
Its useful to have a dedicated logfile which contains details of packets which are dropped or rejected by your iptables firewall. This will allow to you see when connection attempts are being made to your server by IP addresses which are being blocked. This can also be extremely useful when troubleshooting your iptables firewall.
If you’re not up to speed with iptables, then you’ll need to find another guide to work through....
On the primary DB node: Enable binary logging in my.cnf:
[mysqld] log_bin=mysql-bin server-id=1 Restart MySQL
/etc/init.d/mysqld restart Create a user for replication:
mysql> GRANT REPLICATION SLAVE ON *.* TO 'user'@'1.2.3.4' IDENTIFIED BY 'slavepass'; Find filename of binlog:
mysql> show master status; Do the mysqldump of the database you want to replicate:
mysqldump -c –create-options -u root -ppassword –lock-tables databasename > dump.sql Copy the sql file over to the slave:
scp dump....
USB hard disks are often allocated different device names by Linux each time the system boots. For example: what is currently recognized as /dev/sda1 may well end up being /dev/sdb1 after a reboot. To get round this, it is possible to mount disks by label rather than device name by taking the following steps (as root):
First of all, you need to see if the partition in question already has a label:...
Creating a self-signed certificate for an apache server is fairly straightforward. The following steps show you how to do it on an ubuntu / debian based system running apache:
If it doesn’t already exist, make the directory for the key, csr and certificate to go in:
mkdir /etc/apache2/ssl Go to that directory:
cd /etc/apache2/ssl Generate the private key (Enter a passphrase when prompted, we’ll remove this later)
openssl genrsa -des3 -out server....
Here’s an easy way change the names of all files in a directory from upper to lower case (note that we are using ls -1 and not ls -l in this example):
user@server:~/test$ ls -1 FIVE FOUR ONE THREE TWO user@server:~/test$ for file in `ls -1` ; do newfile=`echo $file | tr .A-Z. .a-z.` ; mv $file $newfile ; done user@server:~/test$ ls -1 five four one three two To invert the process, simply change reverse the options passed to the ‘tr’ command like this:...