Archive for the ‘Linux/Unix’ Category

SSH could be a nightmare for corporate firewall…

Tuesday, October 16th, 2007

SSH is very powerful, but it could be a big headache for corporate IT guys, if someone open an reverse ssh tunnel from inside a network then it could be a nightmare for the security.

Just found a post explain how to use SSH to create a reverse tunnel, it could be very useful in some case but also could be a terrible nightmare for information safety.

Using SSH to create a local Socks server  to get rid of China Great Firewall has been used widely for people in China.

Popularity: 15% [?]

Unix alike Symbolic Links on Windows XP (maybe vista)

Thursday, July 12th, 2007

I love many things in Unix, the “symbolic link” is one of them, fortunately from Windows 2000, NTFS support “juction” which is similar to “symbolic link” in Unix.  Unfortunately,  there is no default command and nor GUI menu to let you do that, all we can do is download a small software:

Junction

Create Win2K NTFS symbolic links

There are also many other cool stuff in System Internals:

 

The Sysinternals web site was created in 1996 by Mark Russinovich and Bryce Cogswell to host their advanced system utilities and technical information. Microsoft acquired Sysinternals in July, 2006. Whether you’re an IT Pro or a developer, you’ll find Sysinternals utilities to help you manage, troubleshoot and diagnose your Windows systems and applications. If you have a question about a tool or how to use them, please visit the Sysinternals Forum for answers and help from other users and our moderators.

Popularity: 14% [?]

Recursive touch

Saturday, June 30th, 2007

“touch” is a unix command used to change the time of a file or directory, touch a directory will not touch the files inside.

To touch recursively, it’s simple with the help of “find” and “xargs”:

e.g.

find . | xargs touch

will touch all files and directories recursively under current directory.

Since directory or filename may contain spaces, the shell script need some additional parameteres:

find "$1" -type f -print0 | xargs -0 touch

Popularity: 11% [?]

Shell script to replace strings in all files under directory recursively

Saturday, June 30th, 2007

In one of my project I need to replace some kind of strings in hundreds if file,  the code paste here is for specific usage, but it could be easily changed to do something else.

It will scan all *.xml files in current directory and in sub directories, replace the value of two attributes to a big value.

#!/bin/bash 
# Get List of Files to Be Replaced
file_list=`find . -name ”*.xml” -type f` 
# Define Target String to Be Replaced & Destination String for Substitution
echo ” Replacing *.xml file’s timeout to a big value ” 
# Perform Substitution
for fn in $file_list
do 
if ( test $fn != ./`basename $0` ) 
then
ffnt=”$fn.temp” 
echo ”Processing $fn …… ”  
sed ’s/responseReadTimeout=”[0-9][0-9]*”/responseReadTimeout=”999999″/g’  $fn > $ffnt 
sed ’s/socketReadTimeout=”[0-9][0-9]*”/socketReadTimeout=”999999″/g’ $ffnt > $fn 
rm $ffnt
echo ”  Done ” 
fi
done

Popularity: 15% [?]

Close
E-mail It
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.