Tag: Unix

The accomplishment for the week (Tech!)

So where I work – instead of doing standard mysqldump SQL dumps – they copy the INNODB files into a backup. These backups an beĀ  6GB or more per week. So it was killing the VM the MySQL server runs on.

Now my predecessor had started writing a prune-mysql-backups.sh script. All he’d done was do a list files (ls -At) in time order and then create a text file called filelist.

But the thing was, the dated files went in ascending order. I didn’t want them that way. And apparently he didn’t know enough about sort and sed to complete the script. Sort or sort does exactly what it says, sorts a list of items. The term sed means Stream Editor.

So I had to fire sort -r which means in reverse chronological order then I ran sed to strip out the three newer items in the list, and then pass that file in to a section that walked through the list and rm -rf’d the directories.

That last part ‘rm -rf’ is a goodie. In Unix parlance rm means REMOVE and the -r means recursive the f being all files. You never, ever, ever want to do this on the root partition which would be ‘rm -rf /’. A fast and hard rule to live by is something has to live in FRONT of the slash, e.g. ‘rm -rf 2013-09-30_21-00-34/ ‘would be ok since it’s going to try to walk in that directory and then delete the content and directory.

Another trick is to alias rm -rf and have it make a confirmation of “Do you really want to do this?” before proceeding. That’s the power of Unix/Linux. You can write scripts and aliases to do pretty much anything.

An expansion on Octal

I mentioned Octal as being base 8. It’s true. However in Linux circles you can either set permissions on a file or folder using user/group/other I always found it clunky. Instead you can just do a chmod 551

It breaks down as follows:

4 is read

2 is write

1 is excute

So chmod 551 says User can read and execute, group can read and execute, and other only gets to execute.

You just add up the values to get the permissions for each. All privs come up to chmod 777, that’s read, write and execute for EVERYONE.

But you can understand why it’s called Octal – only 8 possible values for each position.

So it’s now official

I’m a Unix guy. It has been boiling around in my resume for awhile now. At this juncture I’ve now dealt with more Unix and Linux systems than Windows systems.

Granted I still know the hell out of Windows too. For example, I know how to get Windows to route packets destined for certain devices over a certain interface.

But the majority of my experience has now been with Unix and open source tools. And I know how to use Corkscrew to tunnel http connections on Unix too.

xkcd is on the Open Source kick now

First there’s tar – tar in unix circles stands for Tape Archive. Though you can tar off to any device you wish. For example tar -cvpf /home/tonypo/* /dev/mt0/tonypo.tar would work to create an archive.


And then there’s PERL and Regex, I’ve done a LOT of interesting Regex.


And they even riff on probability in a more applicable sense:


Yeah, that’s 2,000,000 germs that don’t succumb to the sanitizer. Now couple the sanitizer and some UV light and you might get it down to around 100,000. But even still that’s unacceptable.

And why am I up at 2:30 AM?

Because I’m rebooting a client box in preparation to upgrade it at the end of the week. Linux/Unix has this little oddity. It’s so damnably reliable that it rarely if ever really requires a reboot.

I’ve heard stories and actually experienced a Linux box in an organization that was several years old but we had no idea where it was physically located. We could connect to it, manage it, etc. But it was buried somewhere in the building. I actually found it about a year and a half later. It was tucked into the very back of the warehouse. I threw a monitor on it and tapped the keyboard and was presented the login prompt. Sure enough, it was that server.

Anyhow the reason I’m doing a reboot is because Linux/Unix after so many days without reboot, forces a disk check. And the box I’m working on here hadn’t been rebooted in year!

Now this is a 250GB volume and it’s taken 31 minutes to get 66.6% through the disk check of that volume. I know I could screw with settings and make it ignore the disk check but honestly, it’s easier to let it just scan.

Interesting segue into my next post. That 666 number. Stay tuned!