Thursday, 12 April 2012

Connecting to LAN Internet using Linux OS

If you're reading this, its most likely that you have no clue how to connect to the LAN Internet (also referred as Cable connection) using your brand new Linux operating system. Don't feel bad, you're not alone.

Everybody had to ask few questions on how to get the freakin' internet work, and without the help of some folks on the online, I would have still been using Microsoft's Windows because connecting to the internet with it is so easy.

Internet is an important element when it comes to general computing, so if someone wants to introduce a new computer system such as Linux, at least let it run the most used service.

Now remember, you will not connect directly to the internet. Basically I'm going to teach you how to connect to a network that will enable you to use the internet. I'm not going teach how to use a certain Distro, or a certain GUI. Distro's network settings sometimes differ, so what I'm going to help you with is ignoring all the distro's default settings and write your own internet .sh script that would let you connect to the internet as easy as 1, 2, 3... So lets see what you have: A cable coming down from outside directly plugged to your NIC (Network Card), normally if you have one NIC, it would be named: eth0 (ethX -> X will change if you have more than one NIC). In this example we're gonna use only one NIC to enable Internet on one station only. General internet connection requirements:
  • an IP address + netmask
  • a Gateway address
  • a DNS address
  • and sometimes a Proxy server address.
Know what you need. It's important to know what you need to connect to your ISP's (Internet Service Provider) network. You will definitely not guess those. While having a nice conversation with your ISP, ask them for the following:
  • Your personal external IP address + netmask (will use and netmask: as example)
  • Your network address (If your IP is then your network address would be - The gateway's (Server) internal IP address (will use as example)
  • Your DNS (usually same as the gateway) internal IP address (will use
  • and finally, ask him if he uses a proxy server, write down it's IP address and port if the ISP uses one. (Will use port 8080 as example; don't get shocked if the proxy's ip address is the same as the gateway and/or DNS).
You also need to know the following:
  • Path for Ifconfig
  • Path for Route
To do that do the following, open a terminal and write down:
haytham@sadusbox:/$ whereis ifconfig && whereis route

You'll get something similar to:
haytham@sadusbox:/$ whereis ifconfig && whereis route
ifconfig: /sbin/ifconfig /lib/ifconfig ...
route: /sbin/route /usr/share/man....

We're just interested in these:
ifconfig: /sbin/ifconfig
route: /sbin/route

Now that you gathered enough information, open your favorite editor,
(will use VIM here, know how to use your editor for the following commands, open,
save as, close)

Write down what is written in the box, and change the variables to your needs
(Variables start from the START EDIT comment to the END EDIT comment)

#-------START EDIT--------
#Setting some variables
echo "Setting Variables..."
#-------END EDIT--------

#Initialize external NIC IP address
echo "Initialize external NIC ($NICNAME) IP address"

#Setting Network and Gateway Settings
echo "Setting Network and Gateway Settings"

$ROUTE add default gw $GATEWAYIP eth0
$ROUTE add -host lo

#Adding a DNS server
echo "Adding a DNS"
echo " " > /etc/resolv.conf
echo nameserver $DNSIP > /etc/resolv.conf

#Detecting default route settings, this may take 5 seconds of wait
echo "Detecting pre-default route settings, this may take 5 seconds for probing"
$ROUTE | grep default

echo "..."
echo "Internet is enabled, happy surfing..."

Save this file as: in your /home/user/ directory and then set its 
permissions to 755 by doing the following command:
haytham@sadusbox:/$ chmod 755 /home/user/

You can now login as SuperUser and just write:
haytham@sadusbox:/$ su
root@sadusbox:/$ sh
Internet should be smiling at you. If your ISP uses a proxy server address don't
forget to add the proxy server's address ( and port 8080) inside your
favorite web browser so that you would be able to surf the pages and most importantly
in your .bashrc script so that it would let you connect to the proxy from bash.To do
that open with your favorite editor the file .bashrc and write the following in the
first lines:

export http_proxy=
export ftp_proxy=
Hope you enjoyed reading this comprehensive guide to help you connect to the Internet on Linux using your cable.

Tuesday, 3 April 2012

9 best tips recommended exclusively for Debian

The Debian operating system comprises software packages which are released as open source and is well known for the abundance of options it offers.

Below is a comprehensive compilation of some of the best tips exclusively recommended for Debian.
  1. Never install new packages with long dependency lists unless you make sure ( that they do not contain any major bugs or are currently broken, or might break other packages in the tree.
  2. Its advised you run apt-get update weekly. Package lists tend to change very often.
  3. Never EVER run apt-get upgrade OR apt-get dist-upgrade. Doing so, you will have signed a deal with the devil. Those two commands are very dangerous to run as they tend to upgrade a very long list of packages which are considered core system packages. This will result in lots of painful package downgrading which you really don’t want to spend time doing.
  4. Always keep an eye out for security packages and patches which are available via apt. Those things are often life savers.
  5. If you have multiple Debian boxen, you NEED apt-proxy, which serves as a local Debian mirror to all running systems on your network. This will save you endless hours if you have a slow internet connection.
  6. In case you ever feel your hard drive space is mysteriously vanishing, then a quick look with -ch /var will show you that the cache directory is keeping hold of all your downloaded Debian packages. You can choose to keep them somewhere else or simply wipe them out by using apt-get clean.
  7. If you need a new kernel installed then the folks at Debian have compiled one just for you. It’s a modular kernel with security and Debian patches applied. A simple search for "kernel" and "2.4.xx" should suffice. Find the right architecture, and install it. Look out though, you will have to modify Lilo (or grub) to use the provided initrd.img file so you can load the cramfs file system and boot.
  8. If on the other hand you're "I'm a real hacker and I compile my own kernels thank you!" kind of person, then feel free to get your own kernel source and use make-kpkg to compile it and create a Deb file from it. This will make installing and removing kernels easier and more "in sync" with the whole Debian packaging system.
  9. The last and final tip is, um, actually, there's no last tip. I just wrote this cause I like the number nine, and I thought I'd just waste some more of your time.
I hope that you find this helpful as educational and fun as I did.