Android development, compiling HTML5/JavaScript to .apk file, via Intel's XDK:

cd intel/XDK/ (projects saved in Home)
Click “Show in OS” to upload images in img folder.
Upload new build edits to XDK server!
View in Emulator, Save, Build, Download file, upload to Play Dev Console.  

.apk install ( to device):
export PATH=$PATH:~/android-sdk-linux/platform-tools
USB Debug mode and reboot phone
cd / to the platform-tools directory (in ~/, above), and run: adb devices to confirm
As user (not adb shell): adb install *.apk (cd or path to file)

For Android dev, push apps to phone via adb shell. 

Google App Engine:
Set path:

Change directory:
cd ~/APP/google_appengine/

Development server: python-math (localhost:8000; cntl c stops)

Update: update python-math

Download files: download_app -A python-math -V 1 ~/py-down


Add fonts from to Gimp:

cp file /usr/share/gimp/2.0/fonts

fc-cache -f -v

Batch rotate images with ImageMagick:

for file in *.png; do convert $file -rotate -90 rotated-file; done

FFmpeg usage Wiki. Constant rate .mp3 conversion:  
ffmpeg -i original.3ga -codec:a libmp3lame -b:a 128k convert.mp3 

Batch convert to .mp3:

for g in *.3ga; do ffmpeg -i "$g" -acodec libmp3lame -ab 128k "${g%.3ga}.mp3"; done

-b:a refers to constant rate .mp3; -q:a refers to VBR (see Wiki for sample rates). aac is also available.

Video screencast, without audio:

ffmpeg -f x11grab -s 1024x768 -r 25 -i :0.0 output.mp4

File management

ls  = list directory/folder contents
ls -a | egrep '^\.' = list hidden files (begin with '.')
cd  = change directory
mkdir  = make directory

rm -r  = remove directory/folder and contents files, recursively
cp file /destination
cp -r *.ttf /path/to/new = copy all .ttf extension files from current to new directory
mv = rename or move
cat = display text file

find /dir -name 'scooter*'  
ls -lt `grep -ril "frogonaut" GameDev`  = list files containing word, by date created, case-insensitive, recursively.

ls -l = list permissions
read = 4, write = 2, execute = 1
chmod 755 dir  for folders; 644 for files
chmod -R 755 dir = permissions for directory and files (don't use / here)
chmod u+x file = user executable; +x for everyone

Install and maintain

Go to Bootable USB Flash Drive Install

Use wget -c <url> to download .iso file; -c (continue) prevents download from breaking.

# sudo netselect-apt displays fastest server options :
deb jessie main contrib non-free
deb-src jessie main contrib non-free
deb jessie/updates main contrib non-free
deb-src jessie/updates main contrib non-free
# jessie-updates, previously known as 'volatile'
deb jessie-updates main contrib non-free
deb-src jessie-updates main contrib non-free
# jessie-backports, previously on
deb jessie-backports main contrib non-free
deb-src jessie-backports main contrib non-free
Update protocol:
apt-get update && apt-get dist-upgrade
apt-get autoremove && apt-get autoclean

Delete program:
apt-get remove packagename 
apt-get remove --purge packagename
removes dependencies

Synaptic package manager installs, removes ("complete removal" = purge) programs as well.

Quit frozen program:
pidof iceweasel
gives process id #
sudo kill # 

System info: 
uname -a (kernel version and processor)
free -m
df -h (disk usage, human readable)
cat /proc/meminfo
cat /proc/cpuinfo

/etc/vim/vimrc (Vim config file)

USB won't mount:
sudo fdisk /dev/sdf (check Disks interface)

1) Unless you are a Linux developer or enjoy troubleshooting, do not install Testing or Unstable; stay with Stable.
2) A clean .iso image (CD) install is always the best route; downgrading or upgrading versions will bring pain.
3) Older NVIDIA graphic cards do not support hardware acceleration and will not render WebGL graphics. Flash can be a problem, but between apt-get install flashplugin-nonfree, or Chrome's deficient PepperFlash, you'll find a way to watch YouTube.


Go to Server/Database, and Ethernet

Monitor your system: 
var/log messages monitor ssh activity
/etc/passwd, look for non-root users w/ UID = 0!
ps = processes
lsof -i = list open files
netstat -a = list incoming and outgoing network connection ports (great tool!); also  | more | less
netstat -tulpn -a = open local ports

ifconfig -a = local inet address and interfaces

Remote data interface:
wget downloads, cURL is bi-directional, login to APIs

wget -r -l1 -np -O news.txt = recursive, 1 level, no-parent

curl --data-urlencode --data-urlencode Passwd=xxxx -d accountType=Google -d source=cURL -d service=youtube

Authenticated Request: (delete spaces around auth key!)
curl --silent --header "Authorization: GoogleLogin Auth=providedKey..."

SSH/SCP see: VirtualBox

nslookup url = remote ip address
whois = website ownership

nmap (testing and diagnostic use):
nmap -O -sS ip   = remote system open ports and OS info
-Pn (if firewall), -A (aggressive), -V low verbosity, -n no reverse dns
-p80 ip  = listen to port  

