How to Install "Drush" for Drupal on a CentOS 7 Server

Drush is a command line shell and can be used for Drupal as a scripting interface.  Drush comes with an array of features that allows you to run different commands and code to interact with themes, modules, and profiles. You can even us Drush to download and install Drupal!

Users can also find Drush useful in performing specific administrative tasks which is a more efficient than using the Drupal panel on their web browser. You can run an update.php, execute DB migrations and sql queries with this service.

This tutorial will take your through the process of installing Drush for Drupal on CentOS 7. It assumes that you know the basics on how to use Linux, host your websites on a personal VPS, and you understand how to use the shell.

In this case, your website should be running on the root account. If this is not the case, you need to include the text “sudo” when running your commands to enjoy the privileges of using a root account.

Special note: HostAdvice features several specialized Drupal Hosting Services that offer great prices, features and support for Drupal users.

Step 1:
Installing Drush

Start by downloading and installing Drush command software. This can be done in several ways as discussed below.

Using package manager.

If you’re using Linux, you can install Drush using the package manager which is part of its operating system. The OS package manager may also be used in installing an older version of this software.

For CentOS, run the command below:

$ sudo yum install drush

Using Composer

You can also use Composer to install Drush. Run the command below:

$ composer global require drush/drush:6.*

You need to ensure that the binary directory on your Composer is included on your system path:

$ sed -i '1i export PATH="$HOME/.composer/vendor/bin:$PATH"' $HOME/.bashrc

Manual Installation

Drush can also be downloaded manually and installed on your system. But you must install Composer first before you install Drush. Run the command below to start the process:

# Create a bin directory for your user account and add to system path

$ mkdir $HOME/bin
echo "PATH=$HOME/bin:$PATH" >> ~/.bashrc
source ~/.bashrc

# Download and unzip the Drush software

wget -O $HOME/bin/
unzip -d $HOME/bin $HOME/bin/

# Install Drush dependencies with Composer (assumes `composer` is on system PATH)

cd $HOME/bin/drush-master
composer install

# Create a symbolic link

ln -s $HOME/bin/drush-master/drush $HOME/bin/drush

Step 2:
Launch Drush

Once you have successfully downloaded and installed Drush software on your system, open your Console or Terminal application and type drush then hit the “Enter” button. You should have an output like this:

