Send email in Linux command line.

Working in raspbian os.

$ sudo apt-get install ssmtp
$ sudo apt-get install mailutils

# Added these lines and commented out any lines that were duplicates
$ sudo nano /etc/ssmtp/ssmtp.conf

AuthUser=your_email@gmail.com
AuthPass=Your-Gmail-Password
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES

# send email
$ echo "This is a test" | mail -s "Test" your_email@gmail.com

# troubleshooting errors
$ taif -f /var/log/mail.log

resources
http://www.cyberciti.biz/tips/linux-use-gmail-as-a-smarthost.html
http://tecadmin.net/bash-mail-command-not-found/

Connect to wifi in the command line

The wifi access point security will determine the way you connect to it.

If WEP (less secure)
http://askubuntu.com/questions/294257/connect-to-wifi-network-through-ubuntu-terminal#answer-294320

If WPA
http://askubuntu.com/questions/138472/how-do-i-connect-to-a-wpa-wifi-network-using-the-command-line#answer-138476

Configuring WPA
# view enabled connections
$ ifconfig

# view enabled and disabled connections
$ ifconfig -a

# To find out the name of your wireless card device. Look at the row that has some information in it, not ‘no wireless extensions’. In this example its wlan0.
$ iwconfig

# find wireless/wifi access points
$ sudo iwlist scan
$ nmcli dev wifi list # source
# an alternative can be “wavemon” if installed on your machine

# Add wifi network ssid and password
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# add to the bottom of file

network={
 ssid="your_wireless_ssid"
 psk="your_wireless_password"
}

# wpa_supplicant.conf is being included in /etc/network/interfaces. Another option would be to edit interfaces file directly. Example Below.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0

iface wlan0 inet dhcp
	wpa-ssid "your_wireless_ssid"
	wpa-psk "your_wireless_password"

# restart connection. This is an alternative to restarting the computer
$ sudo ifdown wlan0
$ sudo ifup wlan0

# you should now see an ip address under “inet addr:”
$ ifconfig wlan0

# test internet connection
sudo ping google.com

# useful commands
# 10 Useful “IP” Commands to Configure Network Interfaces

$ ip addr show
$ ip route show

tag:
wireless interface, network, raspberry pi

Create a router/Access Point for wifi

followed these instructions
https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software

Ran these commands
1 sudo apt-get update
2 sudo apt-get install hostapd isc-dhcp-server
3 sudo nano /etc/dhcp/dhcpd.conf
4 sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.orig
5 sudo nano /etc/dhcp/dhcpd.conf
6 sudo nano /etc/default/isc-dhcp-server
7 sudo ifdown wlan0
8 sudo cp /etc/network/interfaces /etc/network/interfaces.orig
9 sudo nano /etc/network/interfaces
10 ifconfig
11 sudo ifconfig wlan0 192.168.42.1
12 ifconfig
13 sudo nano /etc/hostapd/hostapd.conf
14 sudo cp /etc/default/hostapd /etc/default/hostapd.orig
15 sudo nano /etc/default/hostapd
16 sudo cp /etc/sysctl.conf /etc/sysctl.conf.orig
17 sudo nano /etc/sysctl.conf
18 sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”
19 sudo nano /etc/sysctl.conf
20 sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
21 sudo iptables -A FORWARD -i eth0 -o wlan0 -m state –state RELATED,ESTABLISHED -j ACCEPT
22 sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
23 sudo iptables -t nat -S
24 sudo iptables -S
25 sudo iptables -L
28 sudo sh -c “iptables-save > /etc/iptables.ipv4.nat”
29 sudo nano /etc/network/interfaces
30 wget http://adafruit-download.s3.amazonaws.com/adafruit_hostapd_14128.zip
31 unzip adafruit_hostapd_14128.zip
32 sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.ORIG
33 sudo mv hostapd /usr/sbin
34 sudo chmod 755 /usr/sbin/hostapd
35 sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
40 sudo raspi-config
41 sudo reboot
43 sudo service hostapd status
44 sudo service hostapd start
45 sudo service isc-dhcp-server start
46 sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
47 sudo service hostapd status
48 sudo update-rc.d hostapd enable
49 sudo update-rc.d isc-dhcp-server enable
50 sudo mv /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service ~/

created an image backup called
2016-01-13-rpi_access_point_router_raspbian-jessie.img

additional help

Turn Your Raspberry Pi Into a WiFi Hotspot with Edimax Nano USB EW-7811Un (RTL8188CUS chipset)


https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=75060
https://seravo.fi/2014/create-wireless-access-point-hostapd

Browse Anonymously with a DIY Raspberry Pi VPN/TOR Router

https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/

Vagrant miscellaneous

to sync the /var/www folder with the host computer
1. edit Vagrantfile and add this line config.vm.synced_folder “www/”, “/var/www/”
2. create a folder called www where the Vagrantfile is located
3. read up on some resources if need be
https://docs.vagrantup.com/v2/synced-folders/basic_usage.html
http://stackoverflow.com/questions/19231895/how-to-share-a-folder-created-inside-vagrant

enable symlink on a shared/sync folder
1. follow these instructions http://www.ahtik.com/blog/fixing-your-virtualbox-shared-folder-symlink-error/
2. ran these command in windows cmd
– cd C:\Program Files\Oracle\VirtualBox
– VBoxManage.exe setextradata local.puphpet17 VBoxInternal2/SharedFoldersEnableSymlinksCreate/node 1
– VBoxManage getextradata local.puphpet17 enumerate
should see ‘Key: VBoxInternal2/SharedFoldersEnableSymlinksCreate/node, Value: 1’
3. Run vagrant as windows administrator

Nodejs troubleshooting

I kept getting many errors in npm install

seems that the error comes from symlink not being able to work in vagrant
partial solution: run ‘$ sudo npm install –no-bin-links’
The reason you are getting errors is because you are in vagrant synced folder. If you go to a non synced folder the error will not occur. You can also change vagrant to accept symlink on shared/synced folder. Instructions at http://baligena.com/vagrant-miscellaneous/

Tried to run “$ npm run build” for use in browserify but got this error.

/usr/bin/env: node: No such file or directory
npm ERR! weird error 127
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0

The solution was to run
$ sudo apt-get install nodejs-legacy
source: https://laracasts.com/discuss/channels/general-discussion/npm-installer-with-gulp-weird-error-127

If you don’t have the latest version of npm errors may occur when installing packages
# check version in server. npm current version is shown in https://en.wikipedia.org/wiki/Npm_%28software%29
$ npm -v
# install latest version. you must run this twice I dont know why.
$ sudo npm install -g npm@latest