Linux Utils Quick Reference Guides


Linux Filesystem Octal Formats

Ok, I’m mostly doing this for my own references, because even after all these years of working purely on Unix based systems (mostly Darwin) I tend to forget the exact options I need. In the case of this first one, it’s not like I ever memorized every octal code besides maybe 755 and 644 for web server files.

You pretty much never want to set the permission of a file to 777, perhaps only in rare cases and I mean super rare! If you have file permissions set to read, write, and execute for all users you’re doing something else wrong like ACLs are skewed!

IPTables - Packet Filtering or Firewall

Now this one I never remember and I mean like never! I always end up searching DuckDuckGo almost immediately or I’ll quickly list my rule table from existing servers I have already locked down. Soon enough I’ll have this configured in some sort of custom resource in a configuration management system like Chef or Ansible. Or maybe just cut to the chase, save me some time and effort and use a pre-existing cookbook!

Always remember to allow loopback connections from your network loopback interface. The loopback interface is also used if you configure your application server to connect to a database server with a localhost address, which is common!

$ sudo iptables -A INPUT -i lo -j ACCEPT
$ sudo iptables -A OUTPUT -o lo -j ACCEPT

As always, Digital Ocean has a shit ton more tips and tricks for IPTables

rsync - Quick Remote and Local File Util

I love rsync!! I’d have to say it’s in my top 5 favorite Linux tools, I’ve used it for so many use cases and I swear some of those fancy deployment tools you find on the internets are simply just wrapping rsync! Can’t back this theory up, nor do I care enough, just sayin…

But I can never remember how to copy files locally. Here are some memorable flags that should stick to the ol’ membranes:

Just like this person says, I also use this to backup/copy files to thumb drives. When it comes to using rsync as a backup tool or even worse a deployment mechanism, it can be done and I’m sure some people do it. As for myself I’d rather just use a tool specifically built for backing up files like Carbon Copy Cloner or Super Duper! are just two that I own and highly recommend. As far as deployments go, I’m not gonna lie, I’ve used rsync plenty of times for the quick-n-dirty, but I definitely don’t condone this. Although I do understand you need to get shit done sometimes and “nobody got time for Jenkins!”

more to come…

comments powered by Disqus