Tools :: Useful Unix Commands
Quick jump to: [File manipulation] [MySQL]
File manipulation:
Clone/copy files and preserve timestamps, file permissions, and ownership. Run this from the source direcory, or replace the “.” with the name of the directory to clone.
tar cf - . | ( cd /path/to/destination; tar xfp -)
Remove a file that has a filename beginning with a “special” character (such as a hyphen or hash mark.)
In this example, the filenames are as follows:
[user@localhost ~]$ ls -li 6446590 drwxr-xr-x 2 user group 4096 Apr 12 21:24 ?myfilename 6446620 drwxr-xr-x 2 user group 4096 Apr 12 21:24 -myfilename 6446744 drwxr-xr-x 2 user group 4096 Apr 12 21:24 #myfilename [user@host ~]$ find . -inum 6446590 -exec rm {} ; or [user@host ~]$ rm — -myfilename or [user@host ~]$ rm ./#myfilename
Find large files - find your largest users of space.
alias ducks='du -cks * |sort -rn |head -11'
MySQL:
Need to migrate one database to another quickly? Here ya go:
mysqldump --host={source_hostname} \
--password={source_pw} \
--user={source_userid} \
{source_dbname} | \
mysql --host={dest_hostname} \
--password={dest_pw} \
--user={dest_user} \
{dest_dbname}
