Tag Archives: Ubuntu Tech Snippets

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 , , , ,

Ubuntu Tech Snippet #11 – Speed up your Ubuntu installation with Preload

One of the great time & space conundrums is the need for speed. Everyone wants things, especially their computers, to be fast. And while Ubuntu can be much lighter on system resources than Windows or OS X, any extra speed is awesome and probably accepted by most people.

And so, I present to you Preload. Preload is, according to the manpage (man preload):

“an adaptive readahead daemon that prefetches files mapped by applications from the disk to reduce application startup time.”

Basically, this means that it keeps files loaded that are accessed by applications you commonly use, thus speeding up application startup time.

Note, if you’ve got a smaller amount of RAM (4GB or less) this may not be the best idea for you, as it stores all of the data in RAM – which may lead to slower overall system responsiveness.

However, if you’ve got more than 4GB of RAM or want to try it regardless, here’s the steps:

Tech Tip:

  1. Open Terminal (Ctrl+Alt+T)
  2. Enter sudo apt-get install preload
  3. Hit Enter.
  4. There is no step four

Yeah, it’s that simple.

Of course, if you really want to tweak it, there is a config file stored at /etc/preload.conf.

Conclusion:

What’s this good for? Well, it depends on what you do.

If you’re a developer, video editor, music maker, basically any content creator and are constantly launching a few key programs, then Preload is great. It speeds up launch times for those apps you use all the time and may only launch for a few minutes or seconds at a time.

If you’re just using your system for general work, like writing papers, checking stocks, or balancing a spreadsheet, this may not be as useful and may in fact harm performance, as you’re using up RAM to save a few seconds off the launch of an application that you’re going to leave open for quite a while.

This should work on basically any supported desktop and server Ubuntu release (at the time of writing, this is Desktop: Ubuntu 12.04.5, Ubuntu 14.04, and Ubuntu 14.10 and Server: 10.04.4)

Leave a comment down below telling me what you thought of this article, tell me something you want me to write about, and feel free to share any tech tips of your own!

Tagged , , , , , ,

Ubuntu Tech Snippet #10 – Remove Extra Music Players from the Ubuntu Sound Menu

Tired of pesky music players swarming your sound menu? Sick of all those silly video players making your sound menu take up half your desktop? Well, wait no longer. This Ubuntu Tech Snippet is going to show you how to, in über-l33t fashion, remove the programs that you don’t want hijacking that menu.

Problem:

The Ubuntu Sound Menu is a stupendous idea. Don’t get me wrong – I love this feature and think it should be standard everywhere. It just makes so much sense and make listening to music so much easier, all without the need to keep the music player open.

But there is one key issue, and that’s the fact that basically any music or video player that even sneezes at playing audio can technically plop itself down in this menu. Obviously, if you’re like me and like testing out new software, you are going to end up with a lot of programs filling up the menu, making the menu more of hastle than usual:

ubuntu sound menu - messy

Ubuntu Sound Menu – Look at all those media players…

Solution 1:

Fixing this is a pretty simple solution – uninstall those pesky buggers. Just uninstall the software that’s giving you trouble and you’re good to go – they’ll be removed automatically. Now, this isn’t that great of a solution – read on for the real solution.

Solution 2:

This solution is just a bit harder, involving modifying dconf settings. However, with the help of our trusty tool, dconf-editor, we can fix it! Now, Ubuntu should come with dconf-editor pre-installed – if it is, skip this next step. However, if it isn’t, you can just run the following commands in terminal:

sudo apt-get update 
sudo apt-get install dconf-editor

Once it’s installed go ahead and start it. It’ll look similar to this, though not exactly the same, since I have the Numix GTK3 theme installed:

dconf Editor

dconf Editor

Once it’s open, expand com, then canonical, then indicator, then click on sound. The image below highlights each one:

All the steps, highlighted and numbered. See, it's not that bad!

