October 2, 2008

Perl

To see what modules are running on your unix machine
> find `perl -e 'print "@INC"'` -name '*.pm' -print

To use the CPAN shell tool:
> sudo perl -MCPAN -e shell

> install Spread***::WriteExcel

With this command, the CPAN shell will automatically download the
module, find & retrieve any dependencies like Parse::RecDescent and
File::Temp, and unpack, configure, make, test, and install for you.

To print the version
> perl -v

To print the configuration summary
> perl -V


Additional Information

TechPublic - Perl Modules

Greek Stuff


August 22, 2008

Unix: vi commands

a Insert text after the cursor.
i Insert text before the cursor.
o Open a new line below the line your cursor is currently on.
A Insert text at the end of the line.
I Insert text at the beginning of the line.
O Open a new line above the line your cursor is currently on.
x Delete the character beneath the cursor.
h Move your cursor to the left by one character.
l Move your cursor to the right by one character.
j Move your cursor up by one line.
k Move your cursor down by one line.
$ Move to the end of the line.
0 Move to the beginning of the line.
w Move forward one word and place the cursor on the first character of that word.
b Move backward one word and place the cursor on the first character of that word.
G Go to the end of the file.
1G Go to line 1 of the file.
CTRL+g Report on the current line number that the cursor if on as well as the number of total lines in the file.
dd Delete the current line.
cw Change word. That is, change the characters from where your cursor is to the next space or punctuation.
cl Change letter. Change the character that your cursor is on.
yy Copy the line that the cursor if currently on.
p Place the contents of either a deleted line or a copied line on the line immediately following the one your cursor is currently on.
u Undo the last change.
:w filename Save changes. The filename is optional and is only used to specify the name of the file that you would like to save your work as.
:wq filename Save changes and quit. Again, the filename is optional.
ZZ Save changes and quit.
:q! Quit without saving changes.
/string Search for next occurrence of string in the file.
n Repeat the last search
. Repeat the last insert function.

Unix Commands and Scripts

> mkdir test;
Make a test directory.

> mv data data1
The move command copies over the previous file. Data1 will be the new file.

> umount -l /media/usb
This command is used to un-mount busy usb drives.

> cat *.nbe grep results awk -F"" '{print $3}' sort uniq
This unix statement concatenates all of the .nbe files, searches for the word 'results' and print the third column of uniq data in sorted order


The cat command is a standard Unix program used to concatenate and display files. The name is from catenate, a synonym of concatenate.

grep is a command line text search utility originally written for Unix. The program's name derives from the UNIX ed comman, g/re/p which performs a similar operation.

Although grep is not strictly an acronym, the letters are taken from global / regular expression / print, a series of instructions for the ed text editor. The grep command searches files or standard input globally for lines matching a given regular expression, and prints them to the program's standard output.

> cat *.txt grep Interesting awk '{print $4}' sort uniq
This statement is utilized with a nmap statement. Used to search and publish the IP address from the scans tagged as 'Interesting'.

> tar -zxvf test123.tar.gz
z -- unzip
x -- extract the file
v -- verbose
f -- forcefully done
How to unzip a tar file?