Posts Tagged Linux

Set up an encrypted VPN using DD-WRT

DD-WRT is feature-rich alternative firmware for a large number of home router models. It adds a wonderful array of new features, VPN being one of them. This walkthrough will show you how to quickly and easily configure a PPTP VPN server on your DD-WRT-powered router, so you can connect to your home network from afar, create a secure tunnel so you can safely use a public Wifi point with your laptop, or secure your iOS or Android device.

Setting up the VPN Server

So here’s how to get started. First, you’ll need a build of DD-WRT supported by your router which includes the VPN software. If you’re doing this on an Internet connection which has an IP address that changes periodically (i.e. residential), you’ll likely want a Free DynDNS hostname to point to your IP address. You’ll also need a basic familiarity of networking.

For the remainder of this guide, I will assume your router’s internal (LAN) IP address is 192.168.1.1.

Start by going to http://192.168.1.1 and login to your router’s administration panel.

Go to Services > VPN and set PPTP Server to enable. After doing that, a few new options will appear. The only ones you need to set are Server IP, Client IP(s), and CHAP Secrets. Set them as follows:

Server IP: You can set this to your router’s LAN IP, i.e. 192.168.1.1

Client IPs: Set this to an IP range OUTSIDE your DHCP range (See Setup > Basic Setup to figure your DHCP range) A good example value would be 192.168.1.200-250 for clients to receive addresses within that range.

CHAP Secrets: This is the username/password combinations for your VPN clients. Format is:
username*password*
Example:
myname * mypassword *

Neither the username nor password can contain spaces, and must be all-lowercase.

You’re done with this page; Click Apply Settings.

Now go to Security > VPN Passthrough and make sure PPTP is set to Enabled. Click Apply Settings if you had to change the setting.

You should now be able to connect to your VPN using your Windows, Mac, or Linux computer by setting up a PPTP connection to your public (WAN) IP or hostname.

Troubleshooting

Can’t get connected? First, try setting up your connection to the router itself, using the LAN IP (192.168.1.1). If that works, then the VPN server is set up correctly; the problem is likely on the WAN side. Keep reading for suggestions. If you weren’t able to get connected, go back to the top and double-check your settings.

iOS-Specific changes

You may need to make the following settings adjustment if you are having trouble connecting specifically from your iOS device running iOS 4.3 or above. Go to Administration > Commands and paste the following in the box. Click Save Startup.

#!/bin/sh
echo "nopcomp" >> /tmp/pptpd/options.pptpd
echo "noaccomp" >> /tmp/pptpd/options.pptpd
kill `ps | grep pptp | cut -d ' ' -f 1`
pptpd -c /tmp/pptpd/pptpd.conf -o /tmp/pptpd/options.pptpd

(Source: DD-WRT Wiki)

If you can connect from the LAN side, but are still having trouble connecting from the WAN side, it’s likely your ISP or your gateway device (modem) is blocking the needed GRE protocol or the needed PPTP port or traffic. Contact your ISP for further assistance.

Do you have any experience or tips to share regarding VPN connections to a DD-WRT-powered router, or any suggestions in addition to the above? Please feel free to share them in the comments below. Thank you!

, , , , , , , , , ,

Leave a comment

Bash script to automatically sort photos into folders based on EXIF data for Ubuntu Linux

If you — like me — take a lot of digital pictures, you probably have a hundred folders full of images on your hard drive or external drives, and not nearly as sorted as you would like them to be. you have probably gotten to the point that you don’t know what’s in them or can’t find an image when you’re looking. I had around 10,000 images in over a dozen folders spanning 5+ years, and I had no intention of even trying to sort them manually :) So I wrote this script.

The following script was written in bash on Ubuntu Linux and automatically sorts your images into directories based on the date and time the photo was taken. How does it do this? By making use of the EXIF data your digital camera stores inside the image. The date and time the photo was taken is stored in that EXIF data. When an image doesn’t have EXIF data (such as when it was downloaded from the Internet, or taken from a camera that doesn’t support adding EXIF data), it will use the files last-modified time.

First, this should be run in the top-most directory of wherever your pictures are stored. If you have pictures/foldername/somepics/ and pictures/anotherfolder/morepics, run it from your pictures/ directory.

