Linux Quick Hacks Site

September 14, 2006

http://www.troubleshooters.com/linux/quickhacks.htm

Advertisements

Bash Shell Shortcuts

May 17, 2006

Bash, which is the default shell in Linux contains a whole lot of key bindings which makes it really easy to use . The most commonly used shortcuts are listed below :

____________CTRL Key Bound_____________
Ctrl + a – Jump to the start of the line
Ctrl + b – Move back a char
Ctrl + c – Terminate the command
Ctrl + d – Delete from under the cursor
Ctrl + e – Jump to the end of the line
Ctrl + f – Move forward a char
Ctrl + k – Delete to EOL
Ctrl + l – Clear the screen
Ctrl + r – Search the history backwards
Ctrl + R – Search the history backwards with multi occurrence
Ctrl + u – Delete backward from cursor
Ctrl + xx – Move between EOL and current cursor position
Ctrl + x @ – Show possible hostname completions
Ctrl + z – Suspend/ Stop the command
____________ALT Key Bound___________
Alt + < – Move to the first line in the history
Alt + > – Move to the last line in the history
Alt + ? – Show current completion list
Alt + * – Insert all possible completions
Alt + / – Attempt to complete filename
Alt + . – Yank last argument to previous command
Alt + b – Move backward
Alt + c – Capitalize the word
Alt + d – Delete word
Alt + f – Move forward
Alt + l – Make word lowercase
Alt + n – Search the history forwards non-incremental
Alt + p – Search the history backwards non-incremental
Alt + r – Recall command
Alt + t – Move words around
Alt + u – Make word uppercase
Alt + back-space – Delete backward from cursor

—————-More Special Keybindings——————-

Here "2T" means Press TAB twice

$ 2T – All available commands(common)
$ (string)2T – All available commands starting with (string)
$ /2T – Entire directory structure including Hidden one
$ 2T – Only Sub Dirs inside including Hidden one
$ *2T – Only Sub Dirs inside without Hidden one
$ ~2T – All Present Users on system from "/etc/passwd"
$ $2T – All Sys variables
$ @2T – Entries from "/etc/hosts"
$ =2T – Output like ls or dir

[original link]

Also check out free book: Advanced BASH Scripting by Mendel Cooper 


Unix Cheat Sheet

May 15, 2006

Really good cheatsheet for unix and solaris commands:
http://www.rblweb.com/unix_commands.html 


cron Format (crontab)

April 14, 2006
* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- day of week (0 - 6) (Sunday=0)
| | | ------- month (1 - 12)
| | --------- day of month (1 - 31)
| ----------- hour (0 - 23)
------------- min (0 - 59)

vi, sed, awk Cheat Sheets

March 15, 2006

vi Cheat Sheet – http://www.eec.com/business/vi.html

sed Cheatsheet – http://www.grymoire.com/Unix/Sed.html

awk Cheatsheet – http://www.cs.uu.nl/~piet/docs/nawk/nawk_toc.html


Useful MySQL Commands

March 15, 2006

Dump DB:mysqldump -u root -p password dbname > dbbackup.sql

Dump DB Structure:

mysqldump -u root -p password –no-data dbname > dbname.sql

Reset MySQL root Password:

*shutdown mysql, then restart as follows-

mysqld_safe –skip-grant-tables –skip-networking &

mysql -u root (no password needed)

mysql> UPDATE mysql.user SET Password=PASSWORD(‘new-password’) WHERE User=’root’;

*Logout, shutdown, and restart normally to login

Useful Debugging Commands:

mysql_get_server_info()

mysql_get_host_info()

mysql_list_dbs()

mysql_list_tables()

mysql_list_fields()

mysql_stat()

mysql_ping()


PERL WILDCARDS

March 15, 2006

.     Match any character
\w   Match “word” character (alphanumeric plus “_”)
\W  Match non-word character
\s   Match whitespace character
\S   Match non-whitespace character
\d   Match digit character
\D   Match non-digit character
\t    Match tab
\n   Match newline
\r    Match return
\f    Match formfeed
\a   Match alarm (bell, beep, etc)
\e   Match escape
21 Match octal char ( in this case 21 octal)
\xf0 Match hex char ( in this case f0 hexidecimal)
You can follow any character, wildcard, or series of characters and/or wildcard with a repetiton. Here’s where you start getting some power:

* Match 0 or more times
+ Match 1 or more times
? Match 1 or 0 times
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n but not more than m times
Now for some examples:

$string =~ m/\s*rem/i; #true if the first printable text is rem or REM
$string =~ m/^\S{1,8}\.\S{0,3}/; # check for DOS 8.3 filename