Posts

Showing posts from 2012

How to multiple rename with bash

Sorry the wiseman, I can't remember that guy who post this knowledge. ( he 's alway great ).  In your command line ( bash ) do $ for file_name in *. ; do mv $file_name ${file_name/ / }; done; for example $ for f in *.sql; do mv $f ${f/.sql/.dump}; done; Then every sql files in your current folder will be .dump files hahaha :)

Change hostname on ShogunVPS

Edit /etc/hostname --------------------------    replace on line with myservice.mycompany.com Edit /etc/host -------------------    add new line after 127.0.0.1   localhost    with    127.0.0.1   myservice.mycompany.com **NOTE** this method passed test on ShogunVPS

My command line shortcuts

My command line shortcuts ------------------------------------ alt-d : delete a word, starting at the current cursor position. ctrl-a : move to beginning of line. ctrl-e : move to end of line. ctrl-k : delete all characters in the line, starting the cursor position. ctrl-x : delete all characters in the line before current cursor position. ctrl-u : delete current line. ctrl-w : delete last word of current cursor.

How to disable ubuntu auto update

How to disable ubuntu auto update ----------------------------------------------- ( because it create some spike on incoming network , almost above 2m on zabbix ) 1. Be root 2. edit file /etc/apt/apt.conf.d/10periodic 3. change          APT::Periodic::Update-Package-Lists "1";     to           A PT::Periodic::Update-Package-Lists "0"; thank to Japman ( proteus lead infrastructure )

Clean swap

If i want to clean swap space     $ sudo swapoff -a     $ sudo swapon -a  ref  http://superuser.com/questions/271829/clean-up-swap-memory

SVN adduser

I can both add new svn user or change svn password     htpasswd -m username but if is not valid . I can     htpasswd -c

Deal with mysql_config not found while installing mysql-python

sudo apt-get install mysql sudo apt-get install libmysqlclient-dev then pip install mysql-python ref http://stackoverflow.com/questions/7475223/mysql-config-not-found-when-installing-mysqldb-python-interface

How to start something after boot/reboot

In someway we can deal with rc.local. This is quite a good way to do this that I got this technique from head infrastructure of my company ( the japman ) Edit /etc/rc.local, Add it before sleep command.

whowatch - console, interactive, process and users monitoring tool

For checking current activities of users on system sudo apt-get install whowatch

du and df usage

Show summary for each * du -sckh * Show all with human-readable, total df -ah --total

Little thinks about PSQL

Hi , if you just wanna list all databases on your postgres. It's just $ psql -l U postgres and if you wanna drop db. It's just $ dropdb -U postgres That's it.

Something about su and sudo

su - run a shell with substitute user and group IDs (  http://linux.die.net/man/1/su  ) sudo, sudoedit - execute a command as another user (  http://linux.die.net/man/8/sudo  ) The sudo allows a permitted user to execute a command as a superuser or another user as specified in the sudoers file ( which we can edit by visudo command ). The su is frequently use with -c ( --command ). But we put those 2 together like below example $ sudo su -c "whoami;echo $HOME"   # may be you'll get root and current user's home $ sudo -u hudson sh -c "whoami;pwd;whoami" ref http://linux.die.net

Linux networking #1

$ sudo route $ sudo vi /etc/resolveconf/resolv.conf.d/base $ sudo /etc/init.d/resolvconf restart

SMB usage

$ smbtree   # show list of smb share $ smbclient -L $ smbclient \\\\host\\sharename

SSH with X11 forward

$ ssh -Y # forward X11 Enables trusted X11 forwarding.  Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls. You can use -X but -Y must be better.

Create user for linux

$ useradd -m -p -s

BASH scripting TIP #1

In bash script file $? - store exit value of last command that was executed $* - store all args "$@" - store all args, individually with qoute "$1", "$2" $1 - first arg $2 - second arg $n - nth arg

Some trouble shooting that I just found and use :) #1

