Sync Photos or Files over wifi Between Android and Linux with rsync and curlftpfs

I’ve had mixed success with transferring files between my Android phone and Linux computer. I’ve come to prefer using rsync for any file transfer; I grant that copying will often work, but the ease of double-checking that the transfer happened as planned, or of restarting it in the event of a failed transfer is worth a tiny bit of command line work for me. I’m assuming that you know how to install packages and know how to get a terminal.

Install an ftp server on your phone. I use File Manager HD. In File Manager HD, tap on ‘Tools’ at the top. Under File Transfer, click on ‘Transfer to PC.,’ than click ‘Start.’

Install rsync and curlftpfs on your computer.

Create a directory (“Phone” in this example; remember that Linux commands are case-sensitive.) on your computer and mount the phone storage there (Enter the IP address of your phone, displayed in File Manager HD.):

mkdir Phone
curlftpfs Phone/

Browse and drill down to your desired folder using cd, ls, etc. Don’t forget to tab for auto-complete and double-tab to see what your options are.

cd Phone

Use rsync to perform the sync. I use the -av options. See rsync manpage to help you. If you’re not familiar with rsync, make sure you understand the implications of omitting a trailing forward slash:

rsync -av /Phone/storage_0000-0000/DCIM/Camera/ ~/Pictures/2017-10-12/

After the transfer is finished, here’s the fun: up-arrow reruns the sync, and you can confirm with confidence the success of the transfer. There’s something strangely gratifying about seeing a ridiculously high speed-up (meaning the amount of time you saved over a straight re-copy):

sent 3,311 bytes received 12 bytes 2,215.33 bytes/sec
total size is 3,904,488,112 speedup is 1,174,988.90

Make sure to unmount the ftp directory before you quit (Otherwise, you may encounter nasty hangs when a command tries to look for the directory this mount points to):

fusermount -u Phone/

If you forget, this should get you out of the jam:

killall -9 curlftps


Posted in Uncategorized | 2 Comments

Mail Attachment Downloader on Linux

I’ve been looking for a way to download all attachments from gmail. I tried the Attachment Extractor for Thunderbird, but it apparently isn’t being maintained, and kept throwing error messages. I then found Mail Attachment Downloader for Windows. As of v. 3.1, this needs .NET 4.5 or higher. I naturally checked the AppDB at WineHQ and found a good how-to by scrolling down.

The key to successfully installing the .NET framework is to use Winetricks. However, to make this work on a 64-bit machine, you need to set up a 32-bit Wine environment, called a Wine prefix. Since I had some apps installed on the original 64-bit environment, I needed to set up a separate 32-bit environment. So if you need this, in a terminal window (adjusting your path appropriately):

$ WINEARCH=win32 WINEPREFIX=/home/akn/.wine32 winecfg

Then get Winetricks:

­$ wget

…and use it to install the framework and a core fonts package.

$ WINEARCH=win32 WINEPREFIX=/home/akn/.wine32 bash winetricks dotnet452 corefonts

Note: the installer will ask if you want to install the .NET framework. I initially hit ‘cancel,’ figuring that Winetricks would work its own magic. But I discovered that indeed this is the mechanism for installing the framework, so make sure you let the installer also install the .NET framework.

An important note here is that Wine must use the correct Wine prefix (It needs to be 32-bit.). Hence, the WINEARCH and WINEPREFIX variables on each command.

Now cd to the directory where you’ve downloaded the goal of this endeavor, and execute the following:

WINEPREFIX=/home/akn/.wine32 wine MailAttachmentDownloaderInstall.exe

I’m assuming that you will need to specify the WINEPREFIX each time, so I will set up a new shortcut for this eventually.

I’m testing this on a Linux Mint 17.1, 64-bit machine.

Posted in Uncategorized | Leave a comment

Automatically add suffixes to ordinal numbers in OpenOffice or LibreOffice

