Category Archives: Tip

Ubuntu Tech Snippet #13 – Get your public IP in terminal

Sometimes when you’re working on a project or are SSHed into a remote server, you need to find out the public IP of the device, without using a GUI web-browser.

I had to do this while working on setting up a script on my server, and came across this neat little command that will grab your public IP and print it nicely out for you to use!

All you have to do is run echo $(curl -s https://api.ipify.org) and you’re good to go!

Output from echo $(curl -c https://api.ipify.org)

Output from echo $(curl -c https://api.ipify.org)

You can also do this programatically. In python you can run this code to get the result as a JSON object:

import requests
session = requests.Session()
ret = session.get('https://api.ipify.org',
                   params={"format":"json"})
print ("Public IP Address:",ret.json()['ip'])

You’ll need to install the Python Requests module. This can be done either via pip. Just run sudo pip install requests. You can technically install it using easy_install, but please, please don’t. Just use pip.

And that’s it!

Thanks for reading! If you have any tips of your own, leave them as a comment down below and I’ll be sure to take a look at them!

Advertisements
Tagged , , , ,

Pi-Top: The DIY, 3D-printed, Raspberry Pi-powered laptop

If you’ve been following the Raspi.Today blog at all you may already know about the Pi-Top. As the title suggests, it’s a Raspberry Pi-powered laptop, that you print and put together yourself.

Various such projects have happened in the past, ranging from Ben Heck’s Raspberry Pi point-and-shoot camera, to a Raspberry Pi-powered tablet by hacker Michael Castor (which, awesomely enough, I got to see in real life at Maker Faire Detroit, which I attended in July)

However, those were far more individual projects, something someone did on their own, for themselves. And this is where Pi-Top differs from the crowd.

Pi-Top:

Pi-Top is different from so many other cool Raspberry Pi-powered projects in that it is something that will hopefully eventually be sold as a kit for people to do for themselves.

“The Pi-Top Kit provides a basis to expand your knowledge in hardware and software innovation. Build and understand your own Raspberry Pi Model B+ powered laptop. We take you through each component and its functionality, so that you can use the Pi-Top as a tool for your own build projects in the future.”.

From the Pi-Top website, pi-top.com.
pi-top team

The Pi-Top Team – Image from Raspi.Today

The process is supposed to a learning experience, all while you are putting together a working, usable every day, project.

“Further your knowledge with our free beginner to advanced Hardware & Software Innovation lesson plans, where we break down complex elements so you can start 3D printing, designing your own PCBs and creating products from start to finish.”

From the Pi-Top website, pi-top.com.

The project boasts some impressive specs, purportedly having a fully integrated laptop keyboard and trackpad as well as extra ports beyond the B+ Pi’s 4 USB, HDMI, audio, a 13.3″ HD screen, and 6-8 hour battery life with WiFi.

The team plans to launch their Indiegogo campaign on the 14th of October, just a week away. I’ll be sure to keep providing updates on this project and maybe even get one of my own (hopefully.)

Tagged , , , , ,

Ubuntu Tech Snippet #7 – Find the remaining disk space in all mounted partitions

Many people have several partitions on their systems for different OSes or even different partitions within one OS. This tech snippet is an easy way to find out how many more videos, applications, songs, and documents you have space for.

First off you need to start up a terminal window, you can do this by pressing Ctrl+Alt+T.

terminal

Empty Terminal Window – Open via Ctrl+Alt+T

Next, enter the command:

df
df terminal

Terminal Window running the df command

This brings up the results you see in the image above. However, seeing space available in 1K blocks can be relatively useless for the average user. So, here’s a flag you can add to make the output slightly more understandable:

Clear the terminal screen (clear) and run the df command again, except this time, include the -h flag:

df -h

 

df -h terminal

Terminal window running the df -h command

This flag, which stands for Human readable, takes the 1k blocks from regular df and converts the to slightly easier-to-understand units like Megabytes and Gigabytes. All of the columns remain the same, just the units have changed. As you can see in the screenshot above, I have a 36GB partition with 34GB used and 565MB available.

While not particularly useful for the average user, it is a very handy tool for more advanced Ubunt-ites and for systems (like servers) without GUIs, this becomes a must-have tool.

Tagged , , , , ,

Speed up Youtube and Twitch.tv speeds

Twitch.tv is renowned for being quite a bit slower than Youtube, at least for me, and it made watching streams impossible. Youtube, although better than Twitch, still wasn’t great, barely handling 360p.

snail

Snail – That’s all I have to offer

However, I was researching why the difference in video speed is so great, and I found a very interesting reddit post that talks about blocking two groups of IP addresses that causes a huge increase in Youtube and Twitch.tv speed. You can read it for yourself here. I just figured I would make a post of my own, as the reddit post only has links to instructions for Windows (bleh) not Linux (or Mac, however my instructions have not been tested on a Mac…don’t blame me if it your Macbook goes boom.)


How to increase Youtube and Twitch.tv speeds

It’s a pretty simple thing to do, you just have to block certain IPs from communication with your PC. While I’m not totally sure why this method works, I think it may be that we are blocking heavily-used ip-addresses and/or ones that have throttled speeds, thus causing Youtube and Twitch (and other streaming sites for that matter, I haven’t tested any others as of yet) to be faster! As for side affects, I haven’t seen any off the bat and the changes are applied immediately.

Ubuntu/Linux instructions:

Step 1: Run the following command:

sudo iptables -A INPUT -m iprange --src-range 206.111.0.0-206.111.255.255 -j DROP

Basically what this does is tell iptables (the default Firewall for Ubuntu) to take the given range of IP address (iprange --src-range) and stop (or DROP) any packets/communication going to/from those IP addresses.

Step 2: Run the following command:

sudo iptables -A INPUT -m iprange --src-range 173.194.55.1-173.194.55.255 -j DROP

This does exactly the same thing as the previous command, except with a new set of IP addresses.

Step 3: Watch Youtube Videos in HD! The video below is a Piano Guys (Great music group) that has every possible (on Youtube that is) video resolution for watching from 144p to 4k. Good for testing increased speeds, and good for the ears as well.

That’s all there is to this trick, it’s super simple (at least for Linux users) and works great. If you are a Windows user, read this post from Study Blog.net. Disclaimer, this post was written for Windows Server 2008, so it may not apply anymore. However, please don’t bite the hand that got you good Youtube speeds, the reddit post I got this trick off of is from February of 2013. If those instructions don’t work for you, just google Block ip addresses Windows [INSERT YOUR VERSION HERE].

Remember, this is a Linux/Ubuntu-focused (and/or biased) blog; I haven’t used Windows for more than, say, ten minutes in over a month, so don’t freak out about me not having up-to-date Windows instructions.


That’s all for now. Please remember to leave a comment down below about whether or not this trick worked for you, if you’re running into any issues (errors and the like), and send this to all your friends (though not too many, it’ll stop working.)


Edit – Improved way

I was using this just fine, but it stopped working after a while, strangely enough, so I went back to the reddit post and read over it again and read another reddit post (this time from the Technology reddit) and they pointed out some other ways to do this, better than the DROP command.

First way is to use the REJECT command instead of DROP. The commands you want to run now look like this:

sudo iptables -A INPUT -m iprange --src-range 206.111.0.0-206.111.255.255 -j REJECT

and

sudo iptables -A INPUT -m iprange --src-range 173.194.55.1-173.194.55.255 -j REJECT

Almost identical to the old ones, except for the difference in the final word.

The second way just works for Firefox users (sorry Chrome, Midori, Safari, and all those other browser users) to use a Firefox addon, BlockSite Plus. You just download it (it’s a no-restart addon,) open up the addon’s preferences (enter about:addons in the address bar):

Firefox Addons Menu (about:addons)- Select Preferences for BlockSite Plus

Firefox Addons Menu (about:addons)- Select Preferences for BlockSite Plus

And enter the IP addresses:

BlockSite Plus Preferences - Enter the IP address ranges here

BlockSite Plus Preferences – Enter the IP address ranges here

This one is great for Windows/Mac users, as it will work without having to mess with commands and terminal/command line. I’m not totally sure this second method works, as I’ve already got iptables blocking those IPs, but it seemed to be accepted as a method on the reddit post.

This seems to be working right now, but if you are using Linux and use the iptables command, you will either have to set it up so that the iptable commands are run on boot up or you will have to enter them manually whenever you restart.

Tagged , , , , , ,

Warning! You WILL want to turn your volume down if you are wearing headphones. You run the following commands at your own risk, I cannot confirm the safety of your ears.

Another Ubuntu Tech Snippet inbound! This one is a bit bizarre, I must say, and rather geeky.

The actual idea is pretty simple, you just run a command in terminal and pipe it through aplay. You can take this and try any commands you want, but the commands I list are the ones that I have heard actually play something more than a two-second electronic squelch.

I originally found out about this on Unix/Linux Stack Exchange. First thing to do is run the command

dmesg | aplay

which runs the dmesg (which, from the man page,  examines or controls the kernel ring buffer) command and then pipes the output into aplay, the command-line music player. In this case there are no flags on the dmesg command, so it just reads all the messages from the kernel ring buffer.

By piping the output from dmesg into aplay you will be getting the audio interpretation of whatever data dmesg returns. It will vary between computers, so don’t blame me if your speakers, earbuds, headphones, or eardrums explode because of the interpretation of raw std data. I didn’t do anything horrendous to my system, so you should be safe. Emphasis being on should – I’ve not tested or researched any chances of damage.

Another fun one to play is

ls -l | aplay

in the home directory, especially if you installed lots of software that has config folders/files in the home directory.

This is a Tech Tip that really has no real application, it’s just fun.


One final thing to try if you suddenly become addicted to raw data musically represented

Run

ls -R | aplay

in your Documents directory and have fun listening to the ear-splitting screeches of your computer’s innards. Because the -R flag on ls recursively lists subdirectories within the currently directory, this command can go on for quite a while. Just a warning.

Ubuntu Tech Snippet #5 – Hear what terminal commands “sound” like

Tagged , , , ,

I use my Raspberry Pi as a headless server, and thus SSH in all the time. While I can shut down the Pi and remove the SD card to load files on, or use a USB stick, those require accessing the Pi (and in the case of the USB stick – running wires to a USB hub.) This can be a pain, so if I need to download a file I just use wget.

It comes installed with Raspbian by default as far as I know. It makes sense that it would, as so many core software rely on it. Thusly, I use it download files from the internet or, if I need to put a file on it from my Ubuntu laptop, I just pop the file into my local server and download it onto my Pi. Works great!

However, there is one issue that I have run across, and that is that just running a simple wget command like

wget soandso.com/thisZIP.tar.gz

results in an error:

Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... failed: Name or service not known.
wget: unable to resolve host address `dl.dropboxusercontent.com'

Kind of issue, you might say. It took me ages to figure this one out, but finally I discovered that if you add the -4 flag to the command, it forces wget to use IPv4 addresses, thus resolving the issue and allowing downloads to happen!


Bonus Tip!
If you are downloading a large file and the download gets interrupted, tack on the -c flag on the wget command and it will continue from where you left off. Pretty nifty, eh?

Raspberry Pi Tech Tip #1 – Fix Unable to Resolve Host Address error for wget on Raspbian

Tagged , , , , , ,
%d bloggers like this: