Category Archives: TECH TIPS

Monday Blabber

Just a quick entry to stay in the writing habit. Which, while it’s picked up quite a bit again due to my new crusade it seems *g*, it’s still not a daily endeavor as I’d like it to be. So, even if it’s tripe (er, more tripe than usual,) I’ll try to post something each day.

So today, it’s Valentine’s Day! Hey, there’s a topic!
OK, nothing to say on it. Except, “Happy Valentine’s, Sweetie!” Which is pretty silly, really, since I’ve been telling her all day already, and she never reads my blog. Hrrm.

Well OK, something useful to make the trip here worth it.
If you’re a Linux user, I highly recommend for your anti-virus protection: F-Prot
It’s free for Linux, which is certainly a plus, and works perfectly in my experience. Linux doesn’t get many virii. Maybe, oh, 1% of what Windows users get. But there are some out there, and it only takes one to screw you over. So, always use protection! =)

For Windows, I highly advocate Grisoft’s AVG! It too has a free version for personal use. And for about a year when I was first using it, I used it in conjunction with a $45 copy of Norton Anti-Virus. AVG had detected the ocassional virus that Norton never saw (I download a lot and get tons of spam,) and AVG would always detect anomolies before Norton would. So, free, and better than Norton. What more need be said?

Take that, Spam!

Alright! MT-Blacklist (that beautiful, wonderful man!) has released a new “emergency” upgrade in Blacklist for MoveableType 3.x users (like myself.)
It’s a blog plugin I had used before I upgraded my blog software, which was blocking dozens of spam comments a day! Since it stopped working I turned off blog commenting altogether. Now that there’s a patch for my blog software, on it goes again!
Hooray anti-spam! =)

Coming Out From My (Bash) Shell

Well, I’m into shell scripting now!
It’s amazing! It makes me feel like I did back in 7th grade when I discovered programming on Apple II’s, and 9th grade when I started using Basic on Commadores, and a few years ago when I started PHP. The feeling of power, of control. That you can make this machine do what you want it to, and the potential is limitless!

I’ve used bash shell scripting for a couple years now…solely to make 1-line scripts to replace a 1-line command. Like, so I can set up a cron (automated) job to maybe tarball a directory, or something super simplistic. I’ve finally started writing my own scripts to do slightly more complex and interactive things.

It’s extremely similar to PHP in many ways, but also different in many ways that matter. So while it’s not completely alien to me, it is pretty much a new language for me.

Anyway, here’s a couple of really helpful sites I’ve been using:

Here’s a snippet from the code I wrote to restore a backed up mySQL database.
I’m proud of it. =) (Although the first few lines of nested IF/THENS is pretty clunky. I’m going to find a better way. But at least it works as-is.)


echo -n “What database file are you restoring from? > ”
read response1
if [ “$response1” ]; then
if [ -f “$response1” ]; then
echo “”$response1″ does not exist!

echo -n “Last try: What database file are you restoring from? > ”
read response1
if [ “$response1” ]; then
if [ -f “$response1” ]; then
echo “”$response1″ does not exist! Exiting….

exit 1
echo -n “What database name are you restoring? > ”
read response2
if [ “$response2” ]; then
echo -n “Are you sure you want to use “$rep1” to restore database “$rep2″? (y/n)> ”
read response
if [ “$response” != “y” ]; then
echo “Exiting.”
exit 1
mysql -u root –host=localhost $rep2 < $rep1 echo "Success! " exit 0 fi ----------------------------------------------------------------------------- ADDENDUN: Drat. The blog doesn't display spaces or tabs at the beginning of lines. So, unless I put in lines of periods, that code sample is displayed as justified left instead of formatted properly. Oh well. Makes it harder to read, but (shrug) ADDENDUM in "Extended Entry"... Continue reading Coming Out From My (Bash) Shell

Cool, Basic Linux Commands

So I’ve been using Linux for about 6 years now. Off and on. In that time I’ve learned to do a LOT of things–from building drivers to get odd pieces of hardware to work to writing scripts that do daily backups.

But it seems, even as late as last week, I keep finding all these little, very simple commands that do cool things I’d not seen before and sure wish I knew years ago.
Commands that are so basic that it’s embarassing to have not known about them for so long…even though I know how to do things like install applications from source code and manage an Apache Web server only through the httpd.conf and other config files, never using a GUI. =)

Here’s a few recent, very useful Linux commands:

> du -s /(path)/* | sort -nr
— That one shows you a list of how much disk space each sub-directory is taking up.

> which (executable filename)
— Gives you the exact location of that executable. Would have LOVED to have known that one when I was upgrading PHP and ImageMagic a few months ago!

> fg
— lists currently running programs started via that bash session.

> set
— lists active variables. Excellent for writing shell scripts! Which I’m starting to really get into.

> file (filename)
— explains exactly what kind of file it is. Much more detail than simply “text” or “binary”.

> find /(path)/ -name “*.txt” -mtime +30 -type f -exec rm -f {} \;
— I sorta knew how to use the “find” command but never really read the MAN (manual) before. Little did I know until just today how you can find files based on create,modification, or access dates AND attach other commands to do to it.
In this example, it’ll find any regular file with a .txt extension in a specified path that was modified more than 30 days ago, THEN it deletes each file it finds. I set this one up as a daily cron job on a certain directory to prevent it from building up too many temp files.

Sharing the wealth. =)

Oops, “fg” does not list jobs, like “jobs” does…it brings background jobs into the “fore-ground.” So if you send a job into the background with the ampersand or “bg”, you can bring it back up with the “fg”.