A number of responses on the Oo.o/LO forums regarding the question of adding ordinal notation to dates have said that the only way to add the suffixes st, nd, rd, and th to dates is with macros.  I searched for the same question in the Excel [ahem] arena and quickly came up with a solution:

CHOOSE(1*RIGHT(DAY(A1),1),"st","nd ","rd "),"th ")
&TEXT(A1,"mmmm, yyyy")

If you cut/paste, make sure to remove the carriage returns.  This ingenious bit of magic gives the date in this format: “30th June, 2001”.  Note that in the original post (at, there is a space missing after “th”; I have corrected that in my copying of his formula.

I needed a slightly different form to enter via a mail merge field into an official-sounding certificate: “30th day of June, 2001”.  After some trial and error, here is my solution:

=DAY($A$2)&IF(OR(DAY($A$2)={1,2,3,21,22,23,31}),CHOOSE(1*RIGHT(DAY($A$2),1),”st day “,”nd day “,”rd day “),”th day “)&TEXT($A$2,”of mmmm, yyyy”)

Obviously, adjust the cell reference to meet your needs.  In case you’re curious, trying to put ‘day’ into the final TEXT argument didn’t work because Calc read the ‘d’ as a date format, giving me “30th 30ay of June, 2001″.


Posted in Uncategorized | Tagged , , , | 1 Comment

Direct Cursor (aka, Shadow Cursor, Click-and-type) in Libre/OpenOffice

I have cluttered this post with verbosity in the hope that it will snag searches and save someone the frustration I have just experienced: trying to find a feature in LibreOffice or OpenOffice for which I don’t even have a name.  How can you search for it if you don’t know what it’s called?

The feature is one that I knew WordPerfect had, but I have used WP so rarely that I couldn’t remember what it was called.  I tried search terms like ‘insert text at mouse pointer,’ ‘move cursor to mouse pointer,’  ‘WordPerfect features LibreOffice,’ insert text blank page,’ insert text anywhere in document,’ and ‘insert text at cursor’ (well, duh…but I was desperate).  The search term that finally got me there–at the last hit on the second page (Who goes to the second page?!) was, ‘OpenOffice move cursor to mouse pointer position.’

So, for the few out there in my shoes: the feature that you are looking for is called Direct Cursor, and it can be found at Tools|Options| Writer|Formatting Aids. Check the Direct Cursor box, and enjoy.

This really is a useful feature, and one that I encourage you to try if you are unfamiliar with it.  I don’t think it will get in the way for me even when I don’t need it, and for the project I am currently working on (merging two handbooks, and needing to align/compare sections side by side in columns), it really is a grief-saver.

Thanks to Sunshine Coast Computer Club for the tip. Check this post for more details.

Posted in word processing | Tagged , , , , , , , | Leave a comment

Linux Mint 13 MATE, Synapse Launcher, and Missing MATE Applications

When I first started with Mint 13 MATE, I dug around for a launcher (e.g. Synapse, Launchy, Kupfer) to support my keyboard-driven approach to productivity.  I settled on Synapse, and have been generally satisfied with it.  But I’ve never been able to launch the MATE applications like Monitors, Screenshot, and Disk Usage Analyzer.  I’ve finally found a tiny Github Gist script that scratches this itch.

Copy this block of text into a new text file using your favorite text editor (You may need to adjust the tabs or delete whitespaces at the beginning of the lines.):


for file in $(grep -il "^OnlyShowIn=MATE;$" /usr/share/applications/*.desktop); do
  echo "patching $file"
  sed -e "s/OnlyShowIn=MATE;/#OnlyShowIn=MATE;/ig" $file > /tmp/tempfile.tmp
  mv -f /tmp/tempfile.tmp $file

Save the file with whatever name you wish; I called it

Make the script executable; one of the ways is:

 chmod 744

Run the script as sudo:

 sudo ./

Restart Synapse and enjoy!

Posted in Uncategorized | Leave a comment

Linux 13 MATE, XMonad and Marco

Well over a year ago, I decided to give Mint MATE a try, and have been quite pleased with the performance.  When I try a new version/distro, I usually mess around with eye-candy for a bit, then the novelty wears off, and I go back to my utilitarian bent, and trim down for performance.  I’m hooked on XMonad, so, since I’ve never delved deeply into Haskell or XMonad under the hood, how nicely the distro plays with XMonad out of the box is close to a deal-breaker.

Mint 13 MATE passes the test with flying colors.  I imported my xmonad.xs from my previous install on Ubuntu/Gnome 2, and everything just worked.  The only issue I had was very high CPU usage–high enough to make my SATA-modded ThinkPad T43 run very hot.

After a little digging, I came onto this how-to about changing window managers in MATE.  The relevant parts for this are:

  1. In a terminal, type
    mateconf-editor &
  2. In the configuration editor tree go to /desktop/mate/session/required_components/windowmanager and replace “marco” with “xmonad”

For more help, and a slightly different approach to changing the window manager, go here.

Posted in Uncategorized | Leave a comment

Banner and Poster Printing with Linux

After struggling to print a simple text banner onto multiple pages using LibreOffice and a variety of other solutions prompted by the conventional online search, I came across the simple command line utility poster. Save your original file as a postscript (.ps) file–which you should should be able to do from your print dialog in most distros with the “save to file” option. Note that this doesn’t work with .pdf files. You have the option of specifying what scale factor you want to use or the number of pages you want to output to. This command…

 poster -v -mLet -s4 >

…specifies that you want verbose output (-v), are using letter size paper (-mLet), and that you want the output scaled to 4 times the size of the original. Standard path syntax applies to the file names.

The following command specifies the number of pages to use for the output instead of a scale factor (in this case 3 pages wide and 3 pages high):

 poster -v -mLet -p3x3 >

To install from debian derivatives (Ubuntu, Mint, etc.):

sudo apt-get install poster

The man page will get you rolling without much ado.

If you have Adobe Reader 10 or later, supposedly you can do the same thing from Reader’s dialog. I couldn’t get v. 10 via repositories for my distro.

If you have an image file (.svg not included), PosteRazor should work for you. PosteRazor is also supposed to work for postscript files, but my install didn’t.

Posted in Uncategorized | Tagged , , , , | Leave a comment

autossh for Persistent Reverse ssh Tunnels

Here is my procedure for establishing a reverse ssh tunnel that maintains a persistent ssh connection (using autossh) through a firewall/router with no configuration needed on the target (host) machine. I use this to maintain an Ubuntu/Edubuntu LTSP server for a small school several hours from home. As long as the school’s internet connection is working, the target server is impervious to changes in network settings, even though neither the school nor the server’s IP addresses are static.

On boot-up, the target machine establishes an ssh tunnel to the remote computer (called ‘Home’ hereafter) from which I will be working. For additional security, this tunnel allows no execution on Home from the target computer. On Home, I can then connect via ssh to localhost on the specified port using the command at the end of the procedure below. Although I use this primarily for console work, this also works well using NoMachine NX (or FreeNX), an amazing remote desktop app that runs on ssh. These instructions are Ubuntu/Debian specific, but they should work with minor modifications on any Linux distro. This is designed to be cut-and-paste in case you are uncomfortable with a lot of command-line input. Don’t forget to take advantage of the auto-complete feature of the shell (tabbing completes commands or file paths; double-tab shows options where your input is ambiguous).

As always, very little of this is original with me. Credit goes to others who have posted the technical details in many forums and blogs. I’m only compiling them in a format that worked for me.

On the target/host machine:

ssh-keygen -t dsa

Output: (accept defaults, do NOT enter a passphrase):

Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/
The key fingerprint is:
a9:93:4e:89:22:f0:01:xx:xx:xx:xx:xx:xx:xx:xx:xx user@target
The key's randomart image is:
+--[ DSA 1024]----+
| |
| |
|. |
|.. . |
|... . S |
| |
|. |
| .o. o .. . E |
| ... . .o.. |

List the contents of your .ssh directory to be sure everything is as expected.

ls -l ./.ssh/ 

Output should be similar to this. Note the permissions on id_dsa.

total 36
-rw------- 1 user user 673 2010-08-20 15:43 authorized_keys2
-rw------- 1 user user 668 2010-08-26 07:06 id_dsa
-rw-r--r-- 1 user user 604 2010-08-26 07:06

Copy the (public key) to the Home computer

ssh-copy-id user@Home.local

Output (enter your password on home when prompted):

user@Home.local's password:

Now try logging into the machine, with

ssh 'user@Home.local'

and check the authorized_keys file to make sure we haven’t added extra keys that you weren’t expecting.

cat ~/.ssh/authorized_keys

Install autossh on remote:

sudo apt-get install autossh 

Set up the script:

sudo mkdir /etc/tunnel
sudo touch /etc/tunnel/
sudo cp .ssh/id_dsa /etc/tunnel/

Make sure permissions are tight:

sudo chmod -R 700 /etc/tunnel
sudo chmod 600 /etc/tunnel/id_dsa

Use the text editor of your choice; if you use Gnome/Gedit, run from Alt+F2:

gksu gedit /etc/tunnel/ 

If you use KDE/Kate:

kdesudo kate /etc/tunnel/ 

I use vim:

sudo vim /etc/tunnel/ 

Now insert this script into, obviously changing ‘Home’ to the name of the computer you will be using to work on the target machine ‘user’ to your user name. I ran this on a LAN before deploying the server (Did you know you can access a linux machine on your LAN using [hostname].local?):

set +e
SSH_OPTIONS=" -i /etc/tunnel/id_dsa"
# Always assume initial connection will be successful
# Disable echo service, relying on SSH exiting itself
#to test, use (check out man ssh for explanation of options:
autossh -vv -- $SSH_OPTIONS -o 'ControlPath none' -R 10101:localhost:22 user@Home.local -N > /var/user_sshlog.out 2> /var/user_ssh_error.out &
#once proven, use (and rem out previous command):
#autossh -f -- $SSH_OPTIONS -o 'ControlPath none' -R 10101:localhost:22 user@Home.local -N 2> /var/user_ssh_error.out

NOTE: the logs are a Big Deal! With autossh or ssh set to verbose output (-vv), you can glean an awful lot of info from the log.

Assign script to run on start-up in /etc/rc.local:

sudo vim /etc/rc.local

Append this at the end of your rc.local:

#Delay scipt in case the network needs more time to start running. Adjust as necessary.
sleep 10
#Start autossh script, output to log
/etc/tunnel/ > /var/user_tunnel.log 2>&1
echo autossh to Home.local started
exit 0

[Note(!): Make sure you have logged in to Home from Target as root before trying to run script (to get past the authentication question):]

$$ ssh user@Home.local


The authenticity of host 'Home.local (' can't be established.
RSA key fingerprint is f1:e9:5a:ea:58:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:6a.
Are you sure you want to continue connecting (yes/no)?

To test functionality without time-consuming reboots use:

sudo /etc/init.d/rc.local start

If you want to try again, make sure you kill all running autossh processes:
sudo killall autossh
Sometimes you may have to use:

sudo killall -9 autossh

Check your logs if you have problems:

cat /var/user_tunnel.log


cat /var/user_ssh_error.out

Now for the acid test. Login from Home

ssh -p 10101 user@localhost

If it works, you're done (unless you need to change the address in your when you move the target from your LAN to the off-site location).

For additional testing of the script from a user file before committing it to /etc/rc.local, try this:

cat /etc/tunnel/ >> ~/
chmod 700 

and modify the script, commands, and log paths as appropriate.

If your Home is behind a NAT, set port forwarding appropriately.

To use NX, configure your session similarly to this:

If you see typos or errors in strategy here, I'd be obliged if you would leave comments accordingly.

Posted in Uncategorized | 15 Comments