Tag: command line

Clone hard disk with rsync

I recently wanted to move a system over to a faster, larger SSD. I didn’t want to have to re-install an OS, figure out which old files to transfer over, and then re-configure everything. That’s not a fun time in my book. Here’s what I did (on a live system, yeah!) to clone my disk.

Finding call-time pass by references in PHP.

While trying to move an older code base to a newer system and thus a newer version of PHP (5.3 -> 5.5), I knew that some of the code would need to be changed to avoid using some removed features. Specifically, I mean call-time pass by references. For those who don’t know, this is kind

Scripted WordPress Upgrades

This command line interface for administering WordPress is called wp-cli. It’s pretty great. I wrote a script to run from cron for updating a bunch of different WP installs in the same directory. [crayon-5f5dbc16e8e88428360603/]

Switching from APF to CSF

I was enjoying trying out APF on my Raspberry Pi, but I noticed that it wasn’t blocking repeat attackers the way I wanted it to. fail2ban was working the way it was supposed to work, but it only blocks temporarily, and I never figured out why the gamin back-end to continuously monitor log files didn’t

Re-map the Caps Lock Key to Esc on Mac

Seil is a very cool utility for key re-mapping / enabling international keys on a Mac. I wanted to re-map the mostly useless Caps Lock key to Esc, which I use constantly in vi. If you’re a regular vi user, you know exactly what I’m talking about. Now I just have to develop the muscle

Fix the broken APF package on Debian/Ubuntu

The Debian / Ubuntu package for Advanced Policy Firewall (APF) seems a bit unmaintained. By default it won’t run without some initial tweaking. Note that they probably want everyone to just download and run the installer from their site nowadays, but that’s not how I roll (usually). [crayon-5f5dbc16e8ece845729847/] In functions.apf, change the line [crayon-5f5dbc16e8ed1332345070/] to

APF, fail2ban & more

APF is wonderful for a good-enough firewall solution for a lot of people. But what if you also want the power of another great tool, fail2ban? The problem is, fail2ban wants to make changes directly to iptables, which APF is maintaining. Rules that fail2ban writes will be overwritten by APF. I found the solution is

Get items unique only to list1

…from two lists with some overlap. Spent some time working in Python on this problem. Afterwards, I realized it’s a shell one-liner. comm -23 <(sort f_most) <(sort f_some) | sort -n > f_uniq_to_1 I re-sort the output numerically since comm assumes its input is sorted lexicographically, and I happen to be comparing lists of numbers.

Machine-readable Dates

I had some directories named in the format of “Jul 18, 2012”. Thanks, iPhoto export, but no thanks. [crayon-5f5dbc16e8f9b783524185/] Note: gdate is GNU date after doing homebrew install coreutils.

sort -u versus sort | uniq

I just ran into an interesting situation with sort -u. I had generated a couple files with md5sum and they had a lot of equal lines in them. So I thought I would create a merged version.

It’s the routing table, stupid!

It only took three years for the frustration to build up sufficiently. :-) Finally I went a little deeper to try to solve the mystery of the 30 second hang time before requests to my Linux guest VM would return. I love doing testing on a Linux guest VM via VirtualBox while working on my

Quick Linux ACL

I wanted a directory and everything under it to always get the same owner, group and mode, regardless of who created the files. Access Control Lists to the rescue. [crayon-5f5dbc16e8fd7036419071/] I had to apt-get install acl to get the setfacl command. I’m not exactly clear on why I repeat two regular ACLs with the “d:”

Raspberry Pi SSH cipher speed

I was curious to see how quickly I could transfer files to my Pi using SSH rather than FTP. Obviously using FTP is way faster than almost any other method, but still I wanted to see how fast I could transfer data over SSH. Here’s the time it took to transfer a 50 MB file

Enable X11 Forwarding on Raspberry Pi

The usual suspects failed me last night when the $DISPLAY environment variable wasn’t being set after I logged in via SSH to my Pi. The usual suspects being to make sure that the X11 forwarding options were turned on in /etc/ssh/sshd_config on the server and in ssh_config on the client, or to use the command

Multi-page PDF to multiple images

[crayon-5f5dbc16e909a101756352/] Prefix that with gm if you’re running GraphicsMagick rather than ImageMagick. The %d part means that a number should be placed there to indicate the page number from the original that the image file contains. So a three-page PDF will produce [crayon-5f5dbc16e909c396383685/] You can get a better default sort order on the files by