Useful Unix/Linux Commands for Drupal

Following are some useful Unix/Linux commands which are helpful if you are dealing with large sites (files and db size). I find these really handy when moving sites from one server to other, taking backups of Files, Database etc.

Note: To get access to the Unix command line, you will need an SSH client (e.g. Putty). You can also use WinSCP if you are not comfortable with Command line. WinSCP has a feature to enter custom commands using its interface.

Please add other command-line commands that you use while setting up, developing and managing your Drupal sites.

Zip Contents of current directory
zip -r zipfile.zip *

Unzip Contents into current directory
unzip zipfile.zip

Unzip (and extract) the tar'd, gzipped archive (tarball) Contents into current directory
tar zxvf tarballfile.tar.gz

Remove a directory and its contents (Use with extra care)
rm -rf directoryname

Backup Database
mysqldump dbname -uUSERNAME -pPASSWORD --host HOST > filename.sql

Restore Database
mysql -u root -p[root_password] [database_name] < dumpfilename.sql

Copy all files / directories from one server to other (Both servers should have SSH Support)
rsync -avz --progress username@servername:sourcefolder destinationfolder

Quick install for developers (command line)

This page provides a summary of the command line instructions for installing Drupal on a typical UNIX/Linux web server. Every step contains a link to more detailed installation instructions where you also can find information about installing Drupal on other systems.

Drush - Easily Manage Drupal 'Local' or 'Online' with Unix Command-Line

Drush (Drupal shell) is a program that you can install on your computer and/or on your web-hosting server, which allows you to easily build and maintain all aspects of your Drupal installation, whether that be a 'Local' site on your computer, or an online site.

It is a program with which you use your keyboard to issue Drupal 'text' commands in the Unix language, as opposed to your using the mouse in a visual user interface.

What do all those Unix commands mean?

References to Unix-like (*nix) commands in documentation or forum posts can be intimidating if you're not used to them, but sometimes "command line" is necessary for administering your system or fixing a problem.

Learning some of these *nix commands can help you be more productive, as well as give you insight into what your hosting control panel or GUI FTP client does.

Subscribe with RSS Subscribe to RSS - unix