Copy files with tar, this preserves time/date stamps and permissions nicely.

tar cf - * | ( cd /target; tar xfp -)

Backup and a restore a mySql database:

mysqldump -u username -ppassword database_name > FILE.sql
mysql -u username -ppassword database_name < FILE.sql

Or, perhaps you want to move a bunch of mysql databases from one server to another in one line? Yes you do, and thanks to Marcus here’s how:

mysqldump -u root -pPASSWORD --all-databases | ssh USER@NEW.HOST.COM 'cat - | mysql -u root -pPASSWORD'

List the most visted IP addresses in a default Apache access.log:

less access.log | cut -d '-' -f 1 | sort -r | uniq -c | sort -gr | head -20

Figure out which process is “grabbing” a drive you want to unmount (from Donncha):

# umount /media/disk/
umount: /media/disk: device is busy
# fuser -m /dev/sdc1
/dev/sdc1: 538
# ps auxw| grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox

Sometimes when pasting code in vi, it over-indents. Vim.org has the answer for this:

> All you need to do is "set paste", then paste your stuff, and then "set nopaste" again.

 

That’s all so far.

Close Menu