Mount usb linux command line

# ways to find flash drive
dmesg | tail
sudo fdisk -l
lsusb
ls /dev/sd*

# make a directory to mount the usb
sudo mkdir /media/usb

# mount usb
# to grant permission to all when mounting add umask flag. For only root omit flag.
sudo mount -o umask=000 /dev/sda1 /media/usb

# if error mount: unknown filesystem type 'exfat'
sudo apt-get install exfat-fuse exfat-utils

# mount on every boot
# determine the partition/filesystem type for proc column
sudo blkid /dev/sda*

# edit file
sudo nano /etc/fstab

proc            /proc           proc    defaults          0       0
/dev/mmcblk0p1  /boot           vfat    defaults          0       2
/dev/mmcblk0p2  /               ext4    defaults,noatime  0       1
/dev/sda1       /media/usb      exfat   defaults
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

# unmount
sudo umount /dev/sda1

# resources
How to Mount USB Drive on the Raspberry Pi

# tags
ntfs fat32 ext4

Sync server time and date

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

sources:
http://askubuntu.com/questions/254826/how-to-force-a-clock-update-using-ntp#answer-256004
https://www.digitalocean.com/community/tutorials/how-to-set-up-timezone-and-ntp-synchronization-on-ubuntu-14-04-quickstart
https://help.ubuntu.com/lts/serverguide/NTP.html

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
# 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/

FTP Server Setup

In ubuntu 14.04

How to setup FTP server on ubuntu 14.04 ( VSFTPD )

In ubuntu 12.04

mkdir /home/user/ftpfiles
sudo su
apt-get install vsftpd
cp /etc/vsftpd.conf.bak
nano /etc/vsftpd.conf
groupadd ftpusers
useradd -g ftpusers -d /home/user/ftpfiles newusername
passwd newusername
chmod 775 /home/user/ftpfiles
chown root:ftpusers /home/user/ftpfiles
chmod a-w /home/user/ftpfiles
service vsftpd restart
ftp localhost

errors:
500 OOPS: could not read chroot() list file:/etc/vsftpd.chroot_list
– /etc/vsftpd.chroot_list file doesnt exist created it
– touch /etc/vsftpd.chroot_list

500 OOPS: vsftpd: refusing to run with writable root inside chroot ()
– chmod a-w /home/user/ftpfiles
– https://www.benscobie.com/fixing-500-oops-vsftpd-refusing-to-run-with-writable-root-inside-chroot/

– resource:
– https://www.youtube.com/watch?v=BTGBE1Ae1LA

Virtual Box Internet Issue

The problem:
unable to connect to internet
$ ping google (doesnt work)

What might cause the problem:
Added the ‘Host-only Adapter’ network to the virtual box

Solution:
remove static ip from /etc/network/interfaces (changed it back to dynamic)

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

#auto eth0
#iface eth0 inet static
#       address 192.168.0.108
#       netmask 255.255.255.0
#        network 192.168.0.0
#        broadcast 192.168.0.255
#        gateway 192.168.0.1

remove the 2nd network and only stayed with the 1st one (Bridged Adapter)

reflesh the MAC address (not sure if this help)

reboot

edit /etc/network/interfaces changed back to static ip address

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp

auto eth0
iface eth0 inet static
        address 192.168.0.108
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1

OR
edit using the GUI
http://askubuntu.com/questions/338442/how-to-set-static-ip-address#answer-338855

operating system:
Linux cowboy 3.12-kali1-686-pae #1 SMP Debian 3.12.6-2kali1 (2014-01-06) i686 GNU/Linux

Kali Linux Virtual Box


from video with minor changes relative to my computer

view-1 / main menu
Click new

view-2
name: kali linux
type: linux
version: debian

view-3
1025mb in ram (check the minimum on site)

view-4
create a virtual hard drive now

view-5
VDI (virtualBox Disk Image)

view-6
Dynamically allocated

view-7
20.23 GB (check website for minimum)

the partition is created
in main menu
click “green arrow” / “start”

browse for kali-linux-1.0.6-i386.iso
click start

kali linux start screen will appear and now you start installing

at the end
you will get an error to fix
so go to settings -> system -> processor and check “enable PAE/NX”

Changing Keyboard Layout

Just booted up raspberry pi but had an issue with the keyboard layout not being as I’m used to here in America, I believe the default is UK. So here is how I was able to change it and what I changed it to. (works with linux too)

$ sudo dpkg-reconfigure keyboard-configuration

settings:
generic 105 – (intl) PC
English (US)
English (US)
the default of the keyboardlayout
no compose key
configuration keyboard-configuration — no (x server termination)

resources
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=91&t=18906