Why I Love Linux (Through Examples)

This article is not meant to incite a comparative discussion of various operating systems. These are solely my thoughts and experiences.



I feel Linux helps my productivity, and that I'm not equally productive on other operating systems. If you feel otherwise is true for you, then that's great.

I started using Linux three years ago. As newbie as they get, and totally clueless. Now, that hasn't changed much, but since then, I have written some scripts and use trivial everyday one-liners that ease a lot of tedious manual labor.

This article lists some of these scripts and one-liners, which in themselves, hopefully illustrate why I have become dependent on Linux . No attempt is made to explain the examples. For that, I refer you to a book by William Shotts:

Get the Book This free and awesome book is what I wish I had read early on, instead of going by my cursory hack-it-together approach. It covers most of what is used in the examples, but also much more.

Example 1: Downloading Embedded YouTube Videos

What it does:

Downloads the HTML source of a URL, extracts embedded youtube videos, and downloads them one by one at highest resolution using youtube-dl . Script: getyt Demo:

Click to play

Example 2: Monitor files & scripts

What it does:

Monitor a list of files (or command output), and execute a command on change. There are several utilities that cover similar functionality. In particular iwatch and inotifywatch . I might have suffered from a small case of NIH, though I still prefer straight forwardness of watchfile . Script: watchfile Write-up.

Github gist.

Demo:

Click to play

Example 3: Watermaking Images

What it does:

Adds a subtle watermark to an image. Let's you easily customize label position, font (typeface, size, color), background color, and whether or not the label should extend the image. Script: subtlemark Write-up.

Github gist.

Demo:

Input



(Click to enlarge) Output



Example 4a: User/Pass Management

What it does:

Manages passwords in a file owned by root. Allows partial match queries. Script: userpass Github gist.

Demo:

Click to play

Example 4b: Automatic User/Pass Entry

What it does:

Fills username and password fields, in any browser or application. Uses process information to determine best matching username/password pair. Triggered by a global hotkey that asks for sudo rights to read the password list. Script: enterpass Github gist.

Demo:

Click to play

Example 5: Development Setup

What it does:

Creates a bunch of terminals, runs scripts in them and sets up TTY redirections. Demo:

Click to play The script creates terminals with specific sizes and adjusts font size, and placement.

Example 6: Dual Monitor Timelapse Recording

What it does:

Takes a screen capture every N seconds of a dual monitor setup. Converts the inactive monitor into a picture-in-picture thumbnail. Script: recordscreen Write-up.

Github gist.

Demo:



Example 7: Tic/Toc Timer Pair

What it does:

I missed the Matlab / Octave way of timing things with a tic/toc pair... so, I made them. Script: ttic & ttoc Github gist.

Demo:



Example 8: Open video link in VLC

What it does:

Automatically downloads a video url (youtube, vimeo, etc), at highest resolution, and opens the video file with VLC , as quickly as it can. By assigning the script to a global hotkey, it lets you copy a youtube link, hit the global hotkey, wait 3-5 seconds and have the video start in VLC . Full resolution, no ads, low cpu usage, no buffering issues (it just downloads the whole video as fast as possible), easy scrubbing. VLC is better in every regard, and I no longer use the web-browser. Script: vlcopen Github gist. Demo:



Example 9: Creating animated gif screencapture

What it does:

Accepts screen coordinates and generates an optimized gif . Script: gifcapture Github gist. Demo:

All the animated gifs you'll find in this article.

My Background (Before Linux)

I grew up playing computer games in the mid-90s and on. The operating system of choice at that time for games was Windows , hands down. Naturally, it also became my system of choice for everything else.

Later, when attending university, some courses required Linux interaction. This was often simple enough that one could get by with a few terminal commands, editing files with gedit or nano ( emacs and vi seeming completely unusable), compiling with gcc , modifying a simple (and at the time, cryptic) Makefile , etc.

I still stuck to Windows all the way until I studied a year in the US, and took a computer security course that relied heavily on everyone being familiar with Linux . I went for Fedora and spent countless frustrating hours fighting with basic things like getting wifi and graphics drivers to work properly.

After the course ended, I happily switched back to Windows , and relished in the sweet comfort of Visual Studio for C/C++ programming, and notepad++ for everything else.

Fast forward a few years, I decided to give Linux another go in preparation for a software development position that primarily used CentOS machines. This time going for Ubuntu , and, possibly due to the matured Linux driver support in the three years passed since my previous struggles, it was much smoother sailing.

Bereft of Visual Studio, I set out to learn emacs for writing C++ code. SCons for compiling C/C++ projects. I found the bash scripting language repulsive, ugly and unintuitive, but still used it occasionally for small scripts to simplify command line tasks. As time passed, slowly learning new Unix/Linux tools here and there, and gained a better understanding of how Linux works.

The transition was a long journey, riddled with frustration. A few sessions with grub or twiddling with xorg.conf will tempt any sane person to throw in the towel.

In not doing so, every small thing I learned became a piece of an incredibly powerful and versatile toolbox, as most of the Unix tools follow the unix philosophy. As the quote goes:

This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

This is in stark contrast to how it was for me in Windows . Here, almost any task I wanted to solve had to be accomplished by finding a finished software. Monolithic, and specific for solving the task at hand. For example, I recall needing a program for batch renaming files. I searched for such a utility, and found one ( magic file renamer ). Some other time, I needed to batch edit images. I searched again, and found a another tool ( XnView ).