Here are a couple of problems I’ve seen with newly created instances of virtual servers, and their solutions.
When running apt-get upgrade for the first time, many errors appeared regarding an “unset” locale.
My locale is US/English, so the fix was:
sudo locale-gen en_US en_US.UTF-8
Errors regarding unknown or missing keys.
[MISSINGKEY] is the string in the error message.
apt-key adv --recv-key --keyserver keyserver.ubuntu.com [MISSINGKEY]
Nicely illustrative explanation of trailing slash behavior in rsync:
- An rsync source path with no trailing slash will recreate the top-level directory of the source at the destination.
- With a trailing slash the subdirectories of the source path are created directly in the target directory.
Usually, I just use rsync to keep files in sync, but this runs through all of the files.
Starting on server #1, inside the rancid base directory (/var/lib/rancid for me),
with $LIST_OF_GROUPS from /etc/rancid/rancid.conf,
using ssh with port 2022 ,
$REMOTE = DNS name of remote server :
for i in $LIST_OF_GROUPS ; do echo $i ; rsync -n -i -e 'ssh -p 2022' /var/lib/rancid/$i/router.db $REMOTE:/var/lib/rancid/$i/router.db ; done
To run vimdiff to see or manually sync a single file:
vimdiff /var/lib/rancid/ABC/router.db scp://$REMOTE_SRV:2022//var/lib/rancid/ABC/router.db
Note that this uses 2022 as an alternate ssh port for scp (as called by vimdiff).
The automated sync operation is actually done from jenkins. This is probably not the ideal formula, but for self-documnetation purposes, here it is:
crontab on server1 to remote server2. (REMOTE_SRV = server2′s DNS name)
to copy files from server1 to remote server2.
@daily export JENKINS_HOME=http://JENKINS.brunhilda.edu:8080 ; java -jar /usr/share/jenkins/external-job-monitor/java/jenkins-core-*.jar "rancid_sync srv1 to srv2" rsync --exclude 'configs' --exclude 'bin' --exclude 'logs' --exclude 'CVS' --compress --itemize-changes -Cavh -e 'ssh -p 2022' --checksum $REMOTE_SRV:/var/lib/rancid/ /var/lib/rancid/
vim syntax highlighting
” `:set list` will show all whitespaces as a character. Everything but a space will look different than its normal state, which means that if you still see a plain old space, it’s really a plain old space”
With the GNU
date command line utility.
Print time as seconds from the epoch, or, “
seconds since 1970-01-01 00:00:00 UTC” :
$ date +%s
Convert timestamp or epoch dates into familiar day and time :
$ date --date='@1365439166'
Mon Apr 8 11:39:26 CDT 2013
This works under Debian/Ubuntu, and may work under other Unix/Linux systems.
du -sh * | sort -h
Output should be sorted like this (K, M, G for Kilobytes, Megabytes, Gigabytes):
1.2G VirtualBox VMs
Because I always forget the syntax:
tar cvf - tftpboot/ | ssh firstname.lastname@example.org "cd /home/userone/store_old/ ; tar xvpf - "
There are many variations, and this one includes the verbose flag.
rem10> show system uptime
Current time: 2013-02-13 13:40:10 CST
System booted: 2013-02-13 03:07:33 CST (10:32:37 ago)
Protocols started: 2013-02-13 03:09:23 CST (10:30:47 ago)
Last configured: 2013-02-13 03:21:06 CST (10:19:04 ago) by nim42
1:40PM up 10:33, 1 user, load averages: 0.00, 0.02, 0.00
I’m always forgetting about the dos2unix utility.
Probably because I only need once every couple of years.
For the Ubuntu package, here’s the abbreviated
apt-cache show dos2unix :
Description-en: convert text file line endings between CRLF and LF
This package contains utilities dos2unix, unix2dos, mac2unix,
unix2mac to convert the line endings of text files between UNIX (LF),
DOS (CRLF) and Mac (CR) formats.
Text files under Windows and DOS typically have two ASCII characters
at the end of each line: CR (carriage return) followed by LF (line
feed). Older Macs used just CR, while UNIX uses just LF. While most
modern editors can read all these formats, there may still be a need
to convert files between them.
This is the classic utility developed in 1989.
For Debian-based systems,
“You can discover where a package puts its ‘stuff’ by running:
dpkg -L 'packagename'
dpkg manpage, here’s the
-L, --listfiles package-name...
List files installed to your system from package-name.
Credit to Rooke at Askubuntu.