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

Friday, June 27, 2014

Use your Chromecast/Roku on a Hotel WiFi

Chromecast and Roku are really wonderful devices which allow you to take all your media with you where ever you go. Especially, if you travel a lot, it's definitely way better to watch something on your Netflix subscription rather than paying exorbitant rates on the hotel's pay-per-view.

But there's a problem. Hotel WiFi's usually use web based authentication (i.e.) their wireless network is usually open and anyone can connect to it. Only when you try and open a webpage, they send you to an authentication page that asks for a username/password (which the hotel will provide you) and/or asks you to accept the terms and conditions.

The problem is that Chromecast and Roku do not have native support for such authentication. But fear not, in this post, i am going to write about a few ways in which you can work around this limitation to enjoy Roku/Chromecast on the hotel's WiFi network.

Find out your device's MAC Address

2 of the 3 workarounds that i mention requires you to know the MAC Address of your Chromecast/Roku device. Here's how you figure it out:

Roku
  • Switch it on
  • Navigate to Settings->Network->Wireless
  • On the bottom right, you can see the MAC Address of the Roku
Chromecast
  • Switch it on
  • Connect your phone to the hotel WiFi and authenticate it
  • Open the Chromecast Setup app on your android phone
  • Tap on devices and wait for it to scan
  • Tap on your Chromecast device in the list
  • Tap "Set Up"
  • Tap "I see the code"
  • Tap "Set Name"
  • The MAC Address of your chromecast will be displayed on the screen now. 
Workaround 1 - Call the Tech Support

Most hotels give you a small sheet of paper with your WiFi username and password. That sheet usually also has a "tech support" phone number. Here is what you can do: Call the tech support number and tell them exactly this: "I would like to use the roku media player device over the hotel WiFi. I wanted to check if you could whitelist the MAC Address of my device to by-pass the authentication page".

Depending on the mood and knowledge of the tech support person, he/she might say okay. But nevertheless, it's gonna take some time before the whitelist happens. And once the whitelist happens, you can enjoy Chromecast/Roku over the hotel WiFi.

Workaround 2 - Spoof your MAC and authenticate from your laptop

The whole web authentication system works around MAC addresses. Once you enter your username and password, your MAC and IP addresses are going to be whitelisted for a certain amount of time (about 24 hours) and your device will be allowed to access the internet in that time period.

One key weakness about this authentication mechanism is that MAC address is easily spoof'able. So we are going to to assign your Roku/Chromecast's MAC address to your laptop and perform the authentication like usual and then make use of that whitelist to access the internet from your Roku/Chromecast. Here are the steps (follow them precisely to the word):
  • Find the MAC address of your Roku/Chromecast using the steps above. Note it down.
  • Open the terminal (assumes linux).
  • Run "ifconfig" and note down the MAC Address of the laptop. [1]
  • Run this command: "sudo ifconfig wlan0 down".
  • Disconnect from the WiFi network on the laptop.
  • Run this command: "sudo ifconfig wlan0 hw ether <mac address of roku>".
  • IMPORTANT: Turn off the Roku/Chromecast by unplugging it.
  • Run this command: "sudo ifconfig wlan0 up".
  • Connect to the Hotel's WiFi network on the laptop.
  • Open the browser and navigate to google.com (or any other website).
  • It will ask for authentication, provide username/password that the hotel gave you.
  • Type google.com again and verify that you can access Google.
  • Run this command: "sudo ifconfig wlan0 down".
  • Disconnect from the WiFi network on the laptop.
  • Run this command: "sudo ifconfig wlan0 hw ether <mac address of your laptop from step [1] above>".
  • Run this command: "sudo ifconfig wlan0 up".
  • Now you can plug your Chromecast/Roku back in and connect to the Hotel's WiFi network on that. It should now be connected to the internet!
You will have to repeat these steps after the whitelist expires (usually about once a day).

