Unix Shortcuts

Copy files with tar:

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

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.

Leave a Reply