SU on ESX

When you su in ESX you may find that you can not run the usual commands. This may be down to environmental variables, use: su - This will change the environmental variables to the new user.
Read more →

Running Programs over SSH

This is by far the best thing to use when you are running programs that take a while to complete. The danger is that you lose your SSH connection and your program along with it. Use the following to start a screen session: screen This generates a screen session that can be detached from by pressing: ctrl + a d At this point you can safely close down the SSH session.
Read more →

Matching Multiple Strings in Grep

Syntax: grep -E (string|string2) *
Read more →

How to Send Email from the Command Line in Windows

Blat is the way forward. Blat is a small, efficent SMTP command line mailer for Windows. It is the SMTP sending part of an eMail User Agent (MUA) or eMail client. As such, Blat sends eMail via SMTP (or internet eMail) from the command line, or CGI, … blat 1.txt -t [email protected] -attach 1.bmp -base64 -html This will include the contents of 1.txt in the body of the email and attach the file 1.
Read more →

Exporting info from AD as CSV

If you want to export AD info as CSV then csvde is the cmd for you, for example: csvde -s clyde -f users.csv -r objectClass=user -l givenName, sn, name, sAMAccountName
Read more →

Copy Files from Linux to Windows using pscp Over SSH

Use the following program that comes with putty to copy files from nix machine to a windows machine. pscp -r -C User@Machine:/var/log/httpd/ c:\weblog\ -C Enables compression, which sounds like a good shout accross slow links.
Read more →

Burn ISO from Command Line

Get hold of 2003 cdburn.exe from the Windows 2003 Support Tools. cdburn.exe e: c:\path\iso_file.iso Where e: is the CD writer.
Read more →

Using Grep to Scan Log Files on Windows

Use the following to find Forbidden errors from web server logs: grep 403 \machine\i$\LogFiles\W3SVC1\ex0* You can get GNU utilities for Windows which includes grep. Microsoft has its own version of grep called QGREP which is part of the 2003 resource kit.
Read more →

Using tcpdump to Capture Traffic for Analysis in Wireshark

Use the following: tcpdump -i <interface> -s 1500 -w <some-file> tcpdump will only cature the first 68 bytes so you need to change the value to your packet size.
Read more →

Backing up partions under *nix

dd is your man here. Replace /dev/disk for the disk you are interested in i.e. sda, sdb : dd if=/dev/disk of=/path/backup This will create a full backup of your partition i.e. /dev/sda1: dd if=/dev/disk_partition of=/dev/backup You can compress the backup using gzip: dd if=/dev/disk | gzip -c9 < /path/backup.gz And to restore it: gunzip -c /path/backup.gz | dd of=/dev/disk
Read more →