Last arg

Reusing the last argument is something that I frequently do when working in bash. I’ve more or less committed the !$ history expansion to memory. This makes it really easy to do something like touch myfile.txt and then immediately edit it with vim !$. I learned about another way to do this using escape-dot today. It works the same way. It’s nice to learn new stuff but i’ll probably stick with !

Read More

Scripting Secure Ubuntu Server Creation

If you create a cloud virtual machine and run it for anything more than a few minutes, it quickly becomes apparent how much nefarious activity goes on. You will get hit with brute force attacks on all of the known ports (and some unknown ones) pretty much continuously from the first minute. I don’t know that there is much that cloud hosts can do about this. They have known IP ranges and I would assume that attackers constantly troll those known ranges.

Read More

Bash strict mode

I’d been starting bash scripts with set -euo pipefail. I don’t really know where I got it from but it was something I’d picked up over the years. Aaron Maxwell has an excellent description of how this works and why it is a good idea. I also learned about the Internal File Seperator setting in that blog post and why that is a good idea. Read his excellent post. The net is that you should start your bash scripts with the following:

Read More