Note: The above two work arounds will connect your Chromecast/Roku directly to the hotel's WiFi 

Workaround 3 - Set up your own WiFi network

Buy a portable WiFi adapter and use that to share your Hotel's WiFi through your own access point.

Hope this helps!

-Vignesh

Sunday, June 30, 2013

Using hash tags to organize bash history

We use hash tags all over the place in social networks. We use it extensively on Twitter and Instagram. Facebook recently launched support for hash tags as well.

So, in a way, our online life revolves around hash tags. Given that, it’s a really great thing for bash power users that # in shell means comment. I usually tend to type long commands and won’t bother remembering or saving them somewhere as it is in the bash history and i can retrieve it by reverse-i-search (Ctrl+R) anytime I want. 

As time passes by, more than often I end up retyping the whole command as reverse-i-search doesn’t have a unique combination of letters/words to search for. So, off late, I have found a dead simple way to never lose control over reverse-i-search because of too many similar commands. I just append a hash tag every command I type in. And later search for the hash tag in reverse-i-search. Since, anything that follows # is treated as a comment, the text is silently ignored, while giving you power to search through it alter on.

For example, when i write PHP code, I often tend to run lint on all the php files before executing them to make sure there aren’t any silly syntax errors. This is the exact command that i run:
find . -iname '*.php' -print0 | xargs -0 -n1 php -l
If you look at this command, none if its contents are unique by any mean. All these phrases and commands are something that we use over and over again. So it’s very plausible that this might get lost in the bash history and practically un-searchable with reverse-i-search. Now this is the command with a hash tag appended:
find . -iname '*.php' -print0 | xargs -0 -n1 php -l #phplint
Tada, there we go. From now on, we can do a reverse-i-search for “#phplint” or merely “phplint” to get back this command from the bash history. Also make sure you set HISTSIZE to a large value in your .bashrc to make sure you history is practically infinite.

-Vignesh

Do a good deed today. Donate to the Prime Minister's National Relief Fund.

Wednesday, December 1, 2010

Android 2.1 USB Tethering in Ubuntu

The worst part about owning an android phone is to wait for updates from your hardware vendor (HTC in my case) to provide OS updates. I am still stuck with Eclair and eagerly awaiting froyo,while the N1 counterparts are eagerly awaiting gingerbread :-P.

Wifi tethering (using the phone as a wifi hotspot) is one of the key features of froyo. Since i don't have froyo, i have to go through a tedious process to setup wifi tethering in my eclair. So, i chose the easier option of USB tethering.

Before i even connected the USB cable, i browsed through the internet and found out there are various methods available for USB tethering. There were many tutorials on how to achieve this. I read all levels of tutorials from rooting the device to installing the SDK to installing a $30 app. Atlast i found a simple app, which could do the trick.

I connected the phone (running android 2.1) and the computer (running ubuntu 10.04 netbook remix) and selected "Enable mobile internet sharing" in the phone. Thats when the miracle happened. A small pop up notification appeared in the top corner saying "Connected to wired network auto usb0". I was surprised. I had just spent half an hour surfing through tutorials to make this work. All of a sudden out of nowhere it works out of the box on just connecting the cable. To ensure i just pinged my blog and it was working like a charm!

So its windows that requires all the crappy drivers and vendor software for USB tethering. In ubuntu it automatically established a LAN (PAN may be) and set the IP, gateways and DNS and works on the go without any manual effort (except for connecting the phone and computer of course ;-))

So for all who want to tether your phone's internet connection, please do not waste your time in reading tutorials and rooting your device. Just boot into linux and connect your phone :-)

P.S.: This post is through the tethered 3g connection :-D

-Vignesh

Saturday, October 9, 2010

root - The king of kings - Question (Part 1)

After these many years of linux, i have finally found something that root cannot do but a non-root user can do! Yes, its true and it was difficult for myself to believe this in the first place. Its like the phrase, “I saw binary numbers floating in my dreams, wait a second, i think i saw a two!”.

