Saturday, November 27, 2010

Mutt Tips

searching in mutt

* ~f brucewayne :From: matches "brucewayne"
* ~s party : messages with subject containing "party"
* ~d <2w : messages less than two weeks old. Also: year, month, week, day.
* ~t clarkk : To: matches clarkk (useful for sent-mail folders)
* ~O : old (i.e. unread but not new) messages.
~N is new unread.
~U is unread, i.e. both together.
* ~p : messages addressed to you (useful if your inbox is bombarded with mailing list or system report activity).
* ~p ~U : for messages to you you haven't read yet.
* . : matches everything. In effect, remove the limit.


l limit messages matching
l all show all messages
:set sort=from sort messages by "From"
:set sort=threads sort messages by "Thread"
:set sort=date sort messages by "Date"


mailbox "=cgerada" will show alerts in cgerada mailbox

Friday, November 26, 2010

Bash Cheat Sheet

 !! - Last command (usefull if you forget to run a command as sudo)
 sudo !!  (runs last command as sudo)
 !foo - Run most recent command starting with 'foo...' (ex. !ps, !mysqladmin)
 !foo:p - Print command that !foo would run, and add it as the latest to
 command history
 !$ - Last 'word' of last command ('/path/to/file' in the command 'ls -lAFh
 /path/to/file', '-uroot' in 'mysql -uroot')
 !$:p - Print word that !$ would substitute
 !* - All but first word of last command ('-lAFh /path/to/file' in the command
 'ls -lAFh /path/to/file', '-uroot' in 'mysql -uroot')
 !*:p - Print words that !* would substitute

 ^foo^bar - Replace 'foo' in last command with 'bar', print the result, then
 run. ('mysqladmni -uroot', run '^ni^in', results in 'mysqladmin -uroot')

 {a,b,c} passes words to the command, substituting a, b, and c sequentially
 (`cp file{,.bk}` runs `cp file file.bk`)

 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 + t - Transpose the current char with the previous
 Ctrl + u - Delete backward from cursor
 Ctrl + w - Delete backward a word
 Ctrl + xx - Move between EOL and current cursor position
 Ctrl + x @ - Show possible hostname completions
 Ctrl + z - Suspend/ Stop the command
 Ctrl + x; Ctrl + e - Edit line into your favorite editor

 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 - Transpose the current word with the previous
 Alt + u - Make word uppercase
 Alt + back-space - Delete backward from cursor

 (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
 $ (dir)2T - Only Sub Dirs inside (dir) 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
 .bash_profile = sourced by login shell,
 .bashrc = sourced by all shells,
 .bash_aliases = should be sourced by .bashrc

Run something:
 for i in a b c; do $i 'hello'; done

Do something on a bunch of files:
 for i in *.rb; do echo $i; done

If syntax:
 if [ -e .ssh ]; then echo "hi"; fi

file check flags:
 -e:  file exists
 -f:  regular file (non directory)
 -d:  directory
 -s:  non-zero file
 -x:  execute permission

Avoid duplicates in your history:
 export HISTIGNORE="&:ls:ls *:[bf]g:exit"

Wednesday, November 10, 2010

SMBCLIENT

smbclient -L servername
will show you all available samba / windows shares

To connect to a windows or samba share type

smbclient \\\\servername\\share -U username

you will be asked for your windows password for the username specified

once connected smbclient works like an FTP client

type help for a list of commands.

Keep in mind, you'll need a leading "\" before spaces (ex: My\ Filename.txt).

or alternatively put your filenames in quotes eg "My Filename.txt"

once connected
to copy directories and subdirectories type
recurse

to not be asked (prompted)if you want to replace files. type
prompt

Wednesday, November 3, 2010

Setting UP VNC server on a CentOs or Redhat server


To set up VNC properly, so that you have access to the local
default X console of your server as if you are sitting in front
of the physical server.
follow these steps.

On the server, type vncpasswd as root to set a VNC password.
You will use this password when connecting with vncviewer

Edit the file /etc/X11/xorg.conf

In the stanza called Screen, add this line:
Option "passwordFile" "/root/.vnc/passwd"

then
add in the following lines at the end of the file:

Section "Module"
Load "glx"
Load "dbe"

Load "extmod"

Load "freetype"

Load "type1"

Load "dri"
Load "vnc"
EndSection

save the file

Allow the ports in the iptables Firewall
by typing the following:

system-config-securitylevel

In the "Other ports", add the following range.

5900-5904

Save and close the tool then restart the firewall by typing the following:
service iptables restart or /etc/init.d/iptables restart

type

chkconfig vncserver on

to have vncserver automatically start when the server next boots up.

Then finally RESTART the server.