Linux Blog

SSH Escape

Filed under: General Linux — TheLinuxBlog.com at 2:27 pm on Tuesday, September 2, 2008

You can get into a special area of SSH that you by using the SSH Escape key sequence.It can be set at the connection time to a custom character but if you didn’t set one it is probably set to the Tilda (~). To open the SSH Escape dialog to manage your connection (I assume you know what you want to do, but your wondering how you use it)

Its simple to use; just hit shift, then the back tick (`) to get the Tilda (~) then type the command you want to use.

For example to pull up the SSH Escape dialog help up you use the question mark (?) so do the following:

[owen@Linux_Blog ~]$ ~?
Supported escape sequences:
~.  - terminate connection
~B  - send a BREAK to the remote system
~C  - open a command line
~R  - Request rekey (SSH protocol 2 only)
~^Z - suspend ssh
~#  - list forwarded connections
~&  - background ssh (when waiting for connections to terminate)
~?  - this message
~~  - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)

For more information on the SSH Escape Sequence check out the SSH Man Page

Post By: Owen From: TheLinuxBlog.com

Perl Regular Expression Cheat Sheet

Filed under: Shell Script Sundays — Owen at 10:15 pm on Saturday, October 6, 2007

Regular Expressions can be tricky, that’s why it is a good idea to keep a quick “cheat sheet” handy when working with them, here’s a concise cheat sheet to get you started:

.  	Match any character
\a  	Match alarm
\d 	Match digit character
\D  	Match non-digit character
\e  	Match escape
\f  	Match form-feed
\n  	Match newline
\r  	Match return
\s  	Match whitespace character
\S  	Match non-whitespace character
\t  	Match tab
\w 	Match "word" character (alphanumeric and "_")
\W  	Match non-word character
\022 Match octal char (i.e. 22 octal)
\xff  	Match hex char (i.e. ff in hex)
 
*	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
 
^	Match if at beginning
$ 	Match if at end
 
Examples:
\d{2}-\d{2}-\d{2}		# match date in dd-mm-yy format
^[ \t]+ 			#match leading whitespace
[ \t]+$			#match trailing whitespace
^[ \t]+|[ \t]+$ 		#match leading or trailing whitespace
 
$string =~ m/text/;		#returns true if $string contains text, case sensitive
$string =~ m/text$/i;		#returns true if $string contains text
$string =~ s/text1/text/;	#replace text1 with text2 in $string
$string !~ m/text/;		#returns false if $string contains text, case sensitive
$string !~ m/text/i;		#returns false if $string contains text

I find it useful to print it out and have it handy whenever I wade into the murky waters of regular expressions.