All the steps, highlighted and numbered. See, it’s not that bad!

Once you’ve got the sound option selected go ahead and double-click on the text next to the label interested-media-players:

interested-media-players

interested-media-players is currently selected

You may have to scroll to the right a bit to see all of the media players that have plunked themselves into your Sound Menu’s digital lap.

You’ll want to locate all of the players you want to keep and not select those. Or, vice-versa, find all the players you don’t want to keep and select just those. Removing the select the entire entry, so select from the first single quote to the comma following the menu item you want to remove.
Don’t remove any of the square brackets anywhere or any of the single quotes and commas on the media players you want to keep.
In my case, I want to get rid of the Rythmbox and Clementine media players, so I’m going to select those and cut (Ctrl + X) them:
 dconf-selected-remove
And there you go! This will take place immediately after you remove the entries and click outside of the text box, no reboot required!
However, there is a caveat. This only removes them so long as you don’t launch those programs ever again, which is extremely unlikely.

Solution for the caveat:

This is pretty simple, again, and it explains why you should have cut the text instead of just flat out deleting it. You’ll need to blacklist the programs, and hey! Guess what! Canonical thought this out and included another entry, just for that!

blacklisted-media-players option - Yay Canonical!

blacklisted-media-players option – Yay Canonical!

Double-click on the text box next to blacklisted-media-players and go to the end of the text entry box and enter a comma (,). Then, just paste in the media players you cut from interested-media-players:

Paste in what you cut previously and you're good to go!

Paste in what you cut previously and you’re good to go!

Again, click outside the text box and the changes will be made automatically. You won’t see any change to the menu at that point, but those players listed won’t ever be allowed to put themselves into the Sound Menu again!

The result of this menu slimming:

Much better - I may even be removing more later

Much better – I may even be removing more later

Conclusion

Not everyone is going to use this, but when I read about it (originally on OMG! Ubuntu!) it was a fix for something that had been bugging me for a while and I figured I’d do a write-up while I fixed it myself!

Leave a comment down below telling me what you thought of this post and/or about any things that have been bugging you about Ubuntu/Unity that you’d like me to post about!

Tagged , , , , , , ,

Ubuntu Tech Snippet #9 – Change out the Unity launcher icon

One of the great things about Ubuntu is that it is so customizable. And one of the most commonly customized features is the theme. I currently run the Numix Circle icon theme with the Numix system theme. You can see an example below:

themes

Numix Circle Circle Icon Theme w. Numix Window theme

This screenshot doesn’t really show off the circle element of the icon theme, but this next screenshot does:

unity launcher w. numix circle

Unity Launcher with the Numix Circle icon theme

As you can see, the application icons are circular (thus, Numix Circle.)

Yay, cool. Icons. What’s the Tech Tip?

If you notice at the top of the panel (second screenshot) the BFB (Big Freakin’ Button) isn’t the normal Ubuntu 14.04 version. It’s a flat, circular version that fits much better with the Numix Circle icon theme than the default:

unity launcher icon 14.04

Unity Launcher Icon – Ubuntu 14.04 Default

Obviously, the first, flat icon would (and does) fit with the theme a lot better. So, I went a-searching on how to change out the Unity launcher icon (aka, the BFB) and found one that fit.

There aren’t any automatic ways to do this. However, the manual process isn’t that complicated, involving just copying and renaming a few files.

The Process

To change out the BFB, open up either Terminal or the file browser. As a side-note, you’ll need the ability to run commands as root via sudo. If you don’t have these rights, this tutorial won’t work for you, sorry 😦 Also, these actions set the icon for the entire system, I have yet to find a user-specific way to do this.

I suggest using Terminal (Ctrl+Alt+T) and that’s what this tutorial will be via, though some people may find the file browser easier. If you do decide to use the file browser, you’ll need to launch it with root privileges, which you can do via pressing Alt+F2 and then entering

gksudo nautilus
If you are using the file browser and run into issues, please feel free to ask for help, I’ll try to help as I can.