I have always not liked the fact that root is the king of linux and he never respects anyone else. Of course we need a system administrator who should be able to control the entire system, but at the same time, using a system administrator account should not be considered as dangerous, as many of the linux distros warn me.

Consider a simple case, root executes rm -rf * from a directory that is owned by xxxxxx and permissions set to 700. root will be able to successfully do this as he has no limits (which is the cause of the danger). I feel that root should still respect the permissions and not be able to do this in one step. If he really knows that he wants to do it, first he should change the permissions of the file (say to 720) and then perform the rm. By this, it requires two mistakes to screw up, rather than one. But the point is, root should respect permissions and he should modify the permissions when he clearly knows what he is doing and must not be entitled to do anything arbitrarily.

Now, to the actual topic. Here’s what a normal linux user would think is always true:

user@user$ marry me
fuck off!
user@user$ sudo marry me
with pleasure sir!


The point of the above statements is that, no matter what, root can always do anything and everything, unless i recently found one exception. I was able to run a command as non root but not as root.

user@user$ touch foo
user@user$ sudo touch foo
touch: Permission denied


Can anyone figure out how on earth could this happen ? (Yes it is really possible!). I’m posting this as two parts (Question and Answer). I will post the scenario i came up with along with the explanation how it is theoretically correct in the next part. If you know of such a scenario, please share it on comments :-)

-Vignesh

Wednesday, August 11, 2010

Linux X Server - Awesome Abstraction !! :-)

Before you start reading this, a headnote, this article is targetted for people familiar with linux. Though i have tried to keep it as simple as possible, some parts of this article may seem greek and latin to those who are not familiar about linux.

To start with, as the title suggests i am gonna talk about the Linux X windowing system. Before starting, there have always been so many things about linux that have been controversial (like Vi vs Emacs and Linux vs GNU/Linux to name some - people who are not familiar with all these, just ignore and read on). Linux has always been (atleast according to me) distinct in its way of organizing itself so that the users can extract maximum output of it. Adopting strictly to the basic open source principle of "choice". Briefing it in a nutshell, linux and its companions have always adhered to the goal of providing the maximum choice for its users (best example is the number of linux distributions out there (ubuntu, fedora, suse, etc)).

The linux way of architecturing a product or its feature is in such a way that it can be extracted to the fullest. I am going to write about one of the best examples of such an architecture that linux has built over years, the X Windowing System. So, what the hell is it ? If you are a linux user, you are most likely to be using the X right now. If you have seen linux before, then you have probably seen X. Before talking about the architecture of the X windowing system, let me give a brief introduction about it.

Gedit running in windows via putty


The X windowing system is the basic graphical user interface in linux. The X protocol specifies the way the windows are displayed on the screen. So whats the big deal about it? All the operating systems have some such thing that is used to display stuff on the screen. Yeah, thats true. But the way X does it is significantly different and i shall say, the designer of X is a real out-of-the-box thinker.

If you or me were designing such a system that is used to display stuff on the screen, all we would have done is make a level of abstraction over all the processes that requires display and just draw whatever is requested by the processes simply on the screen. X does just this. But how it has layered itself is what stands out.

First some terminologies. The programs which require to display something are known as the X Servers. The entity that actually interacts with the screen and draws stuff on the screen is known as the X Client. People generally tend to confuse this with the client-server model whereas this is actually client-server model with the roles reversed. In general, the guy who provides service will be called the server whereas here the guy who requests service is called server. (I still could not figure out why this terminology is followed).

The X server and client communicate via sockets. This is where X stands out. Since they communicate via sockets, yeah you guessed it right, it does not matter where the client and server runs (whether on the same machine or not). The TCP/IP stack of the OS takes care of the abstraction in how the requests and responses reach the client and server. So, the client can be any running application (even on a computer without a monitor attached to it) and the server can be any computer (of course with a monitor attached to it). As long as the client and server can communicate with each other via a network, it is possible to access both the computers using a single monitor.

