Yeah, We got Pi!
  page01| page02| page03| page04| page05| page06| page07| page08| page09| page10


install proper vi
sudo apt-get remove vim-tiny
sudo apt-get install vim mc screen

sudo update-alternatives --config editor # select vim as default


what is my Ip address again?
As your router is probably dynamically giving out IP addresses, it may change from time to time. As we are now headless, it is important to keep track of this change. This small python script will email you the Raspberry Pis IP address via gmail as soon as it is on the network. great!

#create a file called ipmail.py in your home folder and copy paste the following, adjust the 'to', 'gmail_user' and 'gmail_password' to your own accounts then save it. (please bear in mind that when sending mail from the same address, the mail will not show in your inbox. check 'all mail' and possibly set up a filter if required.)

#email IP address sent on boot
import subprocess
import smtplib
import socket
from email.mime.text import MIMEText
from datetime import datetime
now = datetime.now()
#
# Change to your own account information
to = 'myemail@myserver.org'
gmail_user = 'he-male@gmail.com'
gmail_password = 'rubadubdub'
#
smtpserver = smtplib.SMTP('smtp.gmail.com', 587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_password)
#
# Very Linux Specific
arg='ip route list'
p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
data = p.communicate()
split_data = data[0].split()
ipaddr = split_data[split_data.index('src')+1]
my_ip = 'Your ip is %s' %  ipaddr
msg = MIMEText(my_ip)
msg['Subject'] = 'IP is %s' % ipaddr + ' at ' + now.strftime('%T on %d/%m/%Y')
msg['From'] = gmail_user
msg['To'] = to
smtpserver.sendmail(gmail_user, [to], msg.as_string())
smtpserver.quit()

#make the file executable
sudo chmod +x ipmail.py

#edit start up and add the missing line from this example
sudo vi /etc/rc.local

 # rc.local
 #
 # This script is executed at the end of each multiuser runlevel.
 # Make sure that the script will "exit 0" on success or any other
 # value on error.
 #
 # In order to enable or disable this script just change the execution
 # bits.
 #
 # By default this script does nothing.
 # Print the IP address
 _IP=$(hostname -I) || true
 if [ "$_IP" ]; then
   printf "My IP address is %s
" "$_IP"
   python /home/pi/ipmail.py ##add this line
 fi
 exit 0


#reboot


Lets get up-to-date.
sudo apt-get update
sudo apt-get upgrade


change hostname

# also an option in raspi-config after apt-get upgrade
sudo vi /etc/hostname
sudo vi /etc/hosts
and reboot

see raspi-config


VNC


sudo apt-get install tightvncserver # install vnc server
vncpasswd #configure vnc password

start vncserver on boot
# become root
sudo su

# create file
> /etc/init.d/tightvncserver

# edit file
vi /etc/init.d/tightvncserver

#######################
export USER='pi'
eval cd ~$USER
case "$1" in
  start)
    su $USER -c '/usr/bin/vncserver :1 -geometry 1024x768'
    echo "Starting vncserver for $USER "
    ;;
  stop)
    pkill Xtightvnc
    echo "vncserver stopped"
    ;;
  *)
    echo "Usage: /etc/init.d/vncserver {start|stop}"
    exit 1
    ;;
esac
exit 0
######################

# set file perms
chmod 755 /etc/init.d/tightvncserver

# add to start up actions
update-rc.d tightvncserver defaults

# reboot & test.

I also often add the lines :-

su $USER -c '/usr/bin/vncserver :2 -geometry 800x600'
su $USER -c '/usr/bin/vncserver :3 -geometry 800x480'

which gives me other options on screen size for my laptop and smartphone. Each session takes a large bucket full of power so the fewer the better of course.

...BACK<-->MORE...

 
    
© 2025 Outanet Ltd.