In Terminal, you’ll need to get to the directory your replacement icon is in. If you downloaded it via Firefox or Chromium, it’s probably in your ~/Downloads folder.

Get to the folder that the icon is stored in via the command

cd WHATEVERFOLDERITSIN/FILEHERE.png

Make sure the icon you downloaded is an .svg or .png, as those tend to work the best. You can find the file’s location by finding it in the file browser and then right-clicking and selecting Copy.

Menu_081

Then, go into the terminal and type in sudo cp and then select Paste Filename

Menu_082

This will make the terminal look like this:

nate@excelion-Satellite-A105: ~_085

Without pressing enter, press Space and enter the following:

/usr/share/unity/icons/launcher_bfb_new.png

Your terminal should now look like this:

nate@excelion-Satellite-A105: ~_087

Go ahead and press enter, and you should be prompted for your password. Enter it in and then press enter again and it should instantly copy the file. If you’re get an error, make sure you put in all of the file names and paths correctly, maybe you entered cd where it should have been cp (those two are very easy to mix up, believe me, I do it all the time.)

Next, enter the following command:

sudo cp /usr/share/unity/icons/launcher_bfb.png /usr/share/unity/icons/launcher_bfb.bak && 
sudo cp /usr/share/unity/launcher_bfb_new.png /usr/share/unity/icons/launcher_bfb.png

This will create a backup of the original BFB (always, always, always make a backup when messing with system files) and then set your BFB icon as the default BFB icon.

Conclusion

Once you complete all of these steps without any errors, you should log out and back in again, and your new icon should be in place! If you have trouble understanding this tutorial, or get stuck somewhere, or get some strange error, comment down below and I’ll try my best to answer your question for you!

Tagged , , , , , , ,

Ubuntu Tech Snippet #8 – Copy and Paste in Terminal with the keyboard

What’s the big deal?

One of the many things that power users use to be more efficient on their PC is using the mouse as little as possible. The less clicking and movement, the better. At least, that’s how I prefer it. If I’m working on coding or writing (like this blog post, for example!) and I can keep both hands on the keyboard and not have to mess around, clicking on stuff, then I’m far faster.

Thus, this shortcut/tech tip was awesome when I found out about it! Normally, when using the Ubuntu terminal, one would have to right-click and then choose copy or paste. While this may not seem like that much to your average user, being able to lose that extra three/five seconds when doing lots of research, debugging, or simply following instructions on a tutorial, can be a big deal.

How doth this worketh?

This tech tip is quite simple, comprising of two different keystroke combos.

First up, is the terminal version of Ctrl+C. You simply tack on the Shift key in that sequence, so it is now: Ctrl+Shift+C. Basically, it’s the normal keyboard shortcut for copying, with the Shift key added on.

That’s right, it’s that simple. Normally, pressing Ctrl+C in a terminal window would terminate whatever program was being used. Adding that shift key makes it so that the terminal ignores the normal useage of Ctrl+C, and uses it in the GUI fashion.

And the paste shortcut is exactly the same. Simply take the normal paste shortcut Ctrl+V, and add the shift key after the Ctrl key: Ctrl+Shift+V.

Conclusion:

That’s all! While this may not benefit everyone, and it most definitely won’t, I know it will be useful to someone, if even just me.

Make sure to comment down below with any tips of your own you want to submit!

Tagged , , ,

Ubuntu Flavors 2nd Alpha Released

As many of you may know, the Ubuntu release cycle has various pre-releases along the way starting with first and second Alpha, moving on to first and then final Beta, and then the release candidate. The second Alpha release, which only the flavors take part in (not vanilla), has been released today.

Kubuntu, Lubuntu, Ubuntu GNOME, and Ubuntu Kylin all have been released as second Alpha, though Xubuntu sat this one out. You can now download the updated .iso files for testing from their respective pages, which I will link to later.

