Tuesday, September 22, 2009

~/.ssh/config

The fields you most often need in ~/.ssh/config are...


Host HOSTNAME
User USERNAME
HostName IP_ADDRESS (or hostname.fqdn)


Not to mention the proxy stuff below.

Tuesday, September 15, 2009

Extracting files from Solaris packages

How to extract files from a DaTaStReAm package without installing the package on the system:

You use pkgtrans to convert a datastream format package to file system format.


$ pkgtrans gzip-1.3.12-sol26-sparc-local .

Thursday, August 06, 2009

Debian Lenny in qemu on Windows

http://homepage3.nifty.com/takeda-toshiya/qemu/

Create an image to install into:

qemu-img.exe create -f qcow qemu_disk.img 3G

Download install image:

http://www.debian.org/CD/netinst/


Copy and change qemu-win.bat

To boot the install image with:
qemu.exe -L . -m 128 -hda qemu_disk.img -soundhw all -localtime -M -cdrom debian-503-i386-netinst.iso

Then to run normally, remove the -cdrom part.

I have also used: -m 256 -cpu pentium3 -M pc -no-reboot -no-acpi -no-kqemu

To do this I copied qemu-win.bat to a new batch file, and edited that to suit my needs and use that to start qemu.

There maybe a few errors when it boots, but nothing serious - and I can run it on a machine where I don't have admin, where I can't install VirtualBox or similar.

If you add:

-redir tcp:22::22
You can ssh into localhost to get into the machine.
-redir tcp:2222::22 if 22 is already in use...

Other links:
http://lassauge.free.fr/qemu/
http://www.davereyn.co.uk/download.htm ?

Friday, July 17, 2009

rolling back a commit with git

Get the hash of the version you want...


$ git log


Check out the version into the current dir:


git checkout 45a5b1aa137c07b15f820f49762feb7ec068b3f8 .


http://stackoverflow.com/questions/373812/rollback-file-to-much-earlier-version

Tuesday, March 03, 2009

Dead ringer...

How to disable bells all over the place...

To turn off that annoying flash (that lags your session) in vim:

In .vimrc


set vb t_vb= " Turn off visual bell


General beeps...

In .inputrc


set bell-style none


In ~/.bash_profile (or /etc/profile or .bashrc or somewhere)


setterm -blength 0


In X Window:


$ xset b off


To turn it on again use:


$ xset b on


For less

In ~/.bash_profile:


export LESS="-q"

Monday, February 23, 2009

htmlify a script -x


sh -x try.sh 2>&1 | sed "s/^+ \(.*\)$/\n$ <b>\1<\/b>/g;"

heads or tails? don't be so negative...

The number of lines options with head and tail do not have to be negative...

After 15 years of using head and tail (and wondering why they encourage the use of the "extra" '-n' option now!) a question just occurred to me...

"What if I don't know how many lines I want to see with tail, I just know I want to skip the first X lines...?"

The logical opposite of:

tail -X FILENAME

would of course be:

tail +Y FILENAME

Which (thanks to Unix being so logical) naturally works!

You wouldn't really want to use it without a -n in front because +NUM would more likely be a valid file name than a switch, so you do get a warning:


$ tail +20 FILENAME
tail: Warning: "+number" syntax is deprecated, please use "-n +number"


and head just barfs:


$ head +20 FILENAME
head: cannot open `+20' for reading: No such file or directory


So use:


$ tail -n +$SKIP FILENAME


Given the file:


$ seq 1 5 > FILENAME
$ cat FILENAME
1
2
3
4
5


Let's unit test...


$ head +2 FILENAME
head: cannot open `+2' for reading: No such file or directory
==> FILENAME <==
1
2
3
4
5


means: "head the files '+2' and 'FILENAME'"


$ head -2 FILENAME
1
2

$ head -n 2 FILENAME
1
2

$ head -n +2 FILENAME
1
2


all mean: "show the first 2 lines of FILENAME"


$ head -n -2 FILENAME
1
2
3


means "show all BUT the last 2 lines of FILENAME"


$ tail +2 FILENAME
tail: Warning: "+number" syntax is deprecated, please use "-n +number"
2
3
4
5


means "I'm being too lazy to use -n, but show me FILENAME from line 2 down"


$ tail -2 FILENAME
4
5

$ tail -n 2 FILENAME
4
5

$ tail -n -2 FILENAME
4
5


mean "Show me the last 2 lines of FILENAME"


$ tail -n +2 FILENAME
2
3
4
5


means "Show me FILENAME from line 2 down"

Wednesday, February 18, 2009

vi - delete all matching lines...

:%g/^sometext,/ d

search range (all lines) : %
beginning with "sometext,
execute the Ex cmd "d" ; delete the line

Thought for the day...

People that call it V I instead of "vie"...

...probably don't need a "vi quick reference guide/cheatsheet" anyway.

:o)