Tag Archives: linux

Using ncdu to examine disk usage

du has been my go-to tool for checking disk usage and it’s wonderfully simple. But I’ve been using ncdu for a few weeks now.

ncdu is short for NCurses Disk Usage. In addition to being able to visualize disk usage by directory, it lets you sort on different parameters, delete files, show hidden files, and a few more stuff that you’ll miss if you go back to plain du. Most importantly it acts as a file manager, so you can simply enter the directories to see a more fine-grained breakdown of file sizes. As an added bonus it has Vim keybindings along with normal arrow key movements.

ncdu - ncurses disk usage

Screenshot of ncdu + help popup


brew install ncdu # macOS
sudo apt-get install ncdu # Ubuntu/debian

Splitting a text file into two

Today I was trying to open a text file with a Node.js script and failed, apparently because it exceeded Node’s maximum buffer size. The most straight-forward solution was to split the file in half and open the two new files separately.

How do you split a text file by two, though? With a quick hack using head and tail of course.

head -n 1000 input-file > output1
tail -n +1001 input-file > output2

The + in the tail command tells it to count lines from the top, instead of from the bottom which is the usual case of tail.

Source: unix.stackexchange

Connecting to mobile broadband from a terminal

In Linux, connecting to internet using a mobile broadband connection (i.e., a dongle) is fairly easy. If your distro has nm-applet installed (like most modern distros do) all you need is to create a new network connection and choose your country and network provider.

But how do you connect with a dongle when you don’t have a GUI? azeemigi’s blog has the solution. I’m reproducing it here just for the sake of my own future reference.

First determine the name of your broadband connection using the command nmcli -p con You will get the list of network interfaces in your computer and among them might be a row corresponding to your dongle. It’s easily distinguishable. In my case it was,

~ » nmcli -p con
                                                   Connection list
NAME                      UUID                                   TYPE         
Wired connection 1        cbd369e1-b2fa-46a6-83b1-fbfdc9d28e0f   802-3-ethernet
Dialog GSM Postpaid       bb06d9f7-772c-4b4b-851a-4564503c3798   gsm       

Obviously it’s the last row.

Now download the following gist and copy/paste the name and the UUID of the connection in the relevant lines.

It goes without saying that you need to make the script executable with chmod +x mbb and add to a location in your $PATH.

Now you can connect to the internet with mbb start, disconnect with mbb stop and check the status with mbb status.

Installing Sinhala Unicode in Crunchbang Linux

Being debian-based, the usual commands can be used to install Sinhala Unicode in Crunchbang Linux. Tested with #! Waldorf.

  1. sudo apt-get install ttf-sinhala-lklug ibus im-switch ibus-m17n m17n-db m17n-contrib
  2. rm -f ~/.xinput.d/* ; im-switch -z all_ALL -s ibus
  3. Logout and login again.
  4. ibus-setup
  5. Choose the Wijesekare layout from the Input Method tab and close

Now you can switch between English and Sinhala using the key combination Ctrl + Space.

Better cp and mv for linux

K. Mandla has blogged about an interesting patch to GNU coreutils. Even if you’ve used Linux only for a few days, you might know how rudimentary the cp and mv commands are. But there’s an unofficial patch that makes them the way they should’ve been.

That’s the way it should be! That’s what I’m after: Transfer rates. File sizes. A proper progress bar and percent complete, with a second readout for overall progress, as needed. 😀

Just follow the instructions on the site to apply the patch and compile coreutils. Then alias the resulting cp and mv binaries to, well, cp and mv. Make sure to add a -g flag to the aliases to get the progress bars.

Activating IRC on Empathy

As it turns out, Empathy doesn’t come with an IRC account support in Ubuntu 12.10. In other words, the new Online Accounts section in Quental lets you connect to Google, Twitter, Jabber and a few other accounts but not IRC. I have no clue what made the packagers take this decision, but it’s a poor move, considering that the plugin only weighs 11.6 kB. Anyway, you can simply install the IRC plugin with the command,

sudo apt-get install account-plugin-irc

There are a few other plugins that do not come pre-installed. You can view them using,

apt-cache search account-plugin

Creating booklets out of PDFs

This friend of mine wanted to print a PDF as a booklet, i.e. with two pages printed in each A4 page so that it can be folded to make an A5 sized booklet. It works as shown in this pic. This requires a software that can rearrange the pages accordingly. I had heard of this tool called Booklet Creator but, even though it’s advertised as free, the free version lets you convert only up to 6 pages. And the license is $20. Ridiculous.

What do you do when you need to find an alternative to a software? Check out AlternativeTo.net of course. It led me to this free and open-source tool called pdfbook that lets you do exactly the same. It works in Linux only though (it may work on Windows but will need some work). Also, the tool has some dependencies which need to be installed. In Linux this is usually not much of a problem thanks to package managers. If you’re on Ubuntu/Debian, the steps to install pdfbook is as follows:

  1. sudo apt-get install texlive-latex-base texlive-latex-recommended
  2. Download the pdfbook tarball from here and extract
  3. Go to the extracted directory and install using make install

Now pdfbook is ready to use. The following command will create a booklet:

./pdfbook -2 original.pdf destination.pdf

CrossOver for Linux is free for today only

CrossOver is a a wine-based platform that lets you install Windows software in Linux and OS X machines. According to OMG!Ubuntu, they are giving away the software for free for today only. Just go to this page, enter your name and email and grab the deb (or the relevant package for your distro). Only a few more hours left (coz today means October 31st in Central Daylight Time).

The Ubuntu Geek article on this reports,

Few days back, CodeWeavers started a campaign ‘Flock the Vote’ announcing that they will release CrossOver for free if 100,000 Americans pledge to vote in the 2012 Presidential elections.
CodeWeavers failed to reach stated goal of 100,000 pledges. However, CEO Jeremy White has now decided to give away CrossOver for free anyway.

This CrossOver package usually costs $59.95.

Everpad hits 2.0

Installed Ubuntu 12.10 yesterday (see the post in the other blog). One of the first things to install in the new OS was Everpad, an Evernote client integrated to Ubuntu and Unity, and found out that it’s been updated to 2.0. Now you can attach pictures and add tables to the notes. Sync issues seem to have reduced as well.

But the best thing is that Everpad is in active development. We badly need a good Evernote client for Linux, something better than NixNote. Everpad is on the move.

Notifications on active monitor [Ubuntu]

Since a few days back I started using a dual monitor system. The terminal stays in the laptop screen; browsing, reading and movies go in the big screen. One hitch was that the OSD notifications appear only in the external monitor. They may go unnoticed if I’m focused on the laptop screen. WebUpd8 has a tip on making this right. Fire up the dconf-editor, go to apps->notifyosd and set the value of multihead-mode to focus-follow.