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 |
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
Then:
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:
/usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control
rbpi3$ date
Sat Feb 28 12:32:40 PST 2015
/usr/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Control
rbpi3$
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
PATH=/usr/local/lbin:$PATH
# Show System Key
# KEY="$(ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub)"
# KEY="${KEY#* }"
# echo
# echo "System Key: ${KEY% *}"
# Setup the default editor
export EDITOR='vi'
set -o "$EDITOR"
# Setup History
HISTSIZE=10000
HISTCONTROL=ignoreboth:erasedups
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
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
;;
esac
# 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, eldonb@ebcon.com
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: https://WA0UWH.blogspot.com