Tuesday, August 2, 2011

Handy Ubuntu commands

Find all files containing a search term and delete them:
find . -type f -exec grep -q "a particular string" {} \; -exec rm -f {} +

Forward a port through a SSH tunnel (in this case POP3):
ssh -f -N -L *:1234:*:110 user@POP3_server

Export mysql databases command-line:
mysqldump -u root -p --databases dbname1 dbname2 | gzip > databasebackup.sql.gz

Import exported databases:
cat databasebackup.sql | mysql -u root -p

Release amavisd blocked mail:
amavisd-release ID (from syslog or wherever)

Reconfigure timezone on ubuntu (NTP needs to be installed first, of course):
dpkg-reconfigure tzdata

Sync whole directories across ssh tunnel with rsync:
rsync -urLptgoDv -e 'ssh -p yoursshport' /sourcedir/ user@server:/targetdir

No comments:

Post a Comment