There are quite a few opportunities to improve this script — and some cautionary notes as well — marked within the script with FIXME tags. I’m already finished sorting my images, but anyone is welcome to contribute suggestions and improvements, which I’ll look into incorporating the next time I’m using this. You are welcome to include any suggestions or code improvements in the comments below using <code> and/or <pre> tags.
Usage: Copy the script into a file, editing options where appropriate, and save it. Make it executable and run it from the command line or window, from the directory where your pictures are stored. No command-line arguments. Back up your stuff first :)

UPDATE: Because WordPress keeps mangling this code, it has been moved to github, here.

Questions, comments, or feedback can be left in the comments below, or please use the contact form. Thank you!

, , , ,

Leave a comment

How to create a multi-page PDF from multiple image files using OpenOffice

I ran into a scan a document to send it via email. PDF format would have been preferable, but Windows Scan and Fax wouldn’t export as a PDF. Fortunately OpenOffice is quite capable of converting a multi-page document to a PDF, and does it quite easily. I had already scanned my documents, so I wanted something that would work with the existing scans. Side note: OpenOffice also works on Linux.

Here’s how I did it.

Step One:

Scan your pages into JPG files and save them where you can find them. In this example, I have four scanned JPG files which I want to convert into a single PDF.

Step Two:

Start OpenOffice Writer

Step Three:

Click Insert > Picture > From File

Step Four:

Select the image to insert. Repeat with any additional images you wish to insert. Once you have all your images inserted, go to…

Step Five:

Click File > Export as PDF.

Step Six:

Set the PDF export options. If you aren’t sure what to do here, accept the defaults as they are fine. Click Export and you’ll be prompted to give the file a name and save it.

That’s it!

, , ,

Leave a comment

Google Music vs iTunes Match

Google and Apple each brought their own services which allow users to upload their music library and stream it to their devices in the form of Google Music and iTunes Match, respectively. But how do those services compare?

Let’s take a side-by-side comparative look at some of the features:

FeatureGoogle MusiciTunes Match
Number of songs20,000 songs not purchased from Android Market25,000 songs not purchased from iTunes
PriceFree$25/yr
Supported devicesWorks on common browsers on Win / Mac / Linux / Android / iOS (1)Works on Win / Mac running iTunes; iOS devices supporting iCloud
SyncAutomatically sync music to Google Music using Win / Mac / Linux clientAutomatically sync music to iTunes Match using iTunes
Sync SelectionSelect which songs to upload using sync clientAll songs from iTunes library are synchronized.
Local StorageSave music to your Win / Mac / Linux / Android device for offline playbackSave music to your Win / Mac / iOS device for offline playback
UploadingEvery song must be uploadedMatching is performed prior to upload; Only unmatched songs are uploaded
Supported file formatsMp3, AAC (m4a), wma, flac, ogg (source)Same as iTunes
Excluded formatsNone24-bit audio; Bitrates under 96 kbps; File over 200MB (source)

(1) Although Google Music is reported to work on iOS devices, I can confirm it does work on iOS (iPhone), but only as the desktop site (which is clunky and requires zooming on an iPhone screen). The mobile site still shows I have no music in my library.

As you can see, Google Music is aimed at the Android crowd, while iTunes Match is aimed at the iOS crowd. However, a few of the major points in Google Music’s favor that I see are that it supports playback from a web browser, has a Linux client, and is free.

, , , , , , , , , , , ,

Leave a comment

How to run a game or other program in a new X session in Ubuntu Linux

To do this, CTRL-ALT-F1 to an open terminal, log in, and run:

xinit ./program -- :1

where program is the program file you want to start in a new X session. Assuming your normal X session is on :0 and appears when you CTRL-ALT-F7, your new one will spawn on CTRL-ALT-F8.

Questions, comments? Please feel free to leave them in the comments section below. Thank you.

,

Leave a comment

Easy Ubuntu data usage monitor

If you’re lucky enough to have a broadband card that works under Linux, your plan probably includes an “allowance” or data usage quota per month. You might be thinking how nice it would be to have a utility that tracks your data usage for the month (or other period) and gives you an easy-to-read report. You might also want said monitoring utility to have pre-built packages for Ubuntu / Debian.

NTM (Network Traffic Monitor) is what you want. As of this post the latest version is NTM 1.2.4.