KVM machine in my office turn on with its kvm's instances. But some of them don't got an IP, even network interface card. So here is what i have found. $ sudo ifconfig eth0 up   # to bring up eth0 $ sudo dhclient -r   # release ip  $ sudo dhclient   # obtain ip ref cyberbiz website

Setup PySide

Setup PySide sudo add - apt - repository ppa : pyside sudo apt - get update   Great thanks to this ref :  http://qt-project.org/wiki/PySide_Binaries_Linux

Setup QT via apt-get

To setup qt4  $ sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui qt4-demos qtcreator qtcreator-dbg qtcreator-doc The demos should locate in /usr/lib/qt4/demos also examples Here is the great reference of setup qt4  http://ashu-geek.blogspot.com/2012/03/qt-47-cross-platform-application-ui.html

Disable flash for google chrome

Type "about:plugins" in url location box, then expand detail panel of flash player. Disable pepper something. After that everything turn good.

Linux networking issue #1

Change route     $ sudo route Delete default gateway     $ sudo route del default Add new default gateway     $ sudo route add default gw xxx.xxx.xxx.xxx Bring up/down interface     $ sudo ifconfig up/down Config network     $ sudo vi /etc/network/interfaces Restart/Stop/Start network     $ sudo /etc/init.d/networking restart/stop/start Release IP from dhcp     $ dhclient -r Get Fresh IP from dhcp     $ dhclient Ref:Japman, InfraGuy.

Check partition type in linux

Just     $ df -T -h or     $ sudo fdisk -l ref :  http://www.cyberciti.biz/faq/linux-how-to-determine-find-out-file-system-type/

Dig in google-chrome #1

I tried to find why I can't type in input-textbox on some website (known later that has flash 11.3 included). Not sure but the problem gone immediately after I disable flash (some pepper version). So I decide to use flash 11.2r202 from adobe website. In tar.gz type, I discovered that google-chrome not just store files in ~/.config/google-chrome but in /opt/google/chrome as well. Seem like this is the truth solution but not event close, because my chrome does not seem to feel a new plugin (libflashplayer.so). So I try to put it in /usr/lib/mozilla/plugins. From doing this, it's work. That's it. ** Download install_flash_player_11_linux.x86_64.tar.gz from adobe web. After untar we'll get - libflashplayer.sh - readme.txt - usr folder **** you should follow the instruction in readme.txt

Python re module's stuff # 1

When you do something with aws, then you need only ip-address from something like this $ ec2-1-2-3-4.ap-southeast-1.compute.amazonaws.com I used to deal with it like split something then concat with something. Now I just found something cool in python's re module. >>> import re >>> ec2_ip = re.search(r'ec2-(\d+)-(\d+)-(\d+)-(\d+), ).groups() so I get >>> print ec2_ip '1.2.3.4' yaha, love this.

The combination of xargs

Assume that you : Have folder "mylist" that contain a lot of files such as "a.php", "uud.php", "ad.py".... You want to : Add new extension ".du" to any files in this folder I can do : ~/mylist$ ls | xargs -I f mv f f.du             # god bless -I :o Or I can do : ~/mylist$ find . -name '*.py' | xargs -I f mv f f.du        # just add new extension for *.py * aha , i think that a lot of combination could made :) ** next time, it should be rename extension not add it. (my eng is suck)

Create file with size for testing purpose

Have you guys even need to have some file with size and its content not neccessary! Here it is $  dd if=/dev/zero of=output.dat bs=1024 count=10240 now we get file -- name : output.dat -- size :1024 * 10240 -> ~10mb Thanks for ( http://linuxcommando.blogspot.com/2008/02/create-file-of-given-size.html )

ShortCut for KDE Desktop

It's from linux mint, but it's work :) http://community.linuxmint.com/tutorial/view/47

Fresh setup with Kubuntu 12.04

I alway deal with external monitor issue. Last time on Kubuntu 11.10 , it's gone by a lot of hack xorg.conf, system settings/display and monitors. Now, it's back. I tried to use old way but I just think if I tried $ kdesudo (or sudo ) amdcccle then I enabled multi-monitor with little setup then restart. And Again it seem like I get in cloning mode. But I just get it amdcccle ( ati control settings ) then enable multi monitor mode again. After that everything is seem to look good now.

Monitoring traffic for linux

Top-class infrastructure at my company (joe) told me about linux app to display traffic, that is "iftop" $ sudo apt-get install iftop then run it with root

Something comeup after install git-cola

 This is an error , i got when i ran git-cola "(python:14634): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap", follow this link at #6 (https://bugs.launchpad.net/ubuntu/+source/quickly/+bug/853232) ,  Peter Würtz (pwuertz) His post will help you get through this problem by this command $ sudo apt-get install gtk2-engines-pixbuf

Some tip on nosetests

$ nosetests --where=[you folder] --tests=[testfile1,testfile2 ,testfile...] E.X.     $ nosetest --where=integrate_test --tests=test_yaya

Better setting for my machine

Currently, i'm use dell laptop core i5 with ATI graphics. It make me feel bad when I tried to focus something on screen. So i tried to do something better. Finally I found that I have option for Kubuntu ( I using ) >>> Use Anti-Aliasing ==> Enabled [RGB, hinting=> slight] >>> Force font to DPI ==> 120 DPI Now I'm feel better with my eyes and my machine :)

Replace ^M in VI

Sometime , you found ^M when you open a file in VIM This is gonna help you get through it. In VIM 1. Press colon (:) , prepare to input command 2. Use command    :%s/ (press ctrl-v, then ctrl-m) ===> you get :%s/^M    then     :%s/^M/\n\r/ , then enter finally, everything should be ok :)

Enable color for terminal ( iterm included )

refer to http://blog.imzaid.com/color-terminal-bash-on-the-mac-iterm-included :) tested with osx, not sure on linux

Command line to kill n restart skype

$ echo `ps -C skype|grep skype` | cut -d' ' -f1 | xargs kill -9 && skype &

Shortcut for Google Chrome

Move to next tab : Ctrl+Tab Move to previous tab : Ctrl+Shift+Tab Move to tab number # : Ctrl+# refer to  http://www.mydigitallife.info/google-chrome-tips-on-keyboard-shortcuts/

Enable/Disable service when start server

Two ways in order to doing this ( that I have for now ) 1. Using rcconf ( from top-infra of my company )    1.1 $ sudo apt-get install rcconf    1.2 $ sudo rcconf    1.3 let's do what you want. 2. Using command line    2.1 sudo update-rc.d [enable | disable]

Change Monitor Layout in KDE

Open your terminal, then $ sudo amdcccle then change your monitor's layout and restart your box !!! everything should be what you want :)

Testing exim4 (MTA)

Setup exim4 $ sudo apt-get install exim4 Testing send email $ /path/to/exim4 -v 'user@domain' ^d refer to  http://atmail.com/kb/2008/testing-email-with-exim/

Do vertical align for multiple display in kubuntu