As with all pre-release software, it isn’t suggested you replace your current installation on any production machines, as there is still a chance there is a system-breaking bug in the code somewhere. It is also still in the Alpha phase, which means you will almost definitely run into some bug somewhere, so be prepared for bug testing and fixing if you do go ahead try this release out.

Although all releases gain from internal changes, each project has its own special changes. Here’s the most major ones:

Distribution-specific changes:

Ubuntu GNOME 14.10 Alpha 2 has the new GNOME shell 3.12 and two new apps, Weather and Maps, (Hey, that rhymes!) that come installed by default.

Ubuntu Kylin 14.10 Alpha 2 has a new version of the Ubuntu Kylin software center, 0.3.2, and now includes the open-source note-taking application Wiznote to the pre-installed defaults.

Kubuntu 14.10 Alpha 2 has an upgraded version of the KDE platform, the 4.14 beta, which is actually the third beta release in the series, but is only the first change to be made post feature-freeze, and is mainly focused on bug fixes and giving the interface a polish.

If you’re feeling really lucky and adventurous, there are images available for trying out the new Plasma 5 desktop.

and, last, but still the favorite for many people, Lubuntu 14.10 Alpha 2 is pretty mundane, just various stability improvements and some package updates.

Beyond Second Alpha

The next milestone will the the first Beta, which is due for arrival for all flavors (except Vanilla Ubuntu) on the 28th of August. Beyond that is the final Beta, on September 25th, which all flavors and vanilla Ubuntu take part in. And finally, Release Candidate on October 16th, which is the last pre-release before the official release of 14.10 on October 23rd, 2014.

OMG Ubuntu has a great graphic for showing the release schedule visually on their post.

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 , , , , , ,

I previously did a Tech Snippet on how to give Firefox native notifications, which you can read here, if you already haven’t. This post is similar to that in that it will show you how to set up native notifications on another application. However, this time it doesn’t require an addon/workaround, it’s a default (albeit un-enabled) setting, on everyone’s favorite open-source media player, VLC.

vlc media player with native notifications

VLC Media Player with Native Notifications – Just started playing a song

VLC is a great piece of software and has the reputation for playing just about anything you throw at it. It has a slew of features, half of which most users don’t even know exist, like screen-recording, audio/video conversion, play YouTube videos, subscribe to Podcasts, play Internet radio, apply effects – both Audio and Video, and even, for your geeky side, play videos in ASCII characters.

Enable Native notifications for VLC on Ubuntu

It’s really pretty simple, it only takes six steps to get this working. Maybe not as simple as installing an addon for Firefox, but still pretty easy. You won’t have to download anything or mess with hidden configuration files, just enter the domain of super-(not)-secret-settings.

First off with VLC open, click on the Tools menu and the select the Preferences menu item.

vlc settings

VLC Settings – Set to All

The preferences window will open, you should look to the bottom-left-hand corner for the Show settings radio buttons. They are labelled Simple and All and you need to change/make sure that it is set to All.

Now, there are a lot of settings you can change. So, instead of playing setting-sweep, we’ll just search for notify. That’ll bring up a much smaller list of results, of which you want to select the Control interfaces option. Then, check the LibNotify Notification Plugin checkbox.

vlc settings - control interfaces

VLC Settings – Control interfaces – Select LibNotify Notification Plugin

And that’s it!


You may notice that my pop up in the first screenshot has just the VLC logo (don’t let the Numix Circle icon through you off,) while the album art shows in the window. I think this may be because VLC isn’t minimized. It does appear if VLC is minimized.

Also, I’ve noticed that the notification will update if new information is found about the current song, and if you skip through several songs in a row the notification will show all of those notifications (changing every few seconds) until they are fully updated. This can be a bit annoying, though if you don’t skip through songs quickly you’ll be fine.

Ubuntu Tech Snippet #6 – Add native notifications for VLC

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 , , , ,
%d bloggers like this: