Self reminder: setting the default boot option in UEFI

Bought a new laptop (*) and I’m 100% sure I’ll forget this if I don’t put it here:

From http://askubuntu.com/questions/291905/how-can-i-make-ubuntu-the-default-boot-option-on-a-newer-laptop-uefi

To set Ubuntu as the default boot OS in a multi-OS setup (ie, dual boot Windows) with UEFI, goto Windows and exec (as admin) bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

Why am I using Windows, you may ask? I’m still in the process of discovering which features will be broken and which hardware will work out of the box. So far I’m actually quite surprised, with only the video card and the touchpad not working. Luckily bash doesn’t use either of those. Who needs a mouse anyway?


Deobfuscate your bash

Who hasn’t written some read-only magical Bash voodoo, only to find you need to decrypt your own creation later on? Luckily, Explain Shell can help with that. Here’s an example from my .bash_history file:


for fn in *; do echo cat $fn | sed “s|’ ‘$URL’||g” | sed “s|curl -X POST -d ‘||g” ; done

And Explain Shell’s explanation: it’s no substitute for knowing Bash but it sure helps.

Bonus: while reading my bash history file, I realized I accidentally copy&paste a lot of code to my terminals. There are way too many “template <FOO>” entries in there…

Bonus II: It’s a good thing they wrote “shell” in a different color. I was wondering why I had “explains hell” in my bookmarks.


Awesome (and useless) trivia: Ubuntu’s first bug

I’m still not over the disappointment from my latest Ubuntu install but recently I found a bug which is quite remarkable: https://bugs.launchpad.net/ubuntu/+bug/1

Yes, Ubuntu’s #1 bug, reported by Shuttleworth himself, is “Microsoft too big”. I’m not too sure I agree with the bug’s resolution.


KSnapshot is getting smarter

I just noticed KSnapshot is smart. Too smart. If you save a snapshot to a folder with a bunch of files like “Snapshot_N_foo” it’ll name the next one “Snapshot_N+1_foo”. That already makes my computer smarter than some humans!


Quickly sharing files in Linux via HTTP

Isn’t it awful when you have to share a file too big for email and don’t know how? You’d think by 2016 we’d have that figured out. Actually we do, many times over. Just pick a standard that works for you!

If you don’t want to read many pages on file transfer standards (Samba? What’s that?) you can try this little snippet:

python -m SimpleHTTPServer $PORT

This will create an http server sharing the current directory. HTTP, luckily, is one of those things that tend to work everywhere, always.

Bonus: some other ways of doing the same thing at https://gist.github.com/willurd/5720255


Ubuntu 15.10: Ubuntu ME

Warning: semi-useless rant ahead. TL;DR: Avoid Ubuntu 15.10 – it’s the closest Linux has ever been to Windows ME.

I have been using Ubuntu for a while now. From the time when Canonical actually mailed real, physical CDs of the distro. So get of my lawn.

In all of my Linux years I have never, ever, had such a horrible installation experience as I did this weekend with Ubuntu 15.10. I may go as far as saying not even Windows ME was this horrible to install. I hit dozens of critical show-stopper bugs, from poor UEFI support to an installer that crashed when clicking “Go back”. And that’s only the installation, don’t get me started on the new KDE Plasma 5 desktop… (hint: my big desktop screen is NOT a phone. Swiping to login? Bad idea for a mouse).

A few hints for any other poor souls that made the fatal mistake of installing Ubuntu ME:

  • UEFI? Say no. Get a different computer if you can. Try to set it in legacy mode if you can not.
  • Try not to repartition and install Ubuntu on the same go. Even more so if you have UEFI. First install, then rearrange partitions with a live cd.
  • If you get a few (or a few dozen) “system crash notifications” when starting up your GUI, check /var/crash. Delete everything from there.
  • If you want Kubuntu, don’t install Ubuntu and then apt-get install kubuntu-desktop. That’s broken. If you want Kubuntu just get its install image.
  • Don’t install Kubuntu. Really, it’s horrible and it crashes. (You though I called 15.10 Ubuntu ME for no reason?)
  • Don’t like Gnome? XFCE is usable and can be configured to look more or less like a sane version of KDE. It still crashes but at least it’s quick to boot.
  • If you get a disk check on every startup just disable it on fstab. No, it’s not nice. I haven’t found any other workarounds yet.

I have no idea when has Ubuntu gone so horribly bad, but I’m not looking forward to installing any Ubuntu distro anytime soon. I wonder what Slackware looks like these days.

2016? Still not the year of the Linux desktop.

Update: XFCE is great… except it doesn’t really support moving the mouse.  Seems Ubuntu is having a nostalgic release and decided to introduce old bugs from 2012!

 


Public service announcement: searching your terminal’s output

Short tip today, but a life-changer one: you don’t need to copy&paste your terminal’s scrollback to search on it, you can do it in place. At least in terminator that’s possible (and I hear it’s also doable in Gnome’s default terminal application). Just press Ctrl+Shift+F. No more copy and pasting to vim!


Bash tip: idiom to get the first error code from a pipe

When writing a bash script, often times you’ll end up with something like this:

real_command | filter_stuff | prettify | do_something_else

The problem arises when you try to figure out if your command succeeded or not. If you `echo $?` you’ll get the return code for the last chain in the pipe. You don’t really care about the output value of do_something_else, do you?

I haven’t found a solution I really like to this problem, but this idiom is handy:

out=`real_command` && echo $out | filter_stuff | prettify | do_something_else

echo $?

Now $? will hold the value of real_command, and you can actually use it to diagnose the real problem.


smaps: A quick memory analysis

Many times you see your process’ memory consumption skyrocketing even though you’re quite certain you have no memory leaks. This usually marks for the beginning of a very lengthy debugging process with valgrind or a similar tool, but even so some times you might get stuck trying to debug some third party library.

There’s a quick tip in Linux that can help you track down a lib gone haywire:

cat /proc/<pid>/smaps

smaps will report every mapped section of memory for a certain process, how big the memory allocation is and which binary created the allocation.


KDE: Lock screen from CLI

For some reason, one of my (seriously outdated) Kubuntu installations has the nasty habit of not locking the screen when pressing Ctrl+Alt+L. Not always, though. It seems to do this only when I’m in a hurry and need to quickly lock my PC before walking away. This happens often enough to be annoying, but not so frequently as to bother me enough to look for a proper solution.

Instead of looking for a proper solution, trying to determine what’s stealing the focus of the Ctrl+Alt+L key command, I just settled for an easier workaround: lock the screen from the command line. I use the terminal most of the time anyway, so why not just use it to lock the screen as well?

The magic incantation is easy, if a bit cryptic at first:

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock

“qdbus” is a broadcasting service for KDE (Qt, actually). This command basically tells the screen saver service to lock the screen. Works every time, and with an alias in my bashrc, I don’t need to remember that horribly long command. Now I only need to determine if my computer detecting when I’m in a hurry is a sign of sentience, and whether this is a threat to mankind. Will report soon.