Transferring files between an Android device and a Linux system via USB cable


Some newer Android devices do not offer regular USB-drive like connection. Instead they use the MTP protocol.

In order to easily transfer files between your Android device and your favorite Linux distro (yes, Debian!) with a USB cable, via MTP transfer protocol :
As root

apt-get install jmtpfs

Make sure your regular user belongs to the “fuse” group

usermod -a -G fuse username

(you need to logout and login again)

Connect your Android device to your computer with your USB cable, then as a regular user :

mkdir -p ~/Android_transfer
jmtpfs Android_transfer/

After a few seconds, files on the Android device should appear in the mount point 🙂

To properly unmount :

fusermount -u ~/Android_transfer

For more info, as always :

man jmtpfs
jmtpfs -h

Wireless Ad-hoc server script

Today, a quick and dirty Bash script which will allow you, for instance, to quickly serve files from your laptop to other wireless devices (Warning here, we use WEP encryption which is not secure).

# Wireless Ad-hoc script
# /
# This script will setup your wireless adapter in Ad-Hoc mode
# and start a DHCP server so that other peers (eg. an Android device)
# can receive an IP address and connect to your computer.
# After that, you can start a minimal webserver (darkhttpd for example)
# so that you can quickly share some files with minimal effort!
# This script must be run as root.
# Tested on Arch Linux.
# Some adaptations may be needed for other Linux systems.
# Requirements: iw, ifconfig commands, and dnsmasq.
# WARNING : WEP encryption is weak security :)

# User variables

# Main program
echo -n "Stopping wireless connections (if any)... "
# adapt to your system; I use wicd
systemctl stop wicd && echo "OK"
# for networkmanager
#systemctl stop NetworkManager

echo -n "Starting wireless Ad-hoc mode... "
ifconfig $mywlan down || exit 1
iwconfig $mywlan mode ad-hoc || exit 1
iwconfig $mywlan essid $myessid
iwconfig $mywlan channel $mychan
[ "$mywepkey" ] && iwconfig $mywlan key $mywepkey

ifconfig $mywlan $myip
ifconfig $mywlan up && echo "OK"
echo -n "Starting DHCP server ... "
dnsmasq --dhcp-range="$mydhcprange" && echo "OK"

echo "--------------------------------------"
echo "ESSID : $myessid"
[ "$mywepkey" ] && echo "WEP KEY : $mywepkey"
echo "This computer's IP : $myip"
echo "--------------------------------------"

# debug
#iwconfig $mywlan

while true; do
echo -n "Enter 'q' to quit. "
read value
if [ "$value" == "q" ]; then

echo -n "Killing DHCP server... "
killall dnsmasq && echo "OK"
echo -n "Killing wireless... "
# restoring the wlan interface to "default" mode
ifconfig $mywlan down
iwconfig $mywlan mode managed
iwconfig $mywlan essid off
iwconfig $mywlan key off
echo "OK"
echo "Wireless Ad-hoc mode terminated."
# now you can restart your network manager

exit 0