Execute a drush command. Run `drush help [command]` to view command-specific help.  Run `drush topic` to read even more documentation.
Global options (see `drush topic core-global-options` for the full list):
 -d, --debug                               Display even more information, including internal messages.                                                 
 -h, --help                                This help system.                                                                                           
 -n, --no                                  Assume 'no' as answer to all prompts.                                                                       
 -r <path>, --root=<path>                  Drupal root directory to use (default: current directory).                                                  
 -s, --simulate                            Simulate all relevant actions (don't actually change the system).                                           
 -l <>,             URI of the drupal site to use (only needed in multisite environments or when running on an alternate port). 
 -v, --verbose                             Display extra information about the command.                                                                
 -y, --yes                                 Assume 'yes' as answer to all prompts.
Core drush commands: (core)
 archive-dump (ard,    Backup your code, files, and database into a single file.                                                                                    
 archive-backup, arb)                                                                                                                                               
 archive-restore       Expand a site archive into a Drupal web site.                                                                                                
 cache-clear (cc)      Clear a specific cache, or all drupal caches.                                                                                                
 cache-get (cg)        Fetch a cached object and display it.                                                                                                        
 cache-set (cs)        Cache an object expressed in JSON or var_export() format.                                                                                    
 core-config (conf,    Edit drushrc, site alias, and Drupal settings.php files.                                                                                     
 core-cron (cron)      Run all cron hooks in all active modules for specified site.                                                                                 
 core-execute (exec,   Execute a shell command. Usually used with a site alias.                                                                                     
 core-quick-drupal     Download, install, serve and login to Drupal with minimal configuration and dependencies.                                                    
 core-requirements     Provides information about things that may be wrong in your Drupal installation, if any.                                                     
 (status-report, rq)                                                                                                                                                
 core-rsync (rsync)    Rsync the Drupal tree to/from another server using ssh.                                                                                      
 core-status (status,  Provides a birds-eye view of the current Drupal installation, if any.                                                                        
 core-topic (topic)    Read detailed documentation on a given topic.                                                                                                
 drupal-directory      Return path to a given module/theme directory.                                                                                               
 help                  Print this help message. See `drush help help` for more options.                                                                             
 image-flush           Flush all derived images for a given style.                                                                                                  
 php-eval (eval, ev)   Evaluate arbitrary php code after bootstrapping Drupal (if available).                                                                       
 php-script (scr)      Run php script(s).                                                                                                                           
 queue-list            Returns a list of all defined queues                                                                                                         
 queue-run             Run a specific queue by name                                                                                                                 
 search-index          Index the remaining search items without wiping the index.                                                                                   
 search-reindex        Force the search index to be rebuilt.                                                                                                        
 search-status         Show how many items remain to be indexed out of the total.                                                                                   
 shell-alias (sha)     Print all known shell alias records.                                                                                                         
 site-alias (sa)       Print site alias records for all known site aliases and local sites.                                                                         
 site-install (si)     Install Drupal along with modules/themes/configuration using the specified install profile.                                                  
 site-set (use)        Set a site alias to work on that will persist for the current session.                                                                       
 site-ssh (ssh)        Connect to a Drupal site's server via SSH for an interactive session or to run a shell command                                               
 test-clean            Clean temporary tables and files.                                                                                                            
 test-run              Run tests. Note that you must use the --uri option.                                                                                          
 updatedb (updb)       Apply any database updates required (as with running update.php).                                                                            
 updatedb-status       List any pending database updates.                                                                                                           
 usage-send (usend)    Send anonymous Drush usage information to statistics logging site.  Usage statistics contain the Drush command name and the Drush option     
                       names, but no arguments or option values.                                                                                                    
 usage-show (ushow)    Show Drush usage information that has been logged but not sent.  Usage statistics contain the Drush command name and the Drush option names, 
                       but no arguments or option values.                                                                                                           
 variable-delete       Delete a variable.                                                                                                                           
 variable-get (vget)   Get a list of some or all site variables and values.                                                                                         
 variable-set (vset)   Set a variable.                                                                                                                              
 version               Show drush version.                                                                                                                          
 watchdog-delete       Delete watchdog messages.                                                                                                                    
 (wd-del, wd-delete)                                                                                                                                                
 watchdog-list         Show available message types and severity levels. A prompt will ask for a choice to show watchdog messages.                                  
 watchdog-show         Show watchdog messages.                                                                                                                      
 (wd-show, ws)
Runserver commands: (runserver)
 runserver (rs)        Runs a lightweight built in http server for development.
Field commands: (field)
 field-clone           Clone a field and all its instances.                         
 field-create          Create fields and instances. Returns urls for field editing. 
 field-delete          Delete a field and its instances.                            
 field-info            View information about fields, field_types, and widgets.     
 field-update          Return URL for field editing web page.
Project manager commands: (pm)
 pm-disable (dis)      Disable one or more extensions (modules or themes).                                                                
 pm-download (dl)      Download projects from or other sources.                                                                
 pm-enable (en)        Enable one or more extensions (modules or themes).                                                                 
 pm-info (pmi)         Show detailed info for one or more extensions (modules or themes).                                                 
 pm-list (pml)         Show a list of available extensions (modules and themes).                                                          
 pm-refresh (rf)       Refresh update status information.                                                                                 
 pm-releasenotes       Print release notes for given projects.                                                                            
 pm-releases (rl)      Print release information for given projects.                                                                      
 pm-uninstall          Uninstall one or more modules.                                                                                     
 pm-update (up)        Update Drupal core and contrib projects and apply any pending database updates (Same as pm-updatecode + updatedb). 
 pm-updatecode (upc)   Update Drupal core and contrib projects to latest recommended releases.                                            
 pm-updatestatus       Show a report of available minor updates to Drupal core and contrib projects.                                      
Role commands: (role)
 role-add-perm (rap)   Grant a specified permission to a role.                                                                                                      
 role-create (rcrt)    Create a new role.                                                                                                                           
 role-delete (rdel)    Delete a role.                                                                                                                               
 role-list (rls)       Display a list of all roles defined on the system.  If a role name is provided as an argument, then all of the permissions of that role will 
                       be listed.  If a permission name is provided as an option, then all of the roles that have been granted that permission will be listed.      
 role-remove-perm      Remove a specified permission from a role.                                                                                                   
SQL commands: (sql)
 sql-cli (sqlc)        Open a SQL command-line interface using Drupal's credentials.            
 sql-connect           A string for connecting to the DB.                                       
 sql-create            Create a database.                                                       
 sql-drop              Drop all tables in a given database.                                     
 sql-dump              Exports the Drupal DB as SQL using mysqldump or equivalent.              
 sql-query (sqlq)      Execute a query against the site database.                               
 sql-sync              Copy and import source database to target database. Transfers via rsync.
User commands: (user)
 user-add-role (urol)  Add a role to the specified user accounts.                                    
 user-block (ublk)     Block the specified user(s).                                                  
 user-cancel (ucan)    Cancel a user account with the specified name.                                
 user-create (ucrt)    Create a user account with the specified name.                                
 user-information      Print information about the specified user(s).                                
 user-login (uli)      Display a one time login link for the given user account (defaults to uid 1). 
 user-password (upwd)  (Re)Set the password for the user account with the specified name.            
 user-remove-role      Remove a role from the specified user accounts.                               
 user-unblock (uublk)  Unblock the specified user(s).
Other commands: (make,sar)
 make                  Turns a makefile into a working Drupal codebase.  
 make-generate         Generate a makefile from the current Drupal site. 
 search-and-replace    Replace strings in text fields in all content.    


From the output above, it’s clear that Drush can be installed in different ways. Now you can comfortably repeat the same process for your system and install Drush for Drupal on a CentOS 7 server. Try it out!


Check out these top 3 Drupal hosting services:

$1.79 /mo
Starting price
Visit HostArmada
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$1.00 /mo
Starting price
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing
$2.03 /mo
Starting price
Visit Ultahost
Rating based on expert review
  • User Friendly
  • Support
  • Features
  • Reliability
  • Pricing

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How to Set Up SSH on a CentOS 7 VPS from a Windows Client

Download puttygen into the Windows machine as shown in figure 1. Then sta
4 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester

How to install Django on a CentOS 7 VPS or Dedicated Server

When building a website, similar components are required, and you do not have to
3 min read
Mark Armistead
Mark Armistead

How to Install the MEAN Stack on Your CentOS 7 VPS or Dedicated Server

This how-to article will show you how to install the MEAN (MongoDB, Express, Ang
2 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top