There’s lots of documents on the web that show how to move “My Documents” to another drive, so I won’t bother show how here. One step I found missing however was brought on by my use of Linux. Whenever you move a directory to a bigger drive, I just symlink it so I don’t have to reconfigure anything that doesn’t follow along. Granted, Windows management of “My Documents” is a little more internal than just a directory (or folder in this case), so most everything followed along. Except for Google Desktop. It actually created it’s own folder in “C:\Documents and Settings\
Syntaxy
...now browsing by category
Useful commands/scripts to remember.
Moving “My Documents” with an extra step.
Thursday, April 23rd, 2009Router tinkering.
Friday, January 9th, 2009So for various reasons, I run two routers on my home network. One is the Rogers supplied SMC POS. I treat this basically as a modem and connect to it with my new Dlink DIR-655 gigabit router. I recently had a need to get some traffic routed to an internal machine and dreaded having to figure it all out. Looking at the SMC, I realized it had a DMZ option. Setting that to the “external” IP of my Dlink router would in effect pass all traffic to my Dlink, letting it handle all security related issues, including routing of traffic to internal IPs. Done and Done.
Source
Wednesday, September 28th, 2005I like Open Source as much as the next geek, but I also like it when I’m shielded from the pain the way I am in Gentoo. Check this `configure` command out from a recent Solaris PHP compile:
$ ./configure \
–with-gd=/usr/local \
–with-jpeg-dir=/usr/local \
–with-freetype-dir=/usr/local \
–with-png-dir=/usr/local \
–with-xpm-dir=/usr/local \
–with-iconv-dir=/usr/local \
–enable-freetype \
–enable-jpeg \
–with-zip \
–enable-memory-limit \
–disable-debug \
–with-regex=php \
–with-pic \
–enable-exif \
–enable-filepro \
–enable-ftp \
–with-gettext \
–enable-mbstring \
–enable-sockets \
–enable-sysvsem \
–enable-sysvshm \
–with-mysql=/opt/private/path/mysql \
–with-apxs2=/opt/private/path/apache/bin/apxs \
–with-zlib \
–with-openssl=/usr/local/ssl \
–enable-ftp \
–enable-shared \
–enable-libgcc \
–prefix=/opt/private/path/php
Isn’t that just sick? Sure, I would have had to use lots of USE flags in Gentoo to make that work, but it’s still a lot less typing/headaches, not to mention the fact that it would have gone out and compiled GD and everything else for me.
Mozilla password migration.
Monday, March 7th, 2005I hate Mozilla sometimes. Something screwed up my profile to the point that the preferences windows wasn’t populated with data. “No problem,” I thought, “I’ll just make a new profile and get a fresh start.” Went well until I tried to migrate/import my passwords to the new profile. Long story short, here’s what you need to do:
There’s a very good chance you don’t need both of those .db files, but I simply don’t care. I killed a good hour jerking around with this POS and I don’t care to look it up any further.
Partition multiple drives in Solaris
Friday, December 10th, 2004Say you have an ol E450 with a whack of drive in it (they fit 20). You want to put all those drives in a RAID5 or something and wish to have them all laid out the same way, partition wise. Here’s a shortcut. Format one of the drives the way you want it. Then run the following:
prtvtoc /dev/rdsk/
This will copy the partition table from the
df and du dont’ match?
Friday, December 3rd, 2004If you have a large active server running (possibly applies to Solaris only here), and find your disk space seems to dissappear quickly, and running `df` and `du` bring back different results, try running the following:
find /proc -type f -size +100000000c -ls
This will look at running processes on the system and find each one that has a file descriptor larger than 100M. If you have quite a few (like I do), try chaning the “100000000″ to “500000000″. From there, investigate each process to see which is larger, and whether its handling its files properly. Use `lsof` to see which files that PID has open, and if the files sizes match the file descriptor size of your above command. If not, that process isn’t closing its files properly, and will need restarting (and subsequent complaints to the developers).
Useful bash history
Wednesday, October 6th, 2004Putting the following in your .bashrc (either in your home, or globally if its just a desktop), will increase the number of entries your bash history will show (when typing `history` or using C-r). The HISTCONTROL variable will cause your bash_history to ignore consecutive commands, so only one will display in your history.
export HISTSIZE=1000
export HISTFILESIZE=1000
export HISTCONTROL=ignoredups
Bash 3 and line wrapping.
Monday, September 13th, 2004I had some trouble with my command line shortly after emerging Bash 3.0. My line was wrapping at very odd places and I couldn’t really figure out why. I originally had this for a prompt:
export PS1="u@h: [$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files - $(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')] w n$ "
This will show the number of files in the current directory, as well as the size of the files. This was neat, but useless so I took it out and ended up with this:
export PS1='u@h: w n$ '
Now, this was smaller, but it still messed up my line wrap. In fact, it looked as though it was wrapping the line according the size of the prompt. Some searching in the Gentoo forums revealed that Bash wasn’t counting the characters properly, thinking my prompt was part of my command line. A post from someone who actually bothered to investigate further suggested you have to escape your entire prompt with []’s, but also escape those with ’s. So, my final prompt is this, which works wonderfully:
export PS1='[u@h: w n$] '
du handiness.
Monday, August 30th, 2004I use ‘du’ often to see what directories are using up all the space. Often, this gets annoying as it delves down in to several thousand directory trees, so I use the following to keep it limited:
du -h –max-depth=1
This will spit out, in human readable format, the size of each of the directories in the current directory, limiting the output to one directory. Try it to see what I mean.
Backup config
Friday, June 25th, 2004Now that I’m hosting other peoples data, I decided perhaps I should try and create some better backups of things. This script can be called to backup any directory you want, and will store the backups on a local filesystem. I did it this way because I have 2 drives in my server, but it could be modified easily to send data to a remote host via ssh, or just use an NFS mount.
I got a lot of help from this page, which explains some of what I’ve done below. Feel free to use this and modify it to suit your needs. I assume no responsibility if it doesn’t work for you.
#!/bin/bash
# ———————————————————————-
# Creating rsync backups, then making daily copies of those backups
# ———————————————————————-
unset PATHID=/bin/id;
CP=/bin/cp;
MV=/bin/mv;
RM=/bin/rm;
RSYNC=/usr/bin/rsync;
BZIP=/bin/bzip2;
TAR=/bin/tar;if [ ! $2 ] ; then
echo “Usage: `/bin/basename $0` SOURCE NAME_SET”
exit 1
fiSOURCE=$1
NAME=$2
DEST=/root/temp/# make sure we’re running as root
if (( `$ID -u` != 0 )); then { $ECHO “Sorry, must be root. Exiting…”; exit; } fi# Step 1, rotate older backups, deleting the 6th backup, as its too old to care about
if [ -e ${DEST}/${NAME}.6.tar.bz2 ] ; then
$RM ${DEST}/${NAME}.6.tar.bz2
fiif [ -e ${DEST}/${NAME}.5.tar.bz2 ] ; then
$MV ${DEST}/${NAME}.5.tar.bz2 ${DEST}/${NAME}.6.tar.bz2
fiif [ -e ${DEST}/${NAME}.4.tar.bz2 ] ; then
$MV ${DEST}/${NAME}.4.tar.bz2 ${DEST}/${NAME}.5.tar.bz2
fiif [ -e ${DEST}/${NAME}.3.tar.bz2 ] ; then
$MV ${DEST}/${NAME}.3.tar.bz2 ${DEST}/${NAME}.4.tar.bz2
fiif [ -e ${DEST}/${NAME}.2.tar.bz2 ] ; then
$MV ${DEST}/${NAME}.2.tar.bz2 ${DEST}/${NAME}.3.tar.bz2
fiif [ -e ${DEST}/${NAME}.1.tar.bz2 ] ; then
$MV ${DEST}/${NAME}.1.tar.bz2 ${DEST}/${NAME}.2.tar.bz2
fi# This one is different. To save a little stress on the system being backed up,
# make a copy (cp -a) of the last ${NAME}, instead of moving it. This will allow
# rsync to only write the changes in the filesystem, rather than everything.
# Also, bzip2 the previous ${NAME} to save drive space.
if [ -d ${DEST}/${NAME}.0/ ] ; then
$CP -a ${DEST}/${NAME}.0/ ${DEST}/${NAME}.1/
if ( `$TAR cjf ${DEST}/${NAME}.1.tar.bz2 ${DEST}/${NAME}.1/` ); then { $RM -r ${DEST}/${NAME}.1/; } fi
fi# Step 2, make a new backup, and call it ${NAME}.0/
$RSYNC –delete -avz ${SOURCE} ${DEST}/${NAME}.0/