Saturday, February 28, 2015

Pi's and Install Configuration


My Raspberry Pi 2's have arrived!  Two of which are now running on the Internet.  I have three locations that I want to install and run them from.

New Raspberry Pi 2's
The initial installations will be running Raspbian (wheezy) serving simple Ham Radio Blog pages and running some HF Beaconing or Receiver code. See:

As a system administrator for large employers, I have installed and configured many Linux (UNIX) systems, I now have it down to quick trivial process.

For Raspberry Pi, First:

On the Raspberry Pi, I immediately execute the following commands:

$ sudo aptitude install ssh sshuttle
$ sudo aptitude install xosview htop tree wicd apache2 php5
$ sudo aptitude install vnc-server vnc-viewer

Note: if these are already installed, no harm. See the man pages as necessary.

Then I add users as necessary, with:

$ sudo adduser <user_name>

And then, add the appropriate admin "user_name" to the "sudo" group

$ sudo adduser <user_name> sudo


There are several things I DO NOT like about most default UNIX installations.

The first is the default command "prompt", which is typically a long string of characters that is; the user and system name, and the current working directory. The information is good, but the format is terrible. While in a directory way down in the directory structure, typing space on the displayed command line is very limited, and wraps around and is difficult to use. For example, change to the directory as shown:

$ cd /usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control/

This will result in a Command Prompt of:

pi@rbpi3 /usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control $ 

Note: there is little typing space on the line to the right of the "$". There is little wonder why most users get turned OFF with the Linux Command Line environment.

I personally like the same information, only in a different prompt format. For example (see below), the "date" command was entered at the prompt, and then executed, a new prompted followed:

rbpi3$ date
Sat Feb 28 12:32:40 PST 2015


In this example the prompt starts with a blank line, followed by the current directory, and then on the next line, the name of the system, followed by the "$" prompt. Regardless of the length of the current directory, the user starts typing at the same location on the command line (and with space to spare).

Modifying or Adding this type of Prompt is simple, but I have done it "too" many times, see shell script below.

PS1='\n$PWD\n\h\$ '

Also, I set the default "command line editor" to "vi", this allows the use of "vi" key commands to "edit the command line", and access "command history stack". As in; "h" and "l" (cursor Hop-left and Leap-right), "j" and "k" (history Jump-down and Klimb-up). Also, see shell script below.

set -o vi

I now add a simple script (/etc/bash.bashrc.local) to each system I install. It contains all of my favourite system modifications. The script is as shown below, details are not provided, but maybe you will find bits-of-it you would like also.

Note, depending on the initial OS installation, each user may want to remove the ".bashrc" and ".profile" from their home directory, or adopt parts of this script in their files. I like the system wide approach, an yet, while knowing that it is a little dictatorial.

# Usage in /etc/bash.bashrc
# Add the following two lines to the end of /etc/bash.bashrc, uncommenting the "test" line.

   # Start up /etc/bash_localrc for Local Stuff
   # test -f /etc/bash.bashrc.local && . /etc/bash.bashrc.local

# Local Startup files for Bash

   #echo "Start: /etc/bash.bashrc.local"
   #set -xv

   TZ='PST8PDT'; export TZ

# Show System Key

   # KEY="$(ssh-keygen -l -f /etc/ssh/"
   # KEY="${KEY#* }"
   # echo
   # echo "System Key: ${KEY% *}"

# Setup the default editor
   export EDITOR='vi'
   set -o "$EDITOR"

# Setup History
   shopt -s cmdhist histappend lithist execfail

# Add extended globing
   shopt -s extglob

# Set the Terminal Tab value
   # If this is an xterm set the title to user@host:dir
   case "$TERM" in
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'

# Prompt # for root, $ otherwise
   PS1='\n$PWD\n\h\$ '

# Local Aliases
   alias ll='ls -l '
   alias bdf='df '
   alias is='ps -ef | grep -v grep | grep -- '

   #set +xv
   #echo "End: /etc/bash.bashrc.local"

# Some Interesting Shell Stuff
   alias ralias='. $HOME/.alias'; # reread HOME aliases
   alias ...='cd ../..'
   alias ..='cd ..'

# Local GitHUB Aliases
# Git related
   alias gco='git checkout'
   alias gci='git commit'
   alias gst='git status'
   alias gbr='git branch'
   alias gls='gbr'
   alias gsbr='git show-branch'
   alias gmg='git merge --no-ff -v --progress'

   alias gad='git add'
   alias gdf='git diff'
   alias glg='git log'
   alias ggp='git grep'
   alias gpu='git push'
   alias gk='gitk --all &'
   alias gr='git rebase'
   alias gri='git rebase --interactive'
   alias gcp='git cherry-pick'
   #alias grm='git rm'

# End

I use "scp" to grab the script from a previously installed system.

Security Tip

If you going to put a Raspberry Pi on the Internet:
  • Remember to set a new passwd on the pi login
  • Do not open the ssh port 22 directly to the Internet, use a router to NAT and route another port to the Raspberry Pi. Note: if you DO open port 22, your system will be hammered by break-in attempts. Check your logs often.
  • Open only the ports that are necessary for your applications.
  • Also, I recommend doing something similar for port 80.

Be careful, the Internet is full of malicious hackers and "script kiddies" that will take over and eat your Raspberry Pi.

The following is a script that I wrote many years ago, as "taillogs", it "lists" and "follows" the system logs, showing new log events as they occur. I know it is somewhat cryptic, but does a nice job.

I saved this in a file: "/usr/local/lbin/taillogs".

Note: "/usr/local/lbin" is where I save all of my authored scripts.

#! /bin/sh
# Author: Eldon R. Brown,

        cd /var/log &&
        find . -type f -print |
        egrep -v "\.[0-9][0-9]*$|OLD|mbox|\.offset$" |
        xargs ls -tr |
        xargs file |
        sed -n '/ text/s/:.*//p' |
        xargs tail -n2 -f

# End

With this script, it is easy to check your system logs.

-- Home Page:

Minima - My Coding Efforts Resumes

After a long delay (due to surgery), I am returning my attention to my Minima Controller Alternate Tuning Method coding effort.

My previous (i.e. current) revisions as available on GitHub "radiono_erb" will remain as-is, with little or no further development for now.

I will "Fork" (GitHub speak for clone) my current Minima Controller GitHub Repro and give it a new name, currently the planned name will be "radiono_PNW_Exp". This Fork will initially be used to experiment with some new Minima Controller software and hardware strategies. Later, "radiono_PNW" will be published for general use. Note: PNW denotes Controller coding efforts that some Minima Builders around the "Pacific NorthWest" are considering. See:


One Goal is to reduce the front panel switch and knob foot print, that is, maybe reduce the number of switches and knobs, but at the same time increase the Controller functionality. Maybe this can be done by optimising the circuit and supporting code. The standard Minimal Volume control could be eliminated with a change of the circuit to add an I2C Quad POT. The Quad POT has four sections; 1) for volume control, the three others could be assigned other tasks, for example: 2) LCD backlight control, 3) LCD Contrast control, 4) and maybe a future Automatic Level or Gain Control (ALC or AGC). Others could be added as required or wanted.

My personal Goal is to reduce my Minima to a small hand-held unit by using very small SMT parts, yet, maintain compatibility with the majority of Builders using their Through-Hole and/or Ugly style of construction. I am a fan of Ugly Style of construction, but for my Minima project small(est) is better.

I plan to maintain circuit and software flexibility to potentially use and include a computer interface, via bluetooth or direct cable connections. Current (readily available) software programs could control and provide a familiar user environment for the Minima.

My overall Goal, which is similar to the main idea of the "Minima", is to; "Use Less Hardware, and Do More with Software".

-- Home Page:

Friday, February 20, 2015

Back to My Projects - Remote Desktop Protocal (RDP)

OK, it has been almost eleven weeks since my surgery - So now I can get back to; My Blog,  Electronic, Programming and Ham Radio Projects. I have been working on them, but in very short sessions.

The last few days I have been updating all of my Workstations to/with LinuxMint 17.1 (Cinnamon). I gave up on Ubuntu due to bloat and continual lack of support for problems that continued to bug me.

But LinuxMint (17.1) appears to have one of the same problems as Ubuntu - that is, Lack of "easy to use" Remote-Desktop-Protocal (RDP) configuration.

My desire is to connect and control other remote workstations and a few Raspberry Pi's from my Main Workstation. RDP is designed to display the remote Consoles on the main workstation, but people on the web have complained that after the last few system updates, it does not work as advertised, and I found that to be the case.

Disclaimer: There are many aspects of X Display, VNC and Remote Consoles that I do NOT know, nor understand. Information provided here has be found experimentally or after much online reading, your mileage may vary.

After many long hours of web research, trial and error, I now have a possible solution, which is really simple, once the magic is known. The solution is different for the remote Raspberry Pi (wheezy) than a remote LinuxMint (17.1) or newer Ubuntu system. The following examples assumes you have ssh, vnc-server and x11vnc installed as needed.

Using Remote Console of a Raspberry Pi is very easy, but several solutions are available depending on whether the Pi has a HDMI attached console or not, and whether or not there is an active logged in session.

Different methods are used to create, or use existing, Frame Buffers, and its address is denoted by the ":N" in the following examples. Any unused number can be used, but ":0" is normally reserved for the real graphic console (hardware monitor).

Pi systems "without" an HDMI attached Console (headless)

For Pi systems without an HDMI attached Console a "Display Frame Buffer" (fb) will not have been automatically created. The "vncserver" command creates a virtual Frame Buffer ":2", as seen in the following example. Also, note: ":2" is an alias for the value of the last two digits of "port number 5902".

Execute the following on the local system:

$ ssh remote_pi_sys_address 'vncserver -geometry 900x600 :2'
$ vncviewer remote_pi_sys_address:2

Note: the Geometry can be any size you like, I like 900x600 because it does not completely fill my local display.

Remote Virtual Console
Enjoy remote access to the PI, if the local window is deleted, it can be re-entered by re-executing the second command.

Pi systems "with" an HDMI attached Console, with Active Session

On remote system, run "Share Desktop", then on the local system execute:

$ vncviewer remote_pi_sys_address:0

Or, Pi systems "with" an HDMI attached Console, with Active Session

$ ssh -xCf -L 5900:localhost:5900 remote_pi_sys_address -l root \
        'x11vnc -q -auth /var/run/lightdm/root/:0 -display :0 -N'

$ vncviewer :0

Note: The required "-auth /var/lib/mdm/:0.Xauth" parameter is dependent on your remote_system and display manager used, which normally can be found via a remote "ps -efl | grep auth" command.

LinuxMint, Ubuntu and other Debian derived systems with RDP and VNC Console bugs.

See the Note above, regarding "auth". The following is accessing a remote LinuxMint system at the login prompt, supplying user name and passwd starts a normal remote session. Note: the displayed window will be the size and resolution of the remote monitor, scrolling may be necessary.

$ ssh -xCf -L 5900:localhost:5900 remote_sys_address -l root \
        'x11vnc -q -auth /var/lib/mdm/:0.Xauth -display :0 -N'

$ vncviewer :0

Remote Login
Note: failure can occur if the Local and Remote ports (5900) (as being requested here) are already in use, some of the following commands can be executed on the Local and Remote systems to help find port collision problem, killing the offending processes will free the port.

$ netstat -ta
$ lsof | grep 5900
$ ps -efl | grep 5900
$ ps -efl | grep vnc

The use of a "virtual" Console would be much better, one that allows you to specify the window size. But alas, it does not work as expected, the default configuration does NOT provide an interactive window manager.

This example does not work as well as it should.

$ ssh -xCf -L 5908:localhost:5908 remote_sys_address \
        'vncserver -geometry 900x600 :8'

$ vncviewer :8

I plan to continue to explore for a usable solution that provides a specified size of window for LinuxMint, Ubuntu and other Debian Derived systems. Currntly only the Raspberry Pi (wheezy) works as expected.

-- Home Page: