Nicolás Brailovsky


A modern blog

Archive for the ‘Linux’ Category

Fixing end of line styles between Linux and Windows with SVN

author Posted by: nico on date Dec 13th, 2011 | filed Filed under: Linux, Programming

Quite a mouthful for such an easy thing. Don’t you just hate when half the people in a project use CR/LF and the other half just LF?

Luckly this is easy to fix, assuming you are using svn. You can use something called auto-props to setup the eol style for different file types.

Set it once for the project, never worry again. Anyone knows its git counterpart?

New Buguntu, new GUI, new problems

author Posted by: nico on date Nov 1st, 2011 | filed Filed under: Linux

I updated Ubuntu to 11.10 in one of three computers I regularely use. Lot’s of problems and very little improvements. Granted, sound now works by default (finally) but dual screen suport is still less than what I would expect from Windows 98. On top of that, the biggest change is the GUi.

WTF! My computer is not a tablet, give me back my menu. While using my phone it’s nice to have only a couple of icons to click. With two big monitors, I miss my launch bar, a propper clock, my custom applets and the applications menu… everything that makes the GUI usable.

Luckly Ubuntu provides a way to revert to the “classic” desktop, you just need to apt-get install gnome-session-fallback (WTF? I need to INSTALL it? If you plan to roll out a new experimental GUI, at least let me opt-out without downloading more stuff). Of course, since now Ubuntu comes with Gnome 3 even more fun ensues.

Did you plan to customize your toolbars? Well, good luck with that. Apparently now the applets that work for the old Gnome won’t work for Gnome 3. Yes, they implemented a new cool applet system, whatever, I just want a port of the old ones I had.

Oh, if you plan to move things around you’ll have to do some research first. See that hideous clock up there, in the top bar? How would you get it to the lower-right corner? Why, hold alt and then right click to see the move menu. Super intuitive. I wonder if they inspired themselves on ribbon.

I don’t understand the tablet-interface-ftw fad, I was happy with my console multiplexer and I want to keep it unobtrusive, as gnome 2 was. Time to switch to XFCE?

Annoying “unable to find a medium containing a live file system” in Ubuntu

author Posted by: nico on date Oct 27th, 2011 | filed Filed under: Linux

Sometimes you may get this message when installing Ubuntu. And it’s not very helpful, the install just dies.

Assuming you created the installer appropriately (usb, live cd, whatever), once you reached that message it means that the BIOS already recognized your device as bootable, loaded the bootloader and started executing it. So it’s the bootloader that can’t find the image, yet that doesn’t make sense if you think about it carefully: if the installer was properly created, that shouldn’t happen.

Well, after fighting for a while I realized that some DVD drives connected to a high speed SATA port  will give this kind of message error. From the message it’s not very clear what causes it, so you can try with one of the crazy kernel options like noapic. If that doesn’t work, you can try to change the SATA mode in the BIOS. ACHI worked for me.

http://www.makarras.org/2008/06/17/gandalf/

Passwordless ssh

author Posted by: nico on date Oct 25th, 2011 | filed Filed under: Linux

This is one of those things that are terribly easy nowadays, but since I only do it every once in a while I never remember how it’s done: setting up a passwordless ssh. I won’t write any explanation, just the command to set it up so I can keep it as reference for the next time I have to do it:

  1.  
  2. ssh-keygen -t rsa && ssh-copy-id USR@HOST
  3.  

You might also want to specify that HOST requires USR, instead of $(whoami), so you won’t have to type ssh USR@HOST next time you want a passwordless loggin. This can be done in /etc/ssh/ssh_config, like this:

  1.  
  2. Host $HOST
  3.         User $USER
  4.  

Replace as needed.

Dell and Ubuntu CPU Scaling

author Posted by: nico on date Oct 20th, 2011 | filed Filed under: Grumpy, Linux
Hi, my name is Nicolás Brailovsky and you may remember me from movies like fixing keyboard problems in Ubuntu JJ, removing the annoying terminal warning, random complaints about dual screen in Buguntu and Ubuntu: sound still fubard. This time, I would like to add a new Ubuntu problem to the list of things which make me want to jump off a cliff, though I must warn you that this is a very old article that got forgotten on the stack of posts to review, so it might be dated. Being an old post means that this problem may be fixed by now, but since I don’t have a Dell laptop anymore I cannot try it. Anyway, I’ll post it as a reference to anyone who may experience something similar.

To be completely fair, this is a dual fuckup between Dell and Ubuntu: after an upgrade I started noticing that sometimes the CPU slows to a crawl, for no apparent reason. The only fix for this is a complete shutdown, as not even a reboot would make this problem go away. WTF?

A lot of time after I had given up on trying to solve this problem and decided that submitting to the gods seemingly random will was the best option, a coworker told me what this was about: apparently when you have a 3D GUI (say, a screensaver) and a double monitor the graphics card has to “work too much”, drawing too much power. When the power consumption reaches 90 watts, the power supply’s limit, the CPU enables something called CPU scaling, bringing the CPU clock speed to about the speed of a wristwatch. (No, really: “Even setting aside the negative performance effect of FSB downshifting in II above, the effective processing power is reduced to 1/8 of 798 Mhz = 100 MHz. This is a reduction to less than 5% of full capacity, from http://www.sigmirror.com/files/44490_iweoz/throttlegate.pdf).

Solution? None, thanks. Just shut it down and reboot.

Starting Ubuntu in console mode

author Posted by: nico on date Oct 13th, 2011 | filed Filed under: Console, Gnome, Linux

Like it or not, Ubuntu is so easy to install that even for servers is very comfortable to just mount the iso and create as many virtual machines as you may need. Sometimes you already have an iso for Ubuntu, but are too lazy to download the server version. For those occasions you can either decide to waste precious RAM running a GUI for a server that will never need it, or you can remove all traces of the graphical login. Like this:

  1. sudo update-rc.d -f gdm remove

This will remove GDM from the startup scripts, meaning you can still fire up the graphical interface (*) if you want, but it will start Ubuntu without loading any graphics stuff. This is very useful to save on RAM, startup time and processing power, which even if not that useful for a desktop machine is incredible beneficial when you have several virtual machines running in a single physical server.

(*) More precisely, if you have users that need it. Remember though, if it can’t be done in console mode, it ain’t worth doing.

http://www.makarras.org/2008/06/17/gandalf/

DIY gnome applets

author Posted by: nico on date Sep 29th, 2011 | filed Filed under: Gnome

We all know Gnome, and similar GUIs, are there only as a fancy console multiplexer, but even so it’s useful to have widgets in your menus or dockbars to display useful data, like the release date of DNF (*). Gnome has a limited amount of applets from which you can choose, and most of them are crap or limited in their customization. You can always create your own widgets, but that’s a pain in the ass for lazy people like me. Fortunately we lazy people can now use something an order of magnitude more useful than widgets in Gnome : we can use console commands!

Using something called Compa you can add a meta-widget, that will display the output of any CLI program. This means, of course, that you have all the power of the console to use in your custom made widgets. Need to check your laptop’s battery? No need to search for a widget anymore, just cat /proc/acpi/battery/BAT0/state. Need to check the weather? Just wget your favorite forecast page and parse it with grep, sed an awk. OK, maybe that’s a little bit too much.

Once more this proves that anything can be done in console mode – and whatever you can’t isn’t worth doing anyway.

(*) Wow, this article has been written a LONG time ago!

Running commands on Windows from Linux, through ssh

author Posted by: nico on date Sep 22nd, 2011 | filed Filed under: Console

Running Windows is something I don’t usually like (running of Windows is a different story) but having to run something on Windows command line interface is something I wouldn’t wish even to my worst enemies. I was stuck in that situation, don’t remember why, but I needed to run a command in a Windows machine, automatically, and I only had ssh (is there a better way of automating scripted tasks in Windows, remotely and without a GUI?). Well, this is what I came up with:

  1. ssh host cmd /c dir

Running that in a bash shell will show the directory listing of C: in machine “host”. Ugly as hell, but it’s a good way of kickstarting a batch script.

Zero padding for Bash scripts

author Posted by: nico on date Sep 15th, 2011 | filed Filed under: Console

Lately I found myself trying to generate a video from a series of images generated by a program. Doesn’t sound difficult, until you start running into a stupid issue: your 1000th frame will come before your 2nd frame!

Luckily there’s a very easy fix for this problem, just add zero padding in a bash script. How?

  1. for i in `seq 1 10`; do echo $i; done

That will print all the numbers between 1 and 10. This one will do the same, with zero padding:

  1. for i in `seq 1 10`; do printf "%02d\n" $i; done

Activating tildes and accents for a USA keyboard layout in Ubuntu

author Posted by: nico on date Sep 8th, 2011 | filed Filed under: Gnome

Wow. This time the title of the post may actually be longer than its contents. How do you enable accents and tildes in Ubuntu? You need it to type cool characters like á, Ó or ñ (hey, my name has one of these!).

If you are on Windows I think you have to install a new map, and then guess where the key would be. Or use an alt+something magic spell. In Ubuntu, it works by default you just need to add a compose key, Go to System > Preferences > Keyboard > Options > compose key position, select right alt (or whatever you fancy), there you go, now it works. Try it by typing alt + ‘ + a.