Linux / Raspberry Pi Tips:
revised
03-03-2016

Set Timezone from command line
sudo dpkg-reconfigure tzdata

Show time
sudo date

Enable FTP server on Pi

http://www.instantsupportsite.com/self-help/raspberry-pi/raspberry-install-ftp/

If you transfer a shell script from one machine to another it may not work even after chmod 755 - if so try this fix:
sed -i 's/\r//' filename
this command fixes the end of line/file markers and allows it to work

To keep an SSH session alive use "screen" - see: http://www.geeklk.com/2012/07/keep-ssh-session-alive-after-disconnecting/
Very useful when starting a Python session from SSH and then disconnecting  - tutorial here: http://raspi.tv/2012/using-screen-with-raspberry-pi-to-avoid-leaving-ssh-sessions-open
...or....
nohup python 8House300.py &      keeps the process running after logout
stop with    killall python 8House300.py

Using Knoppix to rescue a dead Windows PC 

Using Knoppix to clone a hard drive

Installing Knoppix on a hard drive (use the 3.3 and above:  sudo knoppix-installer     after Ctrl-Alt-F1 to get to root)

Troubleshooting tips (screen resolution change on boot, etc)

Automatically login - see:http://elinux.org/RPi_Debian_Auto_Login

to Kill a process do the following:
    use    ps -ef   to list all processes - note the one you want to kill and its PID
    type   sudo kill -9 whateverthePIDis

Wireless setup- notes based on this web page: http://blog.enrii.com/2012/11/13/configure-wep-wireless-on-xbian-xbmc/

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback
#iface eth0 inet dhcp
#auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-essid main
wireless-key abcdeabcde

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#wireless-power off
#iface default inet dhcp

#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

iface eth0 inet static

address 192.168.1.78
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

 

 

 

Sending mail from command line on Pi

http://blog.a-netz.de/2012/12/sending-mail-with-the-raspberry-pi/ has good instructions

this works well, too  http://stackoverflow.com/questions/64505/sending-mail-from-python-using-smtp
a sample Python file is here - it works....
linux/mailtest2.py

Testing for new IP routine is called with this argument  os.system("sudo python IP_New_Email.py 1")
File that is called is
IP_New_Email.py

web page it calls contains only this code
<?php echo $_SERVER['REMOTE_ADDR']; ?>
which returns only the bare IP address -

my /etc/ssmtp/ssmtp.conf  looks like this:

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=outgoing.verizon.net

# Where will the mail seem to come from?
rewriteDomain=outgoing.verizon.net

# The full hostname
hostname=raspberrypi

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

# Use SSL/TLS before starting negotiation
#UseTLS=Yes
#UseSTARTTLS=Yes

# Username/Password
AuthUser=davebodnar
AuthPass=pwpwpwpw

 

Miscellaneous commands that I always forget:

nano cut / paste block
Alt + A = Mark (or select) text
Alt + 6 = Copy text in the buffer
Ctrl + U = Past the text from the buffer

ifconfig - get IP address

iwconfig - wireless network info

sudo raspi-config - bring up Raspberry Pi config menu

Halfacree, Gareth; Upton, Eben (2012-08-30). Raspberry Pi User Guide (Kindle Location 1632). John Wiley and Sons. Kindle Edition.

rm  -  remove file

df - h  or  df -k  - free disk space

rmdir  - remove directory

ls -lh    - show directory info - detailed
ls -lt  - show directory sorted by time
ls -ltr  - same but reverse order
ls -ltS   -sort by size
ls -ltSr  - same but reverse order

top   - q to exit - shows resources being used on system

Lots more:

http://www.thegeekstuff.com/2010/11/50-linux-commands/

http://ss64.com/bash/

http://www.vmts.net/article/linuxcommand.htm