Tuesday, August 30, 2016

Grep for a particular file type

Grep is great for searching recursively through a directory of source code, but it annoyingly wastes time looking at binary files and other file types that I am not interested in. When I am looking through some Java code for a reference to something like writeTextToLog(), I would ordinarily go to my top level directory and use

grep -r "writeTextToLog(" .

But this returns lots of binary target file results like this that clutter the screen and sit there chewing up time:

Grep for a particular file type

Grep is great for searching recursively through a directory of source code, but it annoyingly wastes time looking at binary files and other file types that I am not interested in. When I am looking through some Java code for a reference to something like writeTextToLog(), I would ordinarily go to my top level directory and use

grep -r "writeTextToLog(" .

But this returns lots of results like this that clutter the screen and sit there chewing up time:

Wednesday, June 15, 2016

Some data tools

There are some good command line data tools in this blog post for working with data. Specifically, csvkit is pretty useful.

Wednesday, May 11, 2016

Figuring out which internet connection is being used

Now that fiber connections are more widely available (including in my house) sometimes I will plug my laptop in to a wired connection so that I can take advantage of the higher speeds. For general browsing and listening to music it doesn't make much difference whether I am on wifi or wired in, but when transferring large amounts of data, it can make a big difference. But when I plug in the wired connection, do I need to disconnect my wifi to ensure I am using the connection? How do I tell which connection is being used? The answer is found with the Linux tools route and traceroute.

Monday, April 4, 2016

Viewing login attempts

Open an ssh port to the internet and in a short time you will see all kinds of login attempts. There will be repeated attempts to access your system using usernames such as "admin" and "root" and others that are presumably left unguarded on systems somewhere. There are all kinds of simple steps to take to ensure that these attempts are not successful and that they don't overwhelm your system (such as using fail2ban). The log files auth.log and syslog (found in /var/log) will be full of attempts, but how do you look to see if anyone has successfully logged in?

Wednesday, February 24, 2016

Running Python pip on a specific python installation

Python versions are a bit confused on my Ubuntu install right now. If I type "python" at the command line I get Python 2.7. If I type python3 then I get Python 3.4. And python3.5 gives me Python 3.5. Not usually a problem because I put the correct entry in the shebang of the script I am running, but it is sometimes difficult to get pip to install in the right place (or, I should say, to figure out where pip installed and determine if it is where I want it, because who knows what the "right" place is?).

Wednesday, November 18, 2015

Useful Byobu Commands

Using the terminal in Linux is a must, but sometimes it is a little restricting (especially when logged in over an SSH session). Screen has been a longtime solution for these limitations, providing a terminal user some simple commands to switch among terminal sessions and easily keep sessions running in the background, but recently I have been using Byobu instead. Byobu is built on Screen as well as another solution called tmux.

Thursday, September 10, 2015

Purging old kernels to make room on /boot

I've installed Linux on lots of laptops and desktops by now, and like most people I succumbed to the desire to make some custom decisions on how the system should be configured. One of the most basic decisions is the layout of the system across multiple partitions. There are some technical advantages to having a separate /boot partition, but (especially with Ubuntu, which is what I use) the /boot partition eventually fills up with old kernels and you are unable to perform the standard software updates because the drive doesn't have enough free space. There are a number of recommended ways to clear out these old kernels, but most involve lots of scripting or command line magic. Oddly, there is not a one-button solution within the software updater, where it would be incredibly convenient. But there is a simple command from the bikeshed package to handle this problem.

Wednesday, February 18, 2015

Using DB2 from Python

I have been searching on and off for several years to try and find a simple way to use Python for DB2 queries. Connecting to DB2 from Java is fairly simple--or at least straightforward, because nothing in Java is really that simple--but I have had trouble finding the information and steps for actually making Python speak to DB2. I have finally found the right combination of ingredients for the sauce, though, and it turns out to be extremely simple.

Thursday, October 16, 2014

Ignoring Files in Subversion

Most of our project files were originally designed around Eclipse and the IntelliJ project files keep showing up when I do an SVN status. Not a huge deal...it is fairly easy to just ignore them. But I got tired of seeing them and couldn't remember how to make Subversion ignore them. Online info for dealing with Subversion is generally great, but everything I found on this process was a bit confusing so I wanted to put it all together here.