Start by going to the NTM download site and downloading ntm-1.2.4.deb. Then double-click on it to install it using Ubuntu Software Center.

Once installed, you will find NTM at Applications > Internet.

Upon starting, it minimizes to the tray (next to the clock). You can open the interface by left-clicking the icon, and open the menu to access preferences by right-clicking the icon.

By default NTM monitors ppp0, which is the most likely interface that your broadband card will use. If you want to monitor a different interface, change that under the General tab. If you’re not sure what interface to use, run the following command:

ifconfig -a

This lists all interfaces and will help you locate your desired connection by IP / MAC and other info.

Also by default, NTM is configured with some other settings, such as auto-disconnecting after a data threshold has been reached (98MB by default), and disconnecting after a certain number of usage hours (30). These are likely too low for most mobile broadband users. Be sure to change these settings, under the Traffic, Time Slot, and Time tabs, to prevent unexpected disconnections.

Questions, comments, or other feedback? Please comment below. Thanks!

, ,

Leave a comment

Windows CHKDSK at boot cancelled by phantom keypress

When you run the Windows checkdisk (chkdsk) utility, it may report the disk being in use and recommend that you schedule chkdsk to run the next time the computer restarts, like the following screenshot shows:

chkdsk_schedule2

Windows can’t check the disk while it’s in use. Do you want to check for hard disk errors the next  time you start your computer?

However, doing that ran me into a very curious issue on Michele’s laptop: I would restart the computer, and get a message telling me to press any key within a few seconds to abort the scan if I so desired. Sorry, but I don’t have the exact message in front of me at the moment. Curiously it would abort itself after a second or two, stating that I pressed a key (which I did not). I’m fairly certain this is caused by this issue here: kernel atkbd.c: Unknown key released messages on Linux.

In order to make the chkdsk run without aborting due to that phantom keystroke, you have to set the delay to zero. To do this, boot back up into Windows, open an administrative-level command prompt, and run the following:

chkntfs /t:0

That will set the delay to zero seconds, effectively making it unable to be interrupted. Schedule the disk check again and reboot. It should run without issue.

Questions, comment, or any issues with the above are welcome in the comments section. Thank you!

, ,

Leave a comment

How to tell if your CPU supports virtualization under Ubuntu Linux

If you’re thinking of running a virtual machine, you should check first to see if your processor supports the VT extension. To do so, run the following command in a terminal.

cat /proc/cpuinfo | egrep '(vmx|svm)'

Having the VT extension allows improved virtual machine performance, as well as the ability to run 64-bit virtual machines. Note that some manufacturers have an option to enable/disable VT in the BIOS (which is usually set to disabled), so if you have VT extensions, you may want to check to make sure it’s enabled.

Further Reading: Linux Tip: How to Tell if Your Processor Supports VT

Sorry for the brief post, but it’s late and I’m just making a quick note of this. Note that this works in just about any Linux distro, not just Ubuntu.

,

Leave a comment

Batch converting audio files to MP3

If you’re converting a single file, http://media.io/ is a great online tool. However, for batch conversion, you’ll want to look at one or more of the following tools:

Windows:

dbPowerAmp is a great conversion utility http://www.dbpoweramp.com/dmc.htm

Ubuntu:

While dbPowerAmp says Linux is supported through Wine, I’ve found that soundconverter works wonderfully. To install it:

sudo apt-get install soundconverter

Next, just run it. You can select your input files and directories in the GUI. By default, soundconverter produces .ogg output. If you want mp3, simply select it in Edit > Preferences

, , ,

Leave a comment

How to monitor your microphone through headphones in Ubuntu

If you want to monitor your headphone feed, either for streaming it to the output or for mixing purposes, you’ll need to know your audio device names. Start with reading the latter half of this post to find your device names. Once you have the input and output device names, substitute them in the following command:

pacat -r --latency-msec=1 -d alsa_input.pci-0000_00_1b.0.analog-stereo | pacat -p --latency-msec=1 -d alsa_output.pci-0000_00_1b.0.analog-stereo

Note that the .monitor part has been removed from the playback device. Not much explanation to go on here, but it does the job and I’m writing this in a hurry.

Based on PulseAudio: Monitoring your Line-In Interface.

,

Leave a comment