ping -c 5 ip  = count 5x
telnet ip port #

Common Ports:
20, 21, FTP
22 SSH
23 Telnet
31 Warning 
53 DNS
79 finger
110 POP3
119 NNTP
161,2 SNMP
443 Secure Sockets

Disable Apache2 from starting at boot:
sudo update-rc.d -f apache2 remove
"      "                                    defaults (to restore)
Stop/start MySQL:
sudo service mysql start/stop 

MySQL config:

Troubleshoot Ethernet Connection:
Check System Tools < Network Tools < Network Device to see if Loopback Interface, not Ethernet, is configured. Add Ethernet (eth0) option, save, then select new Ethernet option (previously set to "Wired Connection") from network icon in desktop status tray. Network Devices is also useful for finding the IPv4 and IPv6 addresses of your provider, Ping and Whois utilities, and more.


grep finds; sed stream editor; awk formats text

grep to find “!” and “?” :
$ grep -F -e ! -e ? test.txt
-F = string pattern, -e = pattern

Insert text with sed: 
$ sed -i '$Objects upload now.' test.txt
-i = insert (default inserts before pattern or line 3), $ = last line,

Append text:
$ sed '/MatchPattern/orLine# a \ appendText' file.txt

Insert | every 20 characters, to all .txt files in directory: 
$ sed -i 's/.\{20\}/&|/g' *.txt
s = substitute pattern space, g = hold pattern space, . = match any single char.

Replace first line:
$ sed '1 c\ Replacement' file.txt
c = replace

Delete character:
$ cat test.txt | tr -d '|' > test1.txt
tr = delete ("translate")

Substitute text with awk:
awk '{ gsub("e","g",$2); print  $2}' sed1.txt > sed2.txt
original, substitution, place in text (columns or words); for entire file, use $0

Sort most common words from a YouTube video's Comments, using sed stream editor:

wget -O - \
| sed -e 's/<[^>]*>//g' | tr -cs A-Za-z\'  '\n' \
| tr A-Z  a-z | sort | uniq -c | sort -k1,1nr -k2 | sed ${1:-200}q > conan.txt  

Remove content between tags, ^ = beginning of pattern, * = sequence preceding character (like a wildcard), translate non-letter characters to newline, translate upper to lower case, uniq = omit repeats, -c = count, sort -k1, 1nr -k2 = in descending, then ascending order, q = quit process.

or sort words from file: 

cat p1nesap.txt \
| sed -e 's/<[^>]*>//g' p1nesap.txt | cat p1nesap.txt | tr -cs A-Za-z\'  '\n' \
| tr A-Z  a-z | sort | uniq -c | sort -k1,1nr -k2 | sed ${1:-1000}q > p1nesap2.txt

./ (execute file in terminal)   

awk version:

wget -O - \
| awk '{ gsub(/<[^>]*>/,"")                # remove content between tags, replace with space
$0=tolower($0)                           # convert text to lower case
gsub(/[^a-z]]*/," ")                      # remove non-letter characters, replace with space
for (i=1;i<=NF;i++) a[$i]++       # save each word in array a, and sum it.
}END{for (i in a) print a[i],i|"sort -nr|head -500"}' > output.txt  

Remove HTML tags: 
sed -e 's/<[^>]*>//g' file.xml
awk '{gsub(/<[^>]*>/,"")};1' file.xml


Go to SSH and SCP 

First, install build-essential module assistant, then m-a prepare. Also, installing Linux headers linux-headers-$(uname -r) might be a good idea. Next, install VirtualBox via command line, then download (with wget -c) your .iso of choice. Install your "Guest" OS in VirtualBox through the CD icon; browse to your downloaded .iso file.

Wheezy includes Guest Additions functionality (mouse control, windows resizing), but I didn't see evidence of the file, so after installing flashplugin and still not being able to load YouTube videos, I clicked Device and downloaded and installed the updated Guest Additions from the prompt. Most users seem to suggest downloading and mounting Guest Additions via command line, but this wasn't working for me. 

If VirtualBox isn't installing correctly, try:
sudo apt-get remove virtualbox-dkms 
sudo apt-get install virtualbox-dkms 
dkms = dynamic kernel module support. Using sudo (not su) with this command seems important, as the user account needs to have privileges to use VirtualBox.

To prevent VB starting at boot, edit /etc/default/virtualbox config file to: LOAD_VBOXDRV_MODULE=0. The vboxdrv module may have to be loaded manually every time; check alert dialog: sudo modprobe vboxdrv.

Network Settings: 
For independent machine, not networked to Host, use NAT
To SSH to/from Host, use Bridged Adapter.
After changing Network settings: sudo service ssh restart or /etc/init.d/sshd restart and service network-manager restart on Guest and Host. 

Secure Shell (SSH):
ssh -v remoteUserName@IP
Secure Copy (SCP):
scp file remoteUserName@IP:Remote/Path

Use authentication keys or a strong Guest machine password for SSH.