Though this might sound fairly trivial today thanks to a bunch of remote GUI software available in the market, this is something that has been so well thought on those days when X was designed. It is when i see such wonderful designs i realise my college HOD's phrase "More the abstraction, Better the survival".

This article may even be a piece of junk. But i just could not resist blogging about such an awesome design.

P.S.: Seriously, you can scold me openly. :-)


-Vignesh

Thursday, July 22, 2010

7 Mistakes of my life (in the linux commandline) :P

Many people who know me will know that i am an open source enthusiast. Hence, going by the basic prerequisite of an open source enthusiast, i have been using linux primarily for the past 5 odd years. To begin with, initially i was very obsessed with the eye candy GUI available in Linux. It was way too good and no where close the ones available in windows. But recently (i.e.) in the past two years or so, I have realized that the linux way of doing things is to use the mighty shell.

So all the linux geeks talk about the shell, what the heck is it? The answer is simple. Unix shell is the powerful command line interpreter, that provides an user interface through the command line. Almost all the operations that are possible with a GUI, can be performed using the shell.

7 Mistakes of my life (in the linux commandline)


I came to know the immense power of shell more recently (during my internship with hashcube), where i had to log in to a remote server for all my work. That was the time where i learnt a lot about the linux shell since i had no GUI access and that was when i discovered the real power of shell.

The rest of this post might sound hebrew and chinese (why always greek and latin :D) for those who do not know (atleast) the basics of linux shell. In this article, i am going to share the (reasonably impacting) blunders i have made with my unix shell so far in life. Almost everything were done as root (unless mentioned).


  1. I once typed this in my friend's computer for fun when he was away talking over phone,
    rm -rf *
    And i did not press the enter key. My friend was talking in phone for quite a while and his monitor went to sleep by the time he came back. Guess what he did ? Yeah, he tapped the enter key twice to wake his monitor up and by the time the display came back on he was already scolding me by bad words ;-) Moral: Never tap Enter/Esc key when monitor goes to sleep. To be safe, press keys like alt, ctrl, caps lock.

  2. To remove all the files in /tmp/foobar, i had to type
    rm -rf /tmp/foobar/*
    But to my ill luck, that folder was empty and hence my tab completion added an extra space before i could type * and hence i typed
    rm -rf /tmp/foobar/ *
    Guess what the shell did with this ? Yeah, i lost my entire home directory :-) Moral: Always see the rm command thrice before pressing enter. And to be safe, put the -rf option in the end after checking the rest of the line.

  3. Recent linux versions have the option of protecting a partition by encryption. I once did an file system check fsck on such an encrypted volume and lost almost everything in it. Moral: Check the filesystem type twice before running a check

  4. I wanted to create a compressed archive. So i open the shell and quickly type in,
    tar -czvf /path/to/file file_archive.tar.gz instead of
    tar -czvf file_archive.tar.gz /path/to/file
    Yes, i lost the file which i had no backup of!

  5. I had around 1000 files with a # in their name. They were all debug files that were no more required. Hence i decided to remove them using the following command:
    rm -rf *#*
    Well, whats wrong with this? Paste this command in an editor that highlights syntax, and you'll know whats wrong :-)

  6. I used to have my desktop switched on for days together. To check when it was last rebooted, i typed in
    last | reboot instead of last | grep reboot
    No need to guess what happened !! :-)

  7. Try this as root if you are dare enough (or free enough to sit and reinstall your linux now):
    chmod -R -x /bin


Though the linux shell is very powerful, (we all know with great power comes even a greater responsibility), if you are not careful in using it, you might be standing in front of your boss begging yourself for screwing things up, or even worse nightmares can happen. :-)

Go ahead and share more interesting shell mistakes that you have come across.

Note: Throughout this article i have used the terms Unix/Linux interchangably though it is not the same

-Vignesh