I gather information and detail from google. The first thing i did is about ~/.kde/share/config/krandrrc [Display] ApplyOnStartup=true StartupCommands=xrandr --output LVDS --pos 0x1080 --mode 1920x1080 --refresh 60.0147\nxrandr --output CRT1 --pos 0x0 --mode 1920x1080 --refresh 60\nxrandr --output CRT1 --primary [Screen_0] OutputsUnified=false UnifiedRect=0,0,0,0 UnifiedRotation=1 [Screen_0_Output_CRT1] Active=true Rect=0,0,1920,1080 RefreshRate=60 Rotation=1 [Screen_0_Output_LVDS] Active=true Rect=0,1080,1920,1080 RefreshRate=60.0146789550781 Rotation=1 then I found more that I must have script when start up that should be in /etc/X11/1920x2.sh mine is (copy from ~/.kde/share/config/krandrrc xrandr --output LVDS --pos 0x1080 --mode 1920x1080 --refresh 60.0147 xrandr --output CRT1 --pos 0x0 --mode 1920x1080 --refresh 60 xrandr --output CRT1 --primary and the last is /etc/X11/xorg.conf mine is  Section "Monitor"     Identifier   &qu

Specific install python package with PIP

If in the past u use package==2.1.1, then the time goes on package go up to 2.2.0 that blow your environment out. Kirit and some docs told me that we should >>> pip install 'package>=2.1,!=2.2.0' as logic said, we won't get package 2.2.0 , surely :)

Little Info about Chrome's shortcut :)

ctrl + page down/ctrl + tab -> switch to next tab ctrl + page up/ctrl + shift + tab -> switch to back to previous tab ctrl + keypad[1-9] -> switch to specific tab ctrl + alt + left arrow -> switch back to history of its tab ctrl + alt + right arrow -> switch to current of its tab ref JECShark,  http://www.google.com/support/forum/p/Chrome/thread?tid=16c23e5647c48367&hl=en

Empty trash in linux by command line

rm -rf ~/.local/share/Trash/files/*

Basic using s3cmd

sudo apt-get install s3cmd s3cmd --configure s3cmd put s3://xxxxxxxx/ s3cmd get s3://xxxxxxx/file s3cmd setacl s3://xxxxxx/ --acl-public/--acl-private

Fedora 16 ( 64 bits )

I use to play with fedora since it split from redhat. That time i know how to deal with yum ( fedora package manager ) but not much. Now i do task in ubuntu and have apt-get to be a short sword. Today I found some good article about top 10 linux distros. I saw fedora bring something interesting up again. So I got fedora16 (64 bit) in my virtualbox. At the end I found myself trying to find something like build-essential ( ubuntu ) from yum. That's why I have to wrote down in this post. To get something like that I have to >> su - # to be root, traditional way of fedora:) >> yum install yumex   Arrh then you can have something like ubuntu software manager, let's go to development topics then click !!! *** let's try >> yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel

How to rip audio from video using ffmpeg

This is what i want, when i need new ringtone from youtube. Currently I have ffmpeg installed. then i >> ffmpeg -i input.flv -ab 128 -ar44100 output .mp3

When I talk to xorg.conf gentlely :)

I just setup new kubuntu on my machine. And found that does not work fine with multiple display at the first time. So I try to find the good way to do that. After I googled for 1-2 days Kirit told me to look at his friend post about config xorg.conf. Actually I tried another one 'krandrrc' in ~/.kde/share/config/ but it seem like hard to understand in short time. So I think should be better with kirit 's friend way. But i won't post the config in this post yet. Will be next post. :)

Things have to do after install Kubuntu 11.10

Hi, Today I try new fresh setup of kubuntu on my machine. I intend to use it for develop task. So the list below this topic shows which pkg need to setup before do other thing :) >> sudo apt-get update >> sudo apt-get build-essential python-dev >> sudo apt-get install mercurial subversion git-core >> sudo apt-get install kubuntu-restricted-extras >> sudo apt-get install kubuntu-restricted-addons >> sudo apt-get install vim >> sudo apt-get install vim-nox >> sudo apt-get install synapse ( finder-like ) >> sudo update-apt-xapian-index >> sudo apt-get install vlc >> sudo apt-get install synaptic Note : I don't know how to install java by apt-get , if anyone knows please :) That's all , i can think about for now , will add it later. for more information (thank howtoforge and CSch http://www.howtoforge.com/forums/member.php?u=86089) http://www.howtoforge.com/the-perfect-desktop-kubuntu-11.10 http:/

Tiny thing but Cool command for psql

Let's get in psql interactive by >> psql Yes, If you wanna see all yours db. psql>> \l Select db psql>> \c you will get in selected db, then >> \d    # to display all tables