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. |
August 22, 2008
Unix: vi commands
Labels:
Linux
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
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?
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 uniqThis 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?
Labels:
Linux
August 21, 2008
MySQL - Functions
>LOAD DATA LOCAL INFILE '/location/file' INTO TABLE table FIELDS TERMINATED BY '/n';
Uploading data into tables from a file.
>DELETE FROM table
Delete all data from table
>LOAD DATA LOCAL INFILE '/location/file' INTO TABLE table (column1);
Load data into a table from a file into particular columns.
>LOAD DATA LOCAL INFILE '/location/file' INTO TABLE table (column1) SET (column2) = 'data';
Add a value to the column that is not in the source file. Ensure the '( )' are around the column1 name.
>SELECT version();
Determine the version on MySQL you are running.
>SELECT now();
Determine the date and time.
>MYSQLDUMP -u username -p databasename > filename.sql
Backup the entire database from the command prompt.
>DELETE FROM table where Field = 'value';
To delete a row from the database.
>Select * From table WHERE value NOT IN (SELECT value FROM table Union SELECT value FROM table);
Query data from two separate tables where it does not exist in the master table.
>SELECT DISTINCT field FROM table INTO OUTFILE '/location/filename';
Directs the output to a file.
>CREATE TABLE Name Select * from Orginal_Table;
Create a table structure from another table.
>Select a.IP, b.nessus as nessus, c.patchlink as patchlink, d.nmap as nmap from JASON2_Inv as a left join Scan_Nessus_Inv as b on a.IP = b.IP left join Scan_Patchlink_Inv as c on a.IP = c.IP left join Scan_NMAP_Inv as d on a.IP = d.IP;
This is an example of a left join with four tables.
Uploading data into tables from a file.
>DELETE FROM table
Delete all data from table
>LOAD DATA LOCAL INFILE '/location/file' INTO TABLE table (column1);
Load data into a table from a file into particular columns.
>LOAD DATA LOCAL INFILE '/location/file' INTO TABLE table (column1) SET (column2) = 'data';
Add a value to the column that is not in the source file. Ensure the '( )' are around the column1 name.
>SELECT version();
Determine the version on MySQL you are running.
>SELECT now();
Determine the date and time.
>MYSQLDUMP -u username -p databasename > filename.sql
Backup the entire database from the command prompt.
>DELETE FROM table where Field = 'value';
To delete a row from the database.
>Select * From table WHERE value NOT IN (SELECT value FROM table Union SELECT value FROM table);
Query data from two separate tables where it does not exist in the master table.
>SELECT DISTINCT field FROM table INTO OUTFILE '/location/filename';
Directs the output to a file.
>CREATE TABLE Name Select * from Orginal_Table;
Create a table structure from another table.
>Select a.IP, b.nessus as nessus, c.patchlink as patchlink, d.nmap as nmap from JASON2_Inv as a left join Scan_Nessus_Inv as b on a.IP = b.IP left join Scan_Patchlink_Inv as c on a.IP = c.IP left join Scan_NMAP_Inv as d on a.IP = d.IP;
This is an example of a left join with four tables.
Labels:
Databases
Subscribe to:
Posts (Atom)