Here I explain what I did in Ubuntu 12.04 LTS. And will probably be similar in most of the GNU/Linux distros. This method requires a network manager for managing the different networks. First of all you need to ensure that your wireless interface card supports Ad-hoc networking. Because there are some which doesn’t support wireless Ad-hoc networks. Know your network controller by running lspci | grep -i network. Given below is a list containing some of the network controllers that supports Ad-hoc and there may be more in the list.
Step 1: Right click on the network manager icon->Edit connections. Now you will get a window similar to one displayed above.
If not try the Network Connections from the Preferences section.
Step 2: Click on the tab Wireless->Add.
Step 3: Enter the SSID as the name that should be displayed as the network name.
Step 4: Click on the Mode drop-down list to select Ad-hoc. Leave the remaining fields as it is.
Step 5: Click on the Wireless Security tab for adding a password and select one of the Security types listed.
Step 6: Type a password->Save.
If you need a static ip address then follow the sub-steps before saving
Step 6.a) Click the tab IPv4 settings and select the method as Manual.
Step 6.b) Click on add and then type a valid ip in Address section, 255.255.255.0 as Netmask and 0.0.0.0 as Gateway then Save.
Step 7: Click on the network icon again-> Connect to a hidden wireless network.
Step 8: Select the newly created network->Connect.
That’s all. Now this network will be shown in nearby computer’s network list.