Tuesday, July 27, 2010

Set up Wireless Internet Connection Sharing(using Wifi) in Linux (Ubuntu) between any computers

Okay, imagine you only have a network cable plugged in your desktop PC (which we'll call "eth0") and a wireless card too (which we'll call "wireless0"). Now suppose you have your laptop (or any other computer) and you have no way to connect it to the internet - but wait! you have a wireless in your desktop PC and your laptop does too, so what we're gonna do is to share your internet connection for your laptop through your wireless card. Come aboard!

Remember, your machine may vary so be sure to use the commands shown in the "The basics" section right below.

Note: this guide has been tested for sharing connection between :

Ubuntu Feisty Fawn (7.04)

and

Windows XP Professional

Please add successfull configurations

ICS2.jpeg

Note: This diagram was created with inkscape. If you want to edit it download the full file ics.svg from: More Actions->Attachments

The Basics

For getting your wireless card info, open a terminal and use these commands:

lsusb     (lists all the connected USB devices) iwconfig  (lists all the detected wireless hardware) iwlist    (allows you to scan the wireless networks around you) ifconfig  (lists all the detected network hardware. You can get some info for your wireless here too)

Packages

  • You also need Firestarter, which is just a GTK frontend for the iptables and will allow your internet connection to be shared. You can use Add/Remove Applications or the Synaptic package manager to get it (search for firestarter) or just issue a command in any open terminal window:

sudo apt-get install firestarter

Configuring the SERVER

Here we'll configure who is going to share the Internet connection (our desktop PC with the two cards installed). First, we need to have some concepts and rules in mind:

  1. Computers must be in the same subnet (see below for explanations)
  2. You might not be able to use the Gnome Network Manager (and/or maybe KDE WiFi Manager) using this method.

  3. The Server's wireless0 has to be in a range of 192.168.x.2 and 192.168.x.24. Why? our computer is usually using 192.168.0.1 unless you're on a big network, 192.168.0.0 can't be used for it and ranges higher than 24 in the last number are only allowed for Wireless networking,(1.reference please) or so I've read.

  4. Your wireless card must have the lowest IP possible,(2.reference please) that's why we're using 192.168.0.2 because it's closest to 1 and 0 which are in use and we can't use it, so 2 is free. Client computers ALWAYS MUST have greater IP addresses than the chosen one for the wireless adapter (3.reference please)(or the one sharing the internet).

If you haven't yet, it's time to stop the Network Manager:

sudo /etc/dbus-1/event.d/25NetworkManager stop

Once stopped, we shall proceed to edit our /etc/network/interfaces file.

sudo gedit /etc/network/interfaces

Network Interfaces configuration -IMPORTANT-

Your network configuration file will look similar to this one:

auto lo iface lo inet loopback  auto eth0 iface eth0 inet dhcp  auto eth1 iface eth1 inet dhcp  auto eth2 iface eth2 inet dhcp  auto ath0 iface ath0 inet dhcp  auto wlan0 iface wlan0 inet dhcp

For the sake of this example, we only have two network cards, so I'm gonna simplify the example by removing the interfaces we won't use from the file. You can happily do your modifications without deleting them.

We need to think how we'll set up our network. We'll do it this way:

  • IP Address for wireless0: 192.168.0.2 (its own IP address we can define manually).
  • Gateway for wireless0: 192.168.0.1 (where does the internet come from? us, of course. 192.168.0.1 will always be your own computer in most of the cases).
  • Network Mask for wireless0: 255.255.255.0 (Always needed and standard value 99.9% of the time).

Note: You might need to think up another IP address for it if you're on a large network. Else, just leave it like that.

For sharing internet through the wireless with those settings, our interfaces file will end up like this:

auto lo iface lo inet loopback  auto eth0 iface eth0 inet dhcp  auto wireless0 iface wireless0 inet static          wireless-key 1234567890          wireless-channel 6          wireless-mode ad-hoc          wireless-essid 'Wireless Connection'          address 192.168.0.2          gateway 192.168.0.1          netmask 255.255.255.0

Note: Remember to replace wireless0 with your network adapter's name, which you can get by typing in a terminal:

iwconfig

