Wednesday, September 29, 2010

Ubuntu running in low-graphic mode

Solution 1:
Reconfigure xserver xorg, with the command
sudo dpkg-reconfigure xserver-xorg
Solution 2: (Try only if you know what you are doing)

  • Take a backup of xorg.conf file:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_bkp
  • Open the xorg.conf file for editing:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf_bkp
  • Delete this Section Device:
Section “Device”
Identifier     “Device0″
Driver         “nvidia”
VendorName     “NVIDIA Corporation”
BoardName      “GeForce 8400M GS”
EndSection
  • Edit the Section Screen as:
Section “Screen”
Identifier     “Screen0″
Device         “Device0″
Monitor        “Monitor0″
DefaultDepth    24
SubSection     “Display”
Depth       24
Modes “1440×990″
EndSubSection
EndSection

Sunday, September 19, 2010

Installing hamachi VPN in Ubuntu as a service

Hamachi is a free vpn service, useful to create a private LAN over the internet. For more details of hamachi, go to www.hamachi.cc

The following covers installing hamachi in Ubuntu as a service.

  • We start with installing the 'tun' module to enable IP tunneling in linux
sudo modprob tun
(If that gives an error tun module failed try installing faketun as given in the blog post Installing faketun)
  • Open the modules file and add ‘tun’ to the list
sudo nano /etc/modules
Your file should look similar to the example below.
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
lp
rtc
tun
(Incase 'tun' is not on that file, write 'tun' in a new line)
  • Save the file and exit out of nano (Ctrl-O to save & Ctrl-X to exit), lets move on and verify that a tunneling node has been created. (*If you have compiled your own kernel you likely need to recompile it with IP Tunneling support if you receive an error with modprobe. This is not covered in this guide. And if you are unsure, you most likely did not compile yourself and you would definitely remember doing so.)
ls /dev/net/tun
You should recieve a response like the example below
/dev/net/tun
  • If you received something along the lines of “No Such File or Directory” you may need to manually create the node (run the commands below).  If you received the response (/dev/net/tun), jump to the next step.
sudo mkdir /dev/net
sudo mknod /dev/net/tun c 10 200
Run ls /dev/net/tun again and you should now receive the correct response.
  • With our IP Tunnel node created, it is time to install Hamachi itself.  First download the latest version.  As of writing this guide, the latest version is 0.9.9.9-20
wget http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
Expected output below
--2010-09-19 18:40:55--  http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
Resolving files.hamachi.cc... 74.201.74.16
Connecting to files.hamachi.cc|74.201.74.16|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 344866 (337K) [text/plain]
Saving to: `hamachi-0.9.9.9-20-lnx.tar.gz'
100%[======================================>] 3,44,866    --.-K/s   in 0.002s  
2010-09-19 18:41:19 (149 MB/s) - `hamachi-0.9.9.9-20-lnx.tar.gz' saved [344866/344866]
  • Extract our newly downloaded archive
tar zxvf hamachi-0.9.9.9-20-lnx.tar.gz
Expected output below
hamachi-0.9.9.9-20-lnx/
hamachi-0.9.9.9-20-lnx/Makefile
hamachi-0.9.9.9-20-lnx/LICENSE
hamachi-0.9.9.9-20-lnx/README
hamachi-0.9.9.9-20-lnx/LICENSE.tuncfg
hamachi-0.9.9.9-20-lnx/LICENSE.openssh
hamachi-0.9.9.9-20-lnx/LICENSE.openssl
hamachi-0.9.9.9-20-lnx/hamachi
hamachi-0.9.9.9-20-lnx/tuncfg/
hamachi-0.9.9.9-20-lnx/tuncfg/Makefile
hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg.c
hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg
hamachi-0.9.9.9-20-lnx/CHANGES
  • Navigate into the extracted directory
cd hamachi-0.9.9.9-20-lnx/
  • Start the installation
sudo make install
Expected output below
Copying hamachi into /usr/bin ..
Creating hamachi-init symlink ..
Compiling tuncfg ..
Copying tuncfg into /sbin ..
Hamachi is installed. See README for what to do next.
  • Run the tunnel
sudo tuncfg
This should complete the install, we will now configure the user permission in order for it to run correctly.  Create a ‘hamachi’ user group
sudo groupadd hamachi
Add youself as a user to the ‘hamachi’ group.  Be sure to replace your user name where appropriate.
sudo gpasswd -a YOURUSERNAME hamachi
Add the root user to the ‘hamachi’ group
sudo gpasswd -a root hamachi
Set the correct permissions for the tuncfg socket
sudo chmod 760 /var/run/tuncfg.sock
Change the ownership of the socket file
sudo chgrp hamachi /var/run/tuncfg.sock
That should do it for the permissions, Now onto setting Hamachi up & configuring it to start as a system service.
sudo hamachi-init -c /etc/hamachi
Expected output
Initializing Hamachi configuration (/etc/hamachi). Please wait ..
   generating 2048-bit RSA keypair .. ok
   making /etc/hamachi directory .. ok
   saving /etc/hamachi/client.pub .. ok
   saving /etc/hamachi/client.pri .. ok
   saving /etc/hamachi/state .. ok
 Authentication information has been created. Hamachi can now be started with
