• Ubuntu: Restore / Refresh Gnome settings

    Spent some time doing “cool experiments” with your Gnome environment? Icons cannot be changed anymore, fonts are not appearing as they should, windows graphic has become messy… Well think it’s good time to remove all those “messy changes” and start from the scratch with a default Gnome environment.

    To find out what is wrong because you don’t want to restore all the settings is something that may need A LOT of time, so I will explain three methods to restore Gnome defaults, one way to start investigating the source of the issues and one way to avoid issues like this to happen.

    Restore Gnome Settings (Method #1)
    – Open a terminal by hitting CTRL + ALT + F1
    – login to your account, and run the following command:
    sudo service gdm stop

    – If you are using an old version of Ubuntu, the previous command will not work and you’ll have to use:
    sudo /etc/init.d/gdm stop

    – Then you can run the following commands:
    mv .gnome .gnome_old
    mv .gnome2 .gnome2_old
    mv .gconf .gconf_old
    mv .gconfd .gconf_old
    mv .metacity .metacity_old

    – Again, for recent Ubuntu version (like Maverick or Intrepid) run:
    sudo service gdm start

    – For older versions run:
    sudo /etc/init.d/gdm start

    Restore Gnome Settings (Method #2)

    – Open a terminal by hitting CTRL + ALT + F1
    – login to your account, and run the following commands:
    mv .gnome .gnome_old
    mv .gnome2 .gnome2_old
    mv .gconf .gconf_old
    mv .gconfd .gconf_old
    mv .metacity .metacity_old
    – Get back to your GUI desktop by hitting CTRL + ALT + F7

    Restore Gnome Settings (Method #3)
    When you run an Ubuntu system it’s probably a good idea to use Ubuntu Tweak. If you launch it and choose the section called “Desktop”, you will be able to select the category “Desktop”. You will then notice the buttons at the bottom right called “Recover”, “Reset” and ” Backup”. The option “Reset” will automatically restore Gnome’s default settings. The difference between this function and our manual methods is that this tool will DELETE your settings while we just save them with a different name. Bear in mind that it’s always good to know how to fix things manually (especially when Gnome is badly damaged and you don’t have an environment where you can easily work on.

    Investigate what went wrong

    Now that your graphic environment is working at its defaults, you can start investigating what wasn’t working properly. Please note that as we’ve previously renamed the original folders by appending a “_old” to all of them, therefore we haven’t removed all your settings. This means that the problem you want to identify is inside one (or more) of those renamed folders.

    So if now we switch back to the terminal with CTRL + ALT + F1, login into the system, we’ll be able to see that all those folders have been recreated using the Gnome defaults. This means that now we can rename one of those folders and give back the original name to the non working one :

    For example let’s say that we will rename “.gnome”:
    mv .gnome .gnome_new
    mv .gnome_old .gnome

    By running those two command we’ve saved some of Gnome defaults into .gnome_new and restore some of the non working ones. Go back to your GUI with CTRL + ALT + F7. Is Gnome broken again? You’ve found the folder that contains the issue… Is Gnome working fine? This means that the issue will probably be inside another folder but now we know how to proceed.

    How to prevent this kind of issues
    As we’ve already seen in the Method #3 to restore Gnome’s defaults, you can use Ubuntu Tweak and its “Reset” function. However we have the “Recover” and ” Backup” one. The last one takes a snapshot of the current settings, that can be later restored by clicking on “Recover”.
    Yes, you’re right, you can take different snapshots of your settings and then go back to the one you want. To be honest, you can do it manually by copying your .gnome, .gnome2, .metacity, etc, folders somewhere easy for restoring them in case something is going wrong, but this tool works very well taking the snapshots and restoring them. I’ve tested by taking various snapshots and changing different settings between one snapshot and the other and the tool was always able to restore the right data in the right way.

    This has been a long article, but I hope it will be useful to you as I’ve seen this kind of issues on different machines. Please remember that Gnome settings are a per-user-settings so you can alway log into the system as another user or using the Rescue CD to rename/remove the offending folders.

  • How to properly restart a frozen Linux: SysRq

    I know that Linux works very well on your machine, but when your work is to provide support you’ll probably see some frozen Linux…

    The biggest problem is when a frozen, full screen X application took control over your mouse and keyboard and it seems that the only way to regain access to the system is to force a shutdown.

    This is obviously not an optimal way to get around the problem, as you may suffer serious data loss.

    The first thing to try is to kill just the frozen application. There are normally six text consoles sessions available and one graphics session.
    You can access the consoles by pressing CTRL + ALT + Fx (where Fx is a function key on the keyboard from F1 to F6).
    Once you enter one console, you will be prompted for user name and password. Enter them and then you’ll reach a command prompt.
    Now you can kill the offending process using the kill command.
    To switch back to the graphic session, just click CTRL + ALT + F7.

    If for some reason you cannot access any of the consoles or you simply cannot control the pc anymore, you should try as last resort to perform a “safe reboot” of your OS.

    Since linux kernel 2.1.43 the feature CONFIG_MAGIC_SYSRQ has been added. When the kernel is compiled with this option enabled, it will be able to understand some low level commands that will work most of the times even if you have unresponsive applications that are freezing your machine.
    To send a low level command you must press ALT + SysRq + Command (where “Command” is one of the commands listed at: http://lxr.linux.no/linux/Documentation/sysrq.txt).

    The SysRq/Print Screen key

    To actually reboot the machine there is a well know key sequence to follow: REISUB (or REISUO if you want to turn off the pc instead of reboot).
    Basically, if you keep pressed ALT + SysRq + R and then while you keep pressed ALT + SysRq you press E, I, S, U, B.
    Here you can see an explanation of each one of those commands:

    R: Switch the keyboard from RAW to XLATE mode (take back the control of the keyboard)
    E: Send the SIGTERM signal to all processes except init
    I: Send the SIGKILL signal to all processes except init
    S: Sync all mounted filesystems (this will help avoiding loss of data)
    U: Remount all mounted filesystems in read-only mode
    B: Immediately reboot the system, without unmounting partitions or syncing

    Sometimes the first command “R” doesn’t work at the first time so you’ll have to press it a few times. And it happened once to me that the REISUB didn’t work until I went to a console (as described before, using the CTRL + ALT + Fx combination).

    Hopefully this information will help you!

  • How to share the internet connection of your Ubuntu with your old Palm using Bluetooth

    Since Bluez utilities have been updated to the version 4.x I’ve found quite complicated to share the internet connection of my linux box (actually an Ubuntu 10.04 – Lucid Lynx) with my Palm Centro.

    So I’ve investigated the issue a bit and this is how I get it working:

    1. pair the phone and the pc using the standard bluetooth interface (on the taskbar)
    2. sudo apt-get install bluez-compat
    3. gksudo gedit /etc/sysctl.conf
    4. Uncomment the line “net.ipv4.conf.default.forwarding=1”
    5. sudo sysctl -p
    6. gksudo gedit /etc/ppp/peers/dun
    7. paste inside the file (and adapt it to your network configuration):
    115200

    # IP address of PC : IP address to be assigned to Palm
    192.168.2.1:192.168.2.2

    local

    # put your DNS server IP down here:
    ms-dns 192.168.0.1

    noauth

    debug
    8. sudo /usr/bin/dund --listen --persist --msdun call dun --nodetach
    9. launch the connection from your phone, it worked for me… Good luck!