Creative web design,
Dependable results.

Get a business website you're proud to show off. Contact us today.

FreshBooks

Remote backup, rsync, automatic daily backups
Useful Linux Commands
Friday, 18 February 2011 16:48

Here are a collection of Linux commands that I frequently use when managing my servers and Magento projects.  Enjoy!

Create a compressed file

Usage: tar -cvxf [filename.tar.gz] [location]

Example:

tar -cvxf myfiles.tar.gz *

Create a MySQL database dump

Usage:  mysqldump -h DBHOST -u DBUSER -pDBPASS DBNAME > data.sql

Example:

mysqldump -h localhost -u mysqlusr -pmypassword mydatabase > mydatabase.sql

Import a MySQL database dump into a database

Usage:  mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < backup/data.sql

Example:

mysql -h localhost -u newdbuser -pnewdbpassword newdatabasename < "/path/to/my/database/dump/mydatabase.sql"

Open permissions for Magento Connect

This example is for PHP running as an Apache module (mod_php, DSO).  First navigate to your root magento directory.

find . -type d -exec chmod 777 {} \;
chmod 666 downloader/config.ini
chmod 777 downloader/pearlib/download/package.xml

If you still get errors, try deleting downloader/pearlib/pear.ini.

Reset Magento permissions

find . -type f -exec chmod 644 {} ;
find . -type d -exec chmod 755 {} ;
chmod o+w var var/.htaccess includes includes/config.php app/etc sitemap/sitemap.xml
chmod 550 pear
chmod -R o+w media

Find recently modified files

Usage:  find /path/to/search -type f -mtime -DAYS -print

Example to find files changed in the last 14 days:

find /home/mysite/public_html -type f -mtime -14 -print

Recursively delete all .svn directories

find /path/to/search -name .svn -print0 | xargs -0 rm -rf

Search for text in files (grep)

Usage:  grep [options] [search phrase] [destination]

Example:

grep -R "*wcltestserver2.us*"

 

 

Add comment


Security code
Refresh