Pages

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, October 23, 2011

Ubuntu network manager and disappering nm-applet icon

I had this strange issue with my Ubuntu install when the nm-applet icon a.k.a. network icon disappeared from the task bar. After much effort i found out a work around that was to stop network-manager application and then launch nm-applet and then restart the network-manager application.

But the solution to this is a very simple one, and as it turned out was not a bug.
If you are faced with such a situation do make sure to checkout your /etc/network/interfaces file to see that the interface is not listed. If the interface is listed in that file remove it else the network-manager wont take over that interface by default.

sudo service network-manager stop
nm-applet &
sudo service network-manager stop

Sample lines in /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.244.2
netmask 255.255.255.0
gateway 192.168.244.244
 

Comment out the interface you want network manager to take over, in this case eth0
#auto eth0
#iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.168.244.2
netmask 255.255.255.0
gateway 192.168.244.244
 

Then you may simply restart your pc or you can simply restart the networking using
sudo /etc/init.d/networking restart 

Thursday, August 19, 2010

Monday, August 16, 2010

Quote of the day

"Muft ke cheez mein makhi zaroor hoti hai", Shoaib Bhatti.

So true for Ubuntu :p :D

Friday, August 6, 2010

Recovering lost Ubuntu installation after installing windows

You can  try installing and using Boot-repair, for instructions on installing and using it refer to the following link. (Note: i have not personally tried it but seems user friendly)
https://help.ubuntu.com/community/Boot-Repair

Or alternately you can choose to do it manually

Boot from a live cd of Ubuntu 10.04.
First, find out about your drives.
sudo fdisk -l
Then check to see if the drive is already mounted or not
df
If it is not mounted then mount it first. This is the drive in which Ubuntu is installed. In this example i will be mounting /dev/sda2 on to the folder /home/mtf
mkdir /home/mtf
sudo mount /dev/sda2 /home/mtf
In case you are not sure which drive has Ubuntu installed, you would like to look for a drive with System field as "Linux" in the output of sudo fdisk -l
If you have multiple such drives and are confused, then you can check the drives by mounting each of them and looking at the contents to see which is which. You can mount multiple drives on different folders using the steps mentioned above. You may also mount to the same folder (not consecutively) by unmounting the former drive.In this example /dev/sda2 is unmounted and /dev/sda3 is mounted in its stead
sudo umount /home/mtf
sudo mount /dev/sd3 /home/mtf
Once the drive is mounted
sudo grub-install --root-directory=/path-of-mounted-drive-with-ubuntu-install /dev/sdx
Replace x with the letter for your hard disk.

In my example, /dev/sda3 is the drive with Ubuntu installation, mounted on /home/mtf so the command would be
sudo grub-install --root-directory=/home/mtf /dev/sda
Note that in the above case it is /dev/sda and NOT /dev/sda2

Additionally to ensure everything is in order boot into your Ubuntu and then do the following to fix any missing or malfunctioning entries in grub
sudo update-grub

https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

Sunday, July 18, 2010

Networking lab

For this lab you will need this manual. Its hard copy has been placed at the photocopier. You are to submit a hard copy at the end of the lab.

All help material has been posted on the blog here.

Saturday, July 17, 2010

Configuring network interfaces in Ubuntu

As a first step you should know which interfaces are configured in your machine. You can start by listing all the interfaces using the command: ifconfig

eth1 Link encap:Ethernet HWaddr 08:00:27:31:34:d7
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe31:34d7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1100 errors:0 dropped:0 overruns:0 frame:0
TX packets:1089 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:970170 (970.1 KB) TX bytes:181886 (181.8 KB)

eth2 Link encap:Ethernet HWaddr 08:00:27:96:82:41
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

eth2:avahi Link encap:Ethernet HWaddr 08:00:27:96:82:41
inet addr:169.254.6.94 Bcast:169.254.255.255 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:240 (240.0 B) TX bytes:240 (240.0 B)

In the output observe the first column it contains the interface name. You need to know which interface you wish to configure. I would be configuring eth2 in the rest that follows, you can replace eth2 by an interface of your choice.

In Ubuntu the main file in which all the network configuration is /etc/network/interfaces.

Before you start editing system files its a good practice to take back up, in case you screw something up, you can restore the file using the backed up file. You can back up the file by using the following command:

sudo cp interfaces interfaces.bak

First, what if you want to make an interface acquire a dynamic configuration using DHCP. in that case open the /etc/network/interfaces using your favorite editor. Note: In order to make changes to this file you need to be an administrator. To do this you need to use the sudo prefix:

