Saturday, January 23, 2016

I love Linux: more Linux tools

While most computers in use today run on OS X (Apple) or MS Windows operating systems, there's a small but hardy contingent that run on Linux. My PC is a Windows 10 machine, but I use a Cygwin window to do a lot of my work. When I started a new job in December, I was delighted to discover that my computer was running Linux:

Linux is not an OS for the faint of heart. It's like the do-it-yourself pickup truck or street rod that experienced mechanics or gearheads like to drive — there's always some tinkering to do, and always some workarounds for the whizzy options pre-installed in other vehicles but not yet installed in your own. Nevertheless, if you are a computer professional, Linux is the OS that lets you get stuff done. With Linux, the OS doesn't get in the way nearly as much as it does with Windows.

You're getting off track, Ray. Reel it in. What's this blog post about?

I'm always running across new capabilities and new toys in Linux. Let me tell you about my latest finds. None of these are new. Linux heads with more hours at the keyboard than me have known about these tools for years. Some of them may snicker at me for not having discovered them until now. But if you don't know about them yet, then let me be the first to tell you about them.

screen - a remote terminal utility

Many Linux users have been using screen for years, while I've been trapped in Windows land using TinyTerm and other terminal emulators. screen lets you connect to any device with a serial interface — or any of a number of interfaces. If it's an I/O device listed in the /dev directory, you can connect to it with screen. In fact, with screen, you can connect with multiple devices at once.

For example, if you have an Arduino connected to your Linux box with a USB cable, and the Arduino is listed as /dev/ttyACM0, then you can talk directly to the Arduino (and it can talk back) through the screen interface, after you type the command:

     screen /dev/ttyACM0

ytree and Linuxtree - file management utilities

The tree command allows you to list all the subdirectories and files in your current directory in a hierarchical (tree) diagram. It's moderately useful. For those of us who get tired of typing commands like

     ls * */* */*/*

it gives you a quick way to see all of your files in an organized fashion. Wouldn't it be nice if you could do something with them while they're displayed like that, the way users used to do with Norton Commander or Xtree?

Well, you can! Xtree fans have created two Xtree lookalikes, ytree ( because it comes after Xtree - heh) and Linuxtree. Both are text-based file management utilities that are superior in some ways to Windows Explorer or File Manager or whatever they call it in the latest version of Windows. After you use ytree or linuxtree for a day or two, you won't want to go back to the Windows way of doing things.

Fortunately, you don't have to. There's a Windows-based lookalike, called Ztree. While ytree and linuxtree are free, Ztree costs money. Ztree gives you a fully-functional 30-day free trial, and before the end of the 30 days, if you like it, you pay a (very reasonable) one-time license fee.

autojump - an easier way to jump around

Most Linux heads like to do most of their work from the command line - you know, a window like this

where you use the keyboard instead of  the mouse and type in all of your commands. You make think that's old-fashioned and archaic, like a manual transmission, and you would be right. But the fact is that, even today, all of the really nice, GUI-based programs that you use were created by a team of software engineers punching away at command lines.

Most of us don't realize how often we use the cd (for "change directory") command from the command line. After a while, I get tired of typing in the same  cd command over and over again - things like

     cd /users/ray/Documents/webpages/blog/

and so I assign it to an alias, a shortcut like this:

     alias blog='cd /users/ray/Documents/webpages/blog/'

Creating an alias like this lets me hit four keys instead of 38 keys.

A tiny tool called autojump lets me do the same thing, but without aliases. Autojump learns which directories I use most often, and then it lets me switch to them quickly, by typing 'j' (for jump) and part of the directory pathname. For example, I can type

     j blog

and autojump takes me to the same directory as that alias does. Autojump is not perfect, but it is very useful to command-line weenies like me.

Where to get them

If screen isn't built into your Linux distribution, you can find it using apt-get or your distro's Software Management tool. It's also available for Cygwin, a Posix-like shell for Windows. Cygwin is one of the first things I install on a new Windows computer.

Likewise, you can get ytree or linuxtree using apt-get or your distro's Software Management too.l. While linuxtree isn't immediately available for Cygwin, ytree is. And if you really want linuxtree in Cygwin, you can download and compile the source code.

You will need to use git to download autojump from github. You will need Python to run the installation utility. Git and Python are available for every Linux distro out there, and for Cygwin as well.