Okay. Now, we're doing the following things:

  • Setting wireless0 to load automatically.
  • Specify a static configuration instead of being assigned by DHCP (which we won't be able to do).
  • We'll set an hexadecimal WEP key for safety (WPA is not supported at this stage).
  • Also, a channel where to send the information through. Remember Wireless is very similar to radio/tv communications.
  • Specify that we're going be in an ad-hoc network (peer-to-peer or mesh).
  • We'll put a name for it, which we'll use to identify it in Windows, and to identify ourselves in our location.
  • We'll set it's address, gateway and netmask as we decided earlier.

That done, we can restart networking to get the device ready:

sudo /etc/init.d/networking restart

After that, we'll fire up Firestarter:

gksudo firestarter

A wizard should appear. Follow through these steps:

  1. Press Next.
  2. Choose eth0 (or your Ethernet device's name) as the Internet device. If your IP configuration is assigned by DHCP, check/uncheck the corresponding box according to your situation.
  3. Choose wireless0 (or your wireless device's name) as the device which will share Internet. Check the box that says to share Internet.
  4. Do NOT activate the option to enable DHCP in the Local Network.

  5. Press Save.

If everything went good, it should say Firewall Started. If not, please refer to the Troubleshooting section, else, we're done here.

Configuring the CLIENTS

This is relatively easy. When you have your wireless card working (it should blink its led lights, or at least turn on) and you've set up the server correctly, all you have to do is this:

  1. Make sure your other computer has wireless enabled and working.

  2. Go to the Wireless Connections panel and scan for nearby networks. Yours should appear soon. If not, then something's wrong with your server computer or the connection itself. Refer to the Troubleshooting section for details.

  3. Double-click your connection and type your password in. Wait for it to connect.

  4. Go to Control Panel -> Network Connections and right-click your wireless connection, then click Properties.

  5. Click TCP/IP Internet Protocol (or similar) and click the Properties button.

  6. Click the Assign an IP Address Manually radio button (or similar).

  7. We'll need to put the following data:
    • IP Address: 192.168.0.10
    • Gateway: 192.168.0.1
    • Network Mask: 255.255.255.0
  8. Set the DNS addresses to the same ones that your desktop PC has. You can check that by typing on the terminal on the Server/Desktop computer (use the IP addresses after "nameserver"):

cat /etc/resolv.conf
  1. Click Ok, then Ok again to apply changes.

  2. Right-click the small icon on the bottom-right corner of the screen (system tray) which looks like a small monitor with some green curves next to it representing radio signals. Then click Repair.

  3. Pat yourself on the back for your hard work and make yourself a sandwich :)

Your laptop should have Internet now. If anything went wrong, check the Troubleshooting section, as always.


For more details lease refer the original content at https://help.ubuntu.com/community/WifiDocs/ShareEthernetConnectionThroughWireless


CD Slide-in trick to increase the speed of BSNL EVDO.

First, let me start with the CD slide-in trick:

1. Take an old CD or DVD.

[Image: th_06.jpg]

2. Connect the device:

[Image: th_03.jpg]

3. Swivel-Open the antenna of the device to about 90 degree: 

[Image: th_11-1.jpg]

4. Slide-In an Old CD or a DVD into the antenna, such that the CD’s hole will enter into the antenna.

[Image: th_04.jpg] [Image: th_05.jpg]

This completes the first method. And this will be useful to get much better signal reception for people who use a laptop and also for people who keeps thedevice static on their desktop.

Now the second method requires a USB extension cable or a USB HUB. Here you go:

1. Take an old CD or DVD and a USB extension cable/hub and slide-in the CD/DVD as I mentioned in the first method.

[Image: th_02.jpg]

2. Connect one end of the extension cable or the HUB to the EVDO data cable….

[Image: th_07.jpg]

3. ….and plug-in the device to the other end or to one of the hub’s port.

[Image: th_08.jpg]

This completes the second method and this is really useful to people who are using desktop. By doing this, one can place the device far from their desktop and can place it where they feel that the device is getting much better signal reception.

I tested by placing the device beside my room’s window, but I didn’t get good speeds, So instead, I’ve placed it on CRT monitor and it works absolutely good.

[Image: th_09.jpg] [Image: th_10.jpg]

Here ends the tutorial..

Tuning Ubuntu 9.10 Karmic for speed and better internet connectivity


After installing Ubuntu Karmic 9.10, I changed the following tunables

swappiness and vfs_cache_pressure

swappiness --> If we have large RAM, there is probably no use for a swap file and we can decrease the swappiness to a very low value without fear. If the RAM capacity is 512 MB or less than 1 GB RAM, then Ubuntu or any linux uses swap as a swapfile. The default swappiness is normally 60 (but I have seen 40 in case of Fedora 11 after updates). Do not touch the swappiness and cache pressure unless you have atleast 1 GB of RAM

If we decrease swappiness, speed of opening programs feels faster

to get current swappiness of system

sudo sysctl -q vm.swappiness

to change swappiness to value 20, which is low


sudo sysctl -w vm.swappiness=20

to increase the speed of browsing files and folders again and again, we should decrease vfs_cache_pressure. Default vfs_cache_pressure is 100, if we decrease it, kernel virtual machine (vm) caches files more and more

to get current vfs_cache_pressure

sudo sysctl -q vm.vfs_cache_pressure

to set vfs_cache_pressure

sudo sysctl -w vm.vfs_cache_pressure = 50

You can read original tuxradar article about improving speed by clicking this http://tuxradar.com/content/make-linux-faster-and-lighter 

Sometime today morning when browsing irctc and opening some news sites, youtube, Ubuntu took a very very long time. Then I remembered that old debian lenny errata page and followed it and tweaked tcp window scaling settings. If you ever feel that you are not able to visit some sites or browse properly, follow this debian errata

Debian Errata, see buggy routers may cause problem

or

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=401435

or

http://kerneltrap.org/node/6723

If you are bored to read the above and continue reading here, what I did, here is what I did after following the above errata page

 Hit the site you are having trouble viewing, if you feel there is problem open terminal and change the system param as follows

sudo sysctl -w net.ipv4.tcp_rmem="4096 65536 65536"

and 


sudo sysctl -w net.ipv4.tcp_wmem="4096 65536 65536"

 If you don't feel the same browsing/network issue you faced before setting these two tunables, then proceed below to make the changes permanent

To make above changes permanent upon reboot(speed increase and net improvements)  

Add these lines to end of /etc/sysctl.conf by editing it (sudo vi etc/sysctl.conf)


#decrease swappiness
vm.swappiness=20
#improve file/folder browsing speed
vm.vfs_cache_pressure=50
#debian tcp window scaling errata fix
net.ipv4.tcp_rmem=4096 65536 65536
net.ipv4.tcp_wmem=4096 65536 65536


Note: sudo sysctl -p reapplies all the settings from /etc/sysctl.conf and can be used

Sunday, July 25, 2010

How To mount Hard Drive Partitions Everytime when Login to Ubuntu Linux automatically

One of the biggest problem of using Linux is the fact that many times things just get screwed up. Most of the times it isn't your fault at all, it could be an hardware problem or an software glitch. However it doesn't change the fact that your PC is screwed up!
One of those things which happens with my Ubuntu is that it doesn't mount all my hard drives (except C:// drive, on which it is installed) during startup. I have to manually open up Places and click on each and every hard drive to open them up. This might seem to be a trivial problem, but it isn't. The major headaches due to this are:

1. I cannot keep any image from other hard drive as Wallpaper.
2. Amarok cannot start playing songs. It gives me an error saying 'File not located'. This is the most important problem.

So if you have been hounded by this problem too, then rejoice cause I have finally found a solution to this problem.
There is an amazing software called Pysdm which allows you to decide which drives to mount or unmount during startup. Pysdm is an GUI application and is extremely easy to use.


here are some methods.


Mounting Fakeraid

Its assumed you have formated you raid set using dmraid command with instructions found at FakeRaidHowto

You need to know the name of your raid set

sudo dmraid -ay

RAID set "sil_aiaedhaeafaa" already active RAID set "sil_aiaedhaeafaa1" already active

Edit fstab as per instructions above :

nano -w /etc/fstab

An example line to add

/dev/mapper/sil_aiaedhaeafaa1  /media/raid  reiserfs  user,nosuid,exec,nodev  0  0

Make sure you create the directory /media/raid

mkdir /media/raid

Reboot

Mounting and checking the partitions

In the terminal, type the following command.

sudo mount -a

To verify that the partitions were mounted properly, open Gnome's file browser and direct it to the locations at which the partitions were mounted. Click the 'File System' button to access '/', and navigate from there. If the partition being examined contains files, the modifications were successful, and the partitions will be automatically mounted every time the system is restarted.

If no files are found, please see XChatHowto and join #ubuntu on irc.freenode.net.

Using pysdm

Pysdm is a program to automatically setup partitions every time Ubuntu starts. This is verified to work in 9.04.

Installation

sudo apt-get install pysdm

Usage

Select each partition you want to change in the list. Note the type. Often it is ext3 (Linus) or NTFS (Windows). Use assistant and press OK. By default the partition is mounted at boottime. You can also mount the partition now. Press Apply. Done.

Using GNOME-Mount

Gnome-mount is a program which mounts disks using the same facilities as when mounting a disk as a normal user through Nautilus. There is no need to setup mountpoints or filesystems. This is particularly interesting if you want to use the automatically created mountpoints instead of manually specifying them for each disk.

Installation

sudo apt-get install gnome-mount

Usage

You can mount a disk as a normal user via

gnome-mount -p myDiskLabel

where myDiskLabel is your disk name (e.g Data). To have the disk mounted each time you startup (thus removing the password prompt on first usage of the disk), simply add above line to your list of startup applications (System->Preferences->Startup Applications). Note that while mounting through gnome-mount will not need a password, unmounting or remounting via Nautilus will still invoke the password prompt.
Please refer https://help.ubuntu.com/community/AutomaticallyMountPartitions for details

Saturday, July 24, 2010

How to install Ubuntu themes

This tutorial will guide you through installing new Desktop Themes in Ubuntu Linux – and provide a couple of resources to find themes.

  1. First you'll need to find some themes to download and try out. Techie Souls has a list of 50 of the best looking Ubuntu (Gnome) themes that you can peruse, complete with download links. And gnome-look.org is a great place to find even more themes.
  2. When you download themes, don't uncompress them. Leave them as tar.gz files – just remember where you saved them. From the Ubuntu menu, select System -> Preferences -> Appearance.

  3. click to enlarge

  4. On the Appearance Preferences page, make sure that the Theme tab is selected. Then click the Install… button.

  5. click to enlarge

  6. Navigate to the theme file that you downloaded, select it, and click Open.

  7. click to enlarge

  8. The theme should now install. Click OK.
  9. Click the Apply New Theme button.
  10. And Ubuntu will now apply that theme, changing the look and style of Ubuntu.

  11. click to enlarge

  12. Repeat the above steps to try out other themes. That's it!

HOWTO: Parental control. Now with GUI too!

HOWTO: Parental control. Now with GUI too! (updated version)
Description:
WebContentControl is a parental control GUI (more specifically a GUI for
DansGuardian+TinyProxy+FireHol).

Official website: https://launchpad.net/webcontentcontrol

Feedback is very welcome. And help too!

Please report bugs at https://bugs.launchpad.net/webcontentcontrol

Pre-Installation:
Please make sure you have the "universe" repository enabled.

Go to System->Administration->Software sources and check the "universe"
repository.
More info: https://help.ubuntu.com/community/Repositories/Ubuntu

Installation:
There are three ways to install WebContentControl:
1)Through the PPA repositories
2)From the Debian package
3)From source

1)Through the PPA repositories
Code:

deb http://ppa.launchpad.net/webcontentcontrol/webcontentcontrol/ubuntu
lucid main
deb-src
http://ppa.launchpad.net/webcontentcontrol/webcontentcontrol/ubuntu
lucid main

See here for how to add repositories:
https://help.ubuntu.com/community/Repositories/Ubuntu

Add the repos by command-line:
Code:

sudo add-apt-repository ppa:webcontentcontrol/webcontentcontrol
sudo apt-get update

Once you've added those repositories, just:
Code:

sudo apt-get install webcontentcontrol

(Or use Synaptic package manager if you prefer a GUI.)

2)From the Debian package
Download the latest .deb from the site and double-click on it or by
command-line:
Code:

sudo gdebi <package>.deb

3)From source
Code:

sudo apt-get install gambas2-runtime gambas2-gb-qt gambas2-gb-form
gambas2-gb-form-dialog gambas2-gb-qt-kde gambas2-gb-qt-kde-html
sudo apt-get install dansguardian tinyproxy firehol

Then download the latest version on
https://launchpad.net/webcontentcontrol/+download and:
Code:

tar -xzvf webcontentcontrol-1.0.tar.gz
cd webcontentcontrol-1.0
./configure && make && sudo make install

The shortcut should be created in Applications->System tools.
If it isn't, the command-line to launch it is:
Code:

/usr/bin/webcontentcontrol

How to uninstall it:
Code:

sudo make uninstall

How to Block Unwanted Website in Ubuntu Linux?

The process to block websites in Ubuntu Linux is very simple and doesn't
require any third party application. You just need to make a simple
entry in the /etc/hosts file. /etc/hosts is a very important file which
handles DNS and internet handling on Linux based systems. In order to
block some site from opening, open the /etc/hosts file by typing the
following command on the terminal:

gedit /etc/hosts

and add the following line:

127.0.0.1 domain.com

Example 127.0.0.1 yahoo.com

Here replace domain.com with the name of the domain that you wish to
block. Once the above exercise is done, who ever tries to access the
site will get a message "Failed to Connect".