sudo gedit /etc/network/interfaces

Look for an entry for the interface on which you wish to use DHCP. If there is one remove it and then add the following:

auto eth2
iface eth2 inet dhcp

Now you need to restart the network. Use the following command:

sudo /etc/init.d/networking restart


Part 2: What if you wish to assign a static configuration to the interface.

Once again open the file /etc/network/interfaces and search for the interface of your choice. Remove all the entries for it below the line auto eth2 (be careful not to remove the configuration for other interfaces). In my case I wish to have the following configuration

Desired new sample settings:
=> Host IP address 192.168.1.100
=> Netmask: 255.255.255.0
=> Network ID: 192.168.1.0
=> Broadcast IP: 192.168.1.255
=> Gateway/Router IP: 192.168.1.254
=> DNS Server: 192.168.1.254

Add the following lines to the file

auto eth2
iface eth2 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254


Once more, now you need to restart networking. For this use the same command as above: sudo /etc/init.d/networking restart

If you want a more advanced tutorial you can follow http://www.cyberciti.biz/tips/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ip-configuration.html

Libpcap in Ubuntu

You can begin by downloading and installing a new Ubuntu VM. Follow my older post for instructions regarding the installation http://zaidmunir.blogspot.com/2010/06/ubuntu-installation-on-virtual-box.html.
Once you are done installing you will need to download and install the libpcap development libraries. In case you need to find them your self, you can use the command to list possible matches:

aptitude search libpcap

You need to install the libpcap-dev package, for this use the command:

sudo apt-get install libpcap-dev

Friday, July 16, 2010

Software router

For those students working on software router, you need to be able to capture packets coming on the interface and analyze them as a first step towards your goal. This link is a useful resource.
You should especially look into this.

Thursday, July 15, 2010

Creating multiple virtual disk images for virtual box

If for some reason you want to run multiple instances of the same OS in virtual box, you need not install it multiple times on new virtual hard disks. Rather, you can create images of the VHD (virtual hard disk) which you can use for you new VM's. This article is primarily for windows, i have added notes for Linux users where appropriate.
1. In order to do this navigate to the folder where you have installed virtual box through command line. In windows you can launch command prompt by typing cmd in run and pressing enter. (In Linux VBoxManage command is in bin folder and hence its path is set, it can be launched directly from terminal by typing VBoxManage)
1.5. Before you proceed launch VBox. Goto File -> Virtual media manager.
       release the image you wish to clone. then also remove it. Make sure you do not delete the image when asked.

2. Next in this folder you will find the file VBoxManage.exe, you need to execute it with the following parameters.
3. VBoxManage clonehd [path of VhD to clone] [path + name of new clone VHD]
4. After this you should have a new VHD in the folder you specified. You can create a new VM in Virtual Box and use this clone hard disk in it. Enjoy :)

Wednesday, July 14, 2010

Libpcap

I have written a small sample code to get you started. You can download it here. to compile the code: gcc code.c -lpcap
and then execute the output file as: sudo ./a.out

Here is a code which generates an ICMP packet, you should follow the structure given in this code. Compile and run the code as mentioned above.

Thursday, July 1, 2010

Wednesday, June 30, 2010

Socket Programming

Here are a few helpful links for those who wish to learn socket programming.
http://www.tenouk.com/cnlinuxsockettutorials.html start from ch 1 and continue further, there is no end to iy, it all depends on how much you wish to learn. :)

For those of you who are getting jumpy and dont want to go through the details this page lists the details of the functions and there parameters that are being used. http://www.tenouk.com/Module39b.html

You can download and run the client and server executables to see what output is expected from you.

Monday, June 28, 2010

Setting up a shared folder in virtual box, windows host , ubuntu guest

You might be wondering if there is any way of getting your data from the virtual disk into your real machine or vice-versa, tension not, it is very easy. All you need to do is set up a shared folder. In order to do this follow the following easy steps.
  1. Go to virtual machine settings and select the shared folders tab.
  2. Now add the path of the folder you want to share and give a name to it, this will be used in your Ubuntu VM machine. Note: if you add the Desktop folder with its default name, i.e. "Desktop" you will not be able to set up sharing, this is some bug, so i recommend changing the folder name to "shared" or something else.
  3. Also check make permanent if you wish to use the folder again after reboot :)
  4. Now make a folder in which to map the shared folder e.g "mkdir ~/Desktop/share"
  5. now use the following command "sudo mount -t vboxsf share ~/Desktop/home" where share is the name of the shared folder you gave in virtual machine settings and ~/Desktop/share is the path where you wish to map the shared folder.
  6. Or you may edit the /etc/fstab file and put the following line in the end of it"share /home/username/Desktop vboxsf auto 0 0" notice here the ~ wont work, so you need to give the full path, and the last two arguments are zero not alphabet 'o'.
  7. Now open the folder and enjoy.

Notes:
  1. The Ubuntu folder that you are mapping to must be empty
  2. If you are already in the shared folder, it wont show any files, you need to cd back into the folder to be able to see the files.

Sunday, June 27, 2010

Installing ns-2 for multiple users

There are a few tips that might save you considerable time and irritation if you follow them.
  1. Firstly, never install ns-2 in the home folder, make a folder at "/" for installing applications, for instance "/Apps" in this case.
  2. Installing for multiple users is no big deal, just install it like you would for a single user, if you are looking for Ubuntu install instructions you can refer to my earlier post http://zaidmunir.blogspot.com/2010/06/installing-ns2-on-ubuntu-910.html you just need to prefix the commands mentioned in the link with a sudo :)
  • After installing it just make a minor change, instead of making changes to the ~./bashrc file make the same changes to /etc/bash.bashrc if you are using Ubuntu or /etc/bashrc for other flavours of Linux.
  • Now go the user which is most probably a "desktop user" you can switch environments without having to log off using the command "su username -" and enter password when prompted for it. Now you would be in the username's environment. now if you run ns-2 it would run but when you run the validation checks, it would fail. This is because the folder that you created at root does not have write privileges by default. You can change this issuing the command "sudo chmod -Rf +w /Apps/ns-allinone-2.34" or you can use "sudo chmod -Rf 777 /Apps/ns-allinone-2.34" this would cause the specified folder and its subfolder to have wrx permissions for all users.
  • Now you can run the validation tests and in a while you should get an all tests passed message. Whola, you are ready to go. By following this method all the users can run ns-2 without any issue. :)

Saturday, June 26, 2010

Useful links for Learning linux

For beginners here is a link to Linux basics http://www.ee.surrey.ac.uk/Teaching/Unix/

For a quick to the point intro https://help.ubuntu.com/community/UsingTheTerminal

One thing you wont be able to escape once you start working on Linux is MakeFiles, here is a very nice link explaining all that you need to know about Make files.

http://mrbook.org/tutorials/make/
in case you need more
http://www.opussoftware.com/tutorial/TutMakefile.htm

The next thing for a bit advanced users, well you would definitely feel the need to mould your machine according to your taste. Scripting my friend is the answer. Its a really powerful tool, once you get the feel of it you won't be able to let go of it. Here is a link to an excellent tutorial on scripting. It has one little bug, just replace !/bin/sh with !/bin/bash and you are all set to go :) Enjoy :D
http://www.freeos.com/guides/lsst/index.html

Friday, June 25, 2010

Installing ns2 on Ubuntu 9.10

A lot of people dread having to install ns2. Well here is a simple tutorial to get you through in just a single go. Mostly people fail at installing ns2 in the first go because of the missing libraries and dependencies.

Here is what you do to install ns2 in the first go.

1. Download ns-allinone-2.34

2. cd into the directory where you have downloaded the ns-allinone-2.34.tar.gz file. Then issue the command cp ns-allinone-2.34.tar.gz ~/

3. Then type cd ~/ to get into your home folder

4. Then use the command tar -xvzf ns-allinone-2.34.tar.gz

5. But before you can continue you need to install the following libraries

autoconf
automake
gcc
g++
build-essential
libxmu-dev
libtool
libxt-dev

6. You can download and install the libraries individually using the command sudo apt-get install libraryname e.g
sudo apt-get install autoconf

7. Now you are all set to proceed, but before you do there is one more modification that needs to be made, cd into ns-allinone-2.34/otcl-1.13 and then use the command gedit configure to make the following changes to the configure file.

change the following line
SHLIB_LD = "ld -shared" to SHLIB_LD = "gcc -shared", you would find that the string SHLIB_LD occurs at many places, you are to change the one that is written under Linux*)

OR you may try typing export CC = gcc-4.3 to change the environment variable, though i have not tried this seemingly easier method. (note: run the command gcc -v to check your version to use in the above command)

8. Now cd into the ns-allinone-2.34 directory and do ./install , hopefully everything will go smoothly and you ns-2 will be installed. But before you can proceed you need to set the environment variables.

gedit ~/.bashrc

copy the following lines at the end of the file, be sure to change /your/path to the path where ns is installed on your system.

