2015/09/10

Changing dash to bash

The default shell for Ubuntu is dash. To change it to bash, the command update-alternatives could be used. The system used to create this tutorial is Ubuntu Studio 14.04.3.

Current Alternatives for ``sh``

Check the current alternatives for sh with the command:

# update-alternatives --config sh
update-alternatives: error: no alternatives for sh

The message showed that there were no alternatives for sh. It bash is already installed as an alternative, jump to Configure the Alternatives.

Install bash as an Alternative

To install bash as an alternative for sh:

# update-alternatives --install /bin/sh sh /bin/bash 100
update-alternatives: using /bin/bash to provide /bin/sh (sh) in auto mode

Where /bin/sh is the symbolic name of the alternative, sh is the alternative name, /bin/bash is the path to bash and 100 is the priority of this alternative.

As there were no alternatives for sh before, just installing bash will make it the default alternative. Just to illustrate the example, to install dash:

sudo update-alternatives --install /bin/sh sh /bin/dash 50
update-alternatives: using /bin/dash to provide /bin/sh (sh) in auto mode

Now, both bash and dash are installed as an alternative for sh. bash is the selected on auto mode, because it has higher priority.

Configure the Alternatives

To manually configure an alternative, use the --config paramater for update-alternatives:

update-alternatives --config sh
There are 2 choices for the alternative sh (providing /bin/sh).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /bin/bash        100       auto mode
  1            /bin/bash        100       manual mode
  2            /bin/dash        50        manual mode

Press enter to keep the current choice[*], or type selection number:

And to change the priority of an alternative, just use the install parameter as described above.

Revision History

Post built on: 2015-09-10 22:29:15
Last modified on: 2015-09-10 22:29:09
First published on: 2015-09-10

Revision Date Description
1.00 2015-09-10 Initial version. Published

Installing CyanogenMod on Moto G XT1033

I have written this tutorial a long time ago, but it was never published. I do not even use a Moto G anymore. This tutorial is here now for historical reasons, but it should work on newer versions of CyanogenMod and maybe (with correct firmware, recovery etc.) with newer versions of Moto G.

I have installed CyanogenMod 11 on a Motorola Moto G XT1033 device. I have followed the instructions of the CyanogenMod page for Moto G.

Everything was fine. But, later, I have tried to install Google Apps, with partial success (partial because it was installed, but the phone was unusable). The problem was that, after each reboot, the message Unfortunately the process com.android.systemui has stopped (or something like that) appeared. Then the GUI would stop, come back then the same message would show up again and again.

The problem turned out to be on CyanogenMod, not on Google Apps as I suspected. I wrote this tutorial because I could install Google Apps and the problem did not appear until I rebooted the device (to write this tutorial) and the problem showed up again.

So, I have installed the nightly build for CyanogenMod 12 (from January 27, 2014) and everything is OK (until now).

WARNING: this will void your warranty according to the device manufacturer.

This guide will show the steps I took to install CyanogenMod and Google Apps on a Moto G. Following the "official" tutorial will work. I am publishing my own tutorial because I thought the official was missing some steps. But, when I realized the problem was with the CyanogenMod build, the tutorial was almost done.

Setting Up the Computer

Android SDK must be installed on a computer. fastboot and adb will be used.

The system used was Slackware. The compressed tarball for standalone SDK tools was downloaded, uncompressed it and set the PATH variable of the system for the tools Android SDK.

Backing Up

Backing up data before doing anything that is somewhat dangerous is always a good idea. The steps of this tutorial will wipe the data on the device. Backup the data!

Starting ADB Server

ADB must have the server running in order to communicate with devices.

# adb start-server

Run this command everytime the server is down, otherwise ADB will not be able to communicate with the device.

Unlocking the Device

In order to install a new firmware, the device must be unlocked. A code is sent to Motorola, then an unlock code is sent back by e-mail. The process is fast.

Getting the phone code

Enable USB debugging on the phone (on developer options). If there is not developer options, go to phone settings -> about phone. Click like ten times or more on Build number field, until a message shows up saying you are now a developer.

Connect the phone with a USB cable and reboot the phone on bootloader:

$ adb reboot bootloader

Then to get the phone code (maybe there is no need to run the command as root, but it did not work as a normal user):

# fastboot oem get_unlock_data

WARNING: this will void your warranty according to the device manufacturer.

Go to Motorola Bootloader Unlock. You must login with either a Motorola ID or with a Google+ account. Enter the code from the last command, agree with the terms of license agreement and the unlock code will be provided by e-mail.

The instructions on how to unlock the phone with the provided code will be on the e-mail too. With the phone on bootloader:

$ fastboot oem unlock unlock_code

The device is now unlocked.

Flashing New Recovery

Download ClockworkMod Recovery.

Connect the USB cable and enable USB debugging.

Reboot the device into bootloader

$ adb reboot bootloader

Then flash the image:

# fastboot flash recovery your_recovery_image.img 

As stated on CyanogenMod page:

Note: Some ROMs overwrite recovery at boot time so if you do not plan to immediately boot into recovery to install CyanogenMod, please be aware that this may overwrite your custom recovery with the stock one.

Installing CyanogenMod and Google Apps

Download CyanogenMod zip and Google Apps zip.

Enable the USB debugging and:

$ adb reboot recovery

It was not possible to create a backup of the current system. It was giving errors.

To wipe the current install, select wipe data/factory reset on device's recovery menu.

Then send the CyanogenMod zip and Google Apps zip with the following commands:

$ adb push cyanogen_img.zip /sdcard/
$ adb push google_apps.zip /sdcard/

Then select install zip/choose zip from sdcard. Install Cyanogen Mod and Google Apps.

The Problem

Rebooting the equipment was causing the problem stated at the begining. Formatting the /data and /cache partitions solved the problem. Options to format it are under mounts and storage at the recovery main menu.

Final Considerations

If anything is wrong, try those steps again.

If you can boot the equipment on bootloader, or the system hangs, the situation is not irreversible.

To force device reboot, press Vol Down and Power for ten seconds, then release.

To open the bootloader, turn off the device and power it up pressing Vol Down and Power.

Revision History

Post built on: 2015-09-10 22:36:55
Last modified on: 2015-09-10 22:36:49
First published on: 2015-09-10

Revision Date Description
1.00 2015-01-27 Initial version.
1.01 2015-09-10 Minor Corrections. Published.
1.02 2015-09-10 Adding correct code tags.