Linux Tricks

In this article i would like to share some linux command tricks, which may help you through the admin day.

count the connection per port:
netstat -plan|grep :80|awk {‚print $5‘}|cut -d: -f 1|sort|uniq -c|sort -nk 1 | wc -l
delete files older than 5 days:
find /path_to_check/temp* -type d -ctime +5 -exec rm -Rf {} \;
show zombie processes:
ps aux | awk ‚{ print $8 “ “ $2 }‘ | grep -w Z
kill zombies:
ps -ef | grep defunct | awk ‚{ print $3 }‘ | xargs kill -9

Git Tricks

Recover orgnal files from repository:
reset to HEAD
git reset –hard HEAD
git pull

GitVideo (gource required)
gource –bloom-multiplier 1.2 –bloom-intensity 1.2 –seconds-per-day 10 –title „mediAsystent“ –auto-skip-seconds 1 -1280×720

Yii Tricks

Name des Kontrollers:
Yii::app()->controller->id

oder

Yii::app()->getController()->getId()
Neuer Eintrag oder ändern in der Datenbank:
if (($model = ModelObject::model()->findByPk($obj_id))===null){
                    $model=new ModelObject;
                    $model->OBJ_ID = $obj_id;
                    $model->GROUP_ID = NULL;
                    .
                    .
                    .
                }
                else{
                    $model->OBJ_ID = $obj_id;
                    $model->GROUP_ID = NULL;
                    .
                    .
                    .
                }
                $model->save(); // save or update group record
Lesen GET/POST data

Yii::app()->request->getQuery($key, $defaultValue); // POST
Yii::app()->request->getPost($key, $defaultValue); // GET