# LD_LIBRARY_PATH
OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$USR_LOCAL_LIB

# TCL_LIBRARY
TCL_LIB=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-allinone-2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix
NS=/your/path/ns-allinone-2.34/ns-2.34/
NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM

for instance on my system i would replace /your/path with /home/z3d

9. source ~/.bashrc to have the changes take effect or you can simply reopen terminal.

10. Now cd into the folder /ns-allinone-2.34/ns-2.34/ and type the command ./validate
it will take a considerably longer time than it did to install and in almost an hour you should get a message all tests successful.

11. Now you can type ns and begin doing your work :)

Ubuntu installation on Virtual Box


There are a lot of people who do not wish to have a dual boot system or there are others who end up having their system screwed up after trying to install Linux on their machines. For all such people: Fear not, virtualization is here to save the day.

There are a lot of virtualization softwares available but over here we will be talking about Virtual box (http://www.virtualbox.org/), for those of you who do not know what virtualization is u can go here http://en.wikipedia.org/wiki/Hardware_virtualization for details. In very short, it is running another computer within your current operating system. So to say a Linux machine running inside your Windows machine and its likes.

You can begin by downloading the software which is free of cost from its website. You would also need an ISO of the Operating system you wish to install, in this case Ubuntu. Before you download Ubuntu you need to make sure that your machine supports 64-bit virtualization, if not or if you are not sure; its always safe to download the 32-bit version from the website.

Ok now you have installed Virtual Box and and have downloaded the ISO file, what to do next. It is definitely a waste of time and resources to burn the ISO on a disc :p. Here is what you do:

1. Click the new button to create a new machine.

2. Select appropriate name, be sure to set the OS type parameters properly. These parameters allow VirtualBox to enable or disable certain OS specific parameters, so you would wish to have them right.

3. On the next screen you should select the amount of RAM you wish to allocate to your virtual machine. You should be very careful here because the value you select here will be acquired by the VM (virtual machine) when it is run and wont be able to your OS. Implying if you have 512 MB RAM and you allot 400 MB to the VM, you will be in trouble, a VM error or a system crash, it depends on the OS you are using.

4. On the next screen select create new hard disk.

5. In the next tab it is recommended that you select the "dynamically expanding storage" and set its size arbitrarily very large, don't worry it would not take up as much space as you have selected, its just an upper limit that could be reached. On the contrary, if you select "fixed-size storage", the amount you specify here will be immediately taken up by the virtual hard disk image file (vdi file), it just has one plus point it performs a little better than the dynamic disk when you are writing to your virtual disk, apart from that the difference in negligible.

6. Now you are done setting up your machine, now you need to map the machines virtual CD ROM to the ISO. You can do this by right clicking on the machine and selecting settings, in the settings menu, select storage. In the right hand pane you would see a CD ROM icon, select it. Now in the extreme right pane click on the folder button. On the screen that appears press add on the top left and browse to the location of ISO file, then click select at the bottom right.

7. Now you are all set up to run the machine for the first time. Select the machine icon on the main menu and click start. You should now be seeing a screen of the OS setup. You can now install your selected OS on your machine.

Sunday, June 6, 2010

All set for the change

For years i have been contemplating moving permanently to the Linux platform. Every time one thing or the other kept me from moving on. Last week i finally found a version of matlab that works on linux :). Now i am already for the change. Here is a check list that you might find convincing
1. Skype works
2. Chrome works
3. VLC works
4. No need for MS office when you have got Open office
5. what else can a kid want more from a PC :P so it means you can also join the big guys :P :D
6. Now dont get thinkin that he is callin me a kid and what about himself, well as for me i have had a dual boot system with fedora for years and lately i have been using Virtual Box to use Linux inside Windows :)

Open source rox, besides in Pk no one really bothers about piracy but if you think of it it is equivalent to stealing, so its better to stop it :)

Monday, May 31, 2010

Ubuntu 10.4

Well Ubuntu's latest version has failed to impress me so far. The very first time i got on with some business i had to face some bugs :s. I use it on a virtual box. I tried mounting the shared folder and each time it gave me a stupid error, "invalid arguments", i reinstalled Vbox Guest additions all in vain. Went through lot and lots of posts and still no use. Guess what the problem was?? For some reason it did not like the share folder name which was "Desktop", i simply changed it to abc and there it was, DONE!
Ubunutu 10.4 fails to impress me so far. My general feeling about it, its for people who are new to linux and want an OS full of Shashka's, instant PM's and social networking bla bla bla....