Sujith's Blog

How to create wifi hotspot in access-point mode on Ubuntu 14.04

In our office we had only wired internet connection, I wanted wifi connection for internet access to my mobile phone. I have tried WiFi hotspot created using Ubuntu’s pre-installed network manager, but it was not working properly. I have searched a lot to get one good WiFi hotspot solution that is working in Ubuntu 14.04. The solution was to create a WiFi Hotspot in access-point mode. For which we need a network card which supports access-point mode.

This solution works only with, WiFi/Network cards supports access-point(AP) mode.

To check whether your network card supports access-point mode or not, use the following command:

    $ sudo apt-get install iw
    $ iw list

Look for AP entry under supported interface section. If it is present you can proceed.

Ubuntu’s pre-installed Network Manager doesn’t support AP mode, So we are using the KDE’s connection editor which supports the AP mode. You can install it using:

  $ sudo apt-get install plasma-nm

Once it is installed You can start it by

  $ kde-nm-connection-editor	

After opening it, click Add Button and choose Wirless(shared). Now in the Wireless tab set an SSID and choose Access Point mode.

Now set the password in the Wireless Security tab and Click OK.

Now your WiFi Hotspot will be visible to all other devices.

How to test cordova-specific feature in a meteor package using Tinytest on Android device.

Last week I have created a meteor package which had some cordova specific feature. After completing the coding, now its time to test the package. So I was about to use Tinytest for testing the package.

But how to test the cordova-specific feature ?. I read the Meteor Cordova Phonegap Integration guide from here. They mentioned about how to perform tests in an android device here. Now I tried the following:

meteor test-packages --android-device ./

Then an android app opened in my android device showing.

Testing in progress..

Passed 0 of 0

It never started the tests, the message was showing for longtime. Then after trying all arguments to the meteor test-packages, I found the following fix for running tests on android device, especially for testing cordova-specific feature.

meteor test-packages --android-device ./ --mobile-server http://192.168.1.4:3000

The mobile-server(--mobile-server http://<host>:<port>) argument is required for it to work on android device.

How to check which directory is taking more disk space in linux

Yesterday when I logged in to my server, I noticed that about 90% of the disk space used. Normally I use ssh to access my server from home. So I wanted a tool/method to find the directory which is using more disk space, that too from terminal. After some browsing, I found the following command which will list the top largest directories:

To list top 10 largest directories in the current directory

	$ du -ks * | sort -nr | head -n10

In the above commands we are using three linux command line utilities:

  • du, Disk usage utility
  • sort, Sorting program in unix.
  • head, head is a program on Unix and Unix-like systems used to display the beginning of a text file or piped data.

first du command is used for finding the size of each file/directory, then piped the output to sort, afterwards the sorted data is passed to head.

Options used with du

    k: show sizes as multiples of 1024 bytes, not 512-byte
    s: report only the sum of the usage in the current directory, 
    not for each file

Options used with sort

   n: used to perform numeric value based sorting
   r: used to reverse the sort order

Options used with head

   n: used to specify the number of lines to be printed 

The output for the above command will look like this:

41752	Mac Format - March 2015 {bk}.pdf
23892	nmap-6.49BETA1.dmg
4976	Malare Ninne -SongspkFree.Com.mp3
1064	demo login fb.apk
776	indian_patent.sql
240	IntelHAXM_1.0.8.mpkg
164	DocketingDB - Latest.csv
48	Capture.PNG
40	12453385.pdf
24	11245371.pdf

This method is not that easy, there is a handy tool for doing the same thing. That is ncdu (NCurses Disk Usage), which is a curses-based version of du, and provides a fast way to see what directories are using your disk space.

You can install ncdu on your ubuntu machine using apt

    $ sudo apt-get install ncdu

For mac users

    $ brew install ncdu

Sample output from ncdu

- /home/server ----------------------------------------------------------
   10.3GiB [##########] /Desktop
    9.9GiB [######### ] /.local
    5.3GiB [#####     ] /.meteor
  622.1MiB [          ] /.cache
  616.3MiB [          ] /clex
  197.2MiB [          ] /purple_line
  188.3MiB [          ] /Downloads
  147.9MiB [          ] /.config
  146.6MiB [          ] /.npm
  106.4MiB [          ] /.meteorite
   83.2MiB [          ] /back_up
   43.8MiB [          ] /mongo_db
   19.2MiB [          ] /.node-gyp
   18.9MiB [          ] /mrt
    1.7MiB [          ] /.thunderbird

Unable to ping devices connected on LAN in a D-Link Modem

I used to connect my Raspberry pi to my modem using USB Wi-Fi Adapter. Then ssh to my pi over Wi-Fi from my Laptop. Yesterday my USB Wi-Fi Adapter was not working. So I took a LAN Cable and connected my Pi to the D-Link Modem. Then the problem comes,

I’m not able to ssh or even ping to the Pi connected on LAN, from my Laptop which is using Wifi. After connecting my system on LAN Cable, I realised that Devices connected on LAN and Wi-Fi are isolated.

When both Pi and my Laptop are connected on Wi-Fi, there is no issue in ping or ssh. Similarly when both devices are in LAN there is no issue.

But I cannot use my Laptop always on LAN, then I spend a lot of time in all configurations of my D-link Modem(DSL-2730U). Finally found this solution.

  1. Log in to the modem configurations page, for me 192.168.1.1
  2. Navigate to Setup > Wireless > Wireless Basic
  3. Then uncheck Enable MultiAP Isolation .
  4. Click Apply Button and Reboot your modem.

My screenshot

How to list all IPs OR Hosts in the connected network

Last week when I started working with my Raspberry Pi, I was looking for a tool to find the Pi’s IP. Normally we used to login to the modem for details of connected hosts. But I wanted to list all hosts and their IPs in the connected network very quickly, without logging into the modem. Then I found a command-line tool called nmap for listing all hosts connected to the local network. nmap is a security scanner used to discover hosts and services on a computer network.

###How to use nmap to list all Hosts connected to the local network###

First, you have to check whether nmap is installed or not, by typing the following command:

	$ nmap --version

If nmap is not installed, install it by typing:

	$ sudo apt-get install nmap

Now type the following command to list all hosts:

	$ nmap -sn 192.168.1.0/24

Which gives you a list like this:

	$ nmap -sn 192.168.1.0/24

	Starting Nmap 6.40 ( http://nmap.org ) at 2014-12-28 16:55 IST
	Nmap scan report for 192.168.1.1
	Host is up (0.0028s latency).
	Nmap scan report for 192.168.1.2
	Host is up (0.0063s latency).
	Nmap scan report for 192.168.1.3
	Host is up (0.049s latency).
	Nmap scan report for 192.168.1.4
	Host is up (0.0030s latency).
	Nmap scan report for 192.168.1.5
	Host is up (0.00019s latency).
	Nmap done: 256 IP addresses (5 hosts up) scanned in 4.09 seconds

Here the option -sn stands for Ping scan, and 192.168.1.0/24 is the subnet change this with details of your network.