'hamachi start' command and then brought online with 'hamachi login'.
Start hamachi
sudo hamachi -c /etc/hamachi start
Expected output
Starting Hamachi hamachi-lnx-0.9.9.9-20 .. ok
Set your computer’s nickname
sudo hamachi -c /etc/hamachi set-nick "COMPUTERNICKNAME"
Login to the Hamachi network
sudo hamachi -c /etc/hamachi login
To join an existing network (optional)  “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password
sudo hamachi -c /etc/hamachi join NETWORKNAME PASSKEY
To create a new network (optional) “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password
sudo hamachi -c /etc/hamachi create NETWORKNAME PASSKEY
If you joined an existing network you must tell hamachi to then “go-online”. Be sure to replace NETWORKNAME with your relevant network name.
sudo hamachi -c /etc/hamachi go-online NETWORKNAME
Check your hamachi status to verify everything is as it should be
sudo hamachi -c /etc/hamachi
Expected output

Hamachi, a zero-config virtual private networking utility, ver 0.9.9.9-20

  version  : hamachi-lnx-0.9.9.9-20
  pid      : 5754
  status   : logged in
  nickname : NICKNAME(assigned nickname)

  • Now to configure to startup and login automatically when the computer starts:
  • Create the startup script file:
sudo touch /etc/init.d/hamachi
(Else you can download the file directly from here. Place it in the /etc/init.d folder.)

  • Open the startup script file for editing (Incase you have downloaded the file and placed in the /etc/init.d folder, you need not do this step)
sudo nano /etc/init.d/hamachi
Paste the following contents in the file:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          hamachi
# Required-Start:    $remote_fs $syslog $network
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start hamachi at boot time
# Description:       Starts up hamachi daemon. Networking is required.
### END INIT INFO

hamachi_start() {
  echo "Starting hamachi..."
  /sbin/tuncfg
  /usr/bin/hamachi -c /etc/hamachi start
  /bin/chmod 760 /var/run/tuncfg.sock
  /bin/chgrp hamachi /var/run/tuncfg.sock
}

hamachi_stop() {
  echo "Stopping hamachi..."
  killall tuncfg
  /usr/bin/hamachi -c /etc/hamachi stop
}

hamachi_restart() {
  hamachi_stop
  sleep 1
  hamachi_start
}

case "$1" in
'start')
  hamachi_start
  ;;
'stop')
  hamachi_stop
  ;;
'restart')
  hamachi_restart
  ;;
*)
  hamachi_start
esac
Save the file Ctrl+O and exit nano Ctrl+X

  • Make the file executable and configure it to run it at startup:
sudo chmod +x /etc/init.d/hamachi
sudo update-rc.d hamachi defaults
 Expected output
 Adding system startup for /etc/init.d/hamachi ...
   /etc/rc0.d/K20hamachi -> ../init.d/hamachi
   /etc/rc1.d/K20hamachi -> ../init.d/hamachi
   /etc/rc6.d/K20hamachi -> ../init.d/hamachi
   /etc/rc2.d/S20hamachi -> ../init.d/hamachi
   /etc/rc3.d/S20hamachi -> ../init.d/hamachi
   /etc/rc4.d/S20hamachi -> ../init.d/hamachi
   /etc/rc5.d/S20hamachi -> ../init.d/hamachi

Tuesday, September 14, 2010

Tweaking the Login Screen in Ubuntu

Ever thought of making the default Ubuntu login screen behave the way you want?


  • Probably you are the only user (and you do not fear someone else prying in your PC/laptop) and you feel entering the password everytime a nuisance! You would want Ubuntu to log in automatically for you.
  • Or there might be other users (like an admin and a standard user), and you may want the login screen to be visible for 10 seconds (in case you want to login as admin user) and on no response for 10 seconds (or any time you choose) log in to the standard user automatically.
  • Else, you like the old secure linux way to ask you to choose the user and enter password everytime.


There may be other things you like;
  • Like playing a sound when you log in.
  • Select the session (Gnome/Kde/xfce etc) as default
Either ways, you have your pick.
Simply go to System>Administration>Login Screen and you would find all the options to tweak the login the way you like.

Note: You will need to be logged in as admin user and enter the admin password again to Unlock the Login Screen menu.

Saturday, September 4, 2010

initramfs update error

Duringa ubuntu linux system update an initramfs error sometimes come up:


update-initramfs: Generating /boot/initrd.img-x.x.x.x-generic
.: 4: Can't open /scripts/functions

Often this results in broken update, and many other issues.
If the system is unable to boot to the new updated kernel, select the older version from the boot menu and try updating initramfs again.

Then try the following:

1, Delete only broken files in /var/lib/initramfs-tools/. (Be careful, delete onlt if you are sure of what you are doing, else you may try the other steps skipping this.)
2, sudo dpkg --configure -a
3, sudo dpkg --configure initramfs-tools (make sure no errors, otherwise repeat step 1 & 2).
4, sudo update-initramfs -u (Maybe not neccessary).