copy files and create the directories if it doesn’t exist

June 3rd, 2011 mysurface

It always have a need for this simple operation. I wanna copy certain files to a destination, but I wanna preserved the sub directories structure, any cp option to set? For examples, I wanna copy my_project/cpp/ to your_project folder, but I want it to appear as your_project/cpp/ automatically. Especially I wanna do it in a [...]

Posted in dirname | Hits: 100232 | 15 Comments »

export environment variable from a bash script

February 1st, 2011 mysurface

You may want to create a bash script that export some environment variable for your shell, but infect every execution of bash script is a unique session, where the variable export within it can’t be carry backward back to the bash shell. For example you have a which contains some environment variables export HELLO=hello [...]

Posted in Bash, source | Hits: 119221 | 4 Comments »

config file for your bash script

January 22nd, 2011 mysurface

Sometime you may wish to create a bash script to do something based on a config file, what actually was in your mind? How to implement the config file for your bash script? First I think of using command ‘cut’, where I can create a list of tag=value, then uses ‘cut‘ to read out the [...]

Posted in Bash, source | Hits: 115449 | 4 Comments »

Why my written shell script doesn’t work in cygwin?

May 20th, 2010 mysurface

You may facing the problem like this. The workable shell script in Linux, after you copy and paste into windows editor and save as .sh, it doesn’t work under Cygwin shell. Why? Bear in mind that, Cygwin shell giving you a *nix environment (either Unix or Linux), which is actually a bash environment. Everything task [...]

Posted in Common, cygwin, dos2unix | Hits: 140956 | 2 Comments »

List command line history with timestamp

October 16th, 2008 mysurface

History is a common command for shell to list out all the executed commands. It is very useful when it comes to investigation on what commands was executed that tear down the server. With the help of last command, you be able to track the login time of particular user as well as the the [...]

Posted in Common, history, last | Hits: 209895 | 21 Comments »

Top Ten Processes Watcher

July 13th, 2008 mysurface

top command provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel. But if you want get something more specific, you must play some tricks on it. For example, I want a clean view of top [...]

Posted in head, tail, top, watch | Hits: 123465 | 3 Comments »

WordPress exploit: we been hit by hidden spam link injection

May 26th, 2008 mysurface

We been hit by hidden spam link injection (a modified version of goro spam injection), this crack injects spam links through wordpress wp_footer() or wp_head() hook. The spam links only reveal itself if crawled by search engine bot such as googlebot, and they are hidden from our eyes. We believe the cracker’s purpose is to [...]

Posted in curl, curlftpfs, file, find, Misc | Hits: 179119 | 81 Comments »

Discover user guides and manuals within your linux system

May 9th, 2008 mysurface

Do you realized that we can obtain a lots of user manuals and guideline documents from our system? There is a folder /usr/share/doc, you may find some useful docs already preinstalled by your distro. Those docs are in pdf or html format. I manage to find user manuals for valgrind, ipython, systemtap, boost etc. I [...]

Posted in Common, echo, find | Hits: 52147 | 2 Comments »

Simple use of find to search for files in command line

May 2nd, 2008 mysurface

Find is a very strong command to search for files and folders. You can search for files based on certain criteria besides filename, such as file types, atime, belongs to which groups, file modes, etc. Because find command support a lots of options, therefore sometimes find command line looks very complicated, but actually it is [...]

Posted in file, find, Misc | Hits: 51136 | No Comments »

rpm and yum rescue tips on Fedora

April 22nd, 2008 mysurface

You have to be careful when you run yum update and yum install, DON’T force kill it, kill -9 or pkill -9. Those action are consider very dangerous, may lead you to losing certain files. Seriously, I hate yum, when I really wanna cancel the process in the middle, by hitting ctrl+c doesn’t really work! [...]

Posted in Admin, awk, rpm, which, yum | Hits: 60768 | 2 Comments »