Installing Modules and Themes Drupal from Drush CLI On FreeBSD

Every Drupal website consists of many Drupal projects such as modules and themes. A module is a collection of PHP, JavaScript, or CSS files that extend website features and add functionality to your Drupal website. In Drupal10, you can activate or deactivate all module features and functionality very easily.

All these modules are stored in Drupal core which provides a very complete and powerful set of features. Thanks to Drupal's configuration management system, you can change and build many features for general and modern websites without having to write a single line of code. Everything is available in Drupal10.

Drupal is famous for having many modules, you can use different modules to design your website. Modules in Drupal are additions, or extensions, that can be added to the core of your Drupal site. Modules are usually built to perform a single function or a collection of related functions. Look at the Drupal model architecture diagram below.

Meanwhile, a theme is a part of Drupal or a collection of files that determine the appearance of your Drupal website. Themes are used to control page layout, colors, fonts, text styles, and more. Anyone who views your Drupal website will see the Drupal theme. Every time a page is requested, Drupal does the work of assembling the content to be displayed into structured data which is then handed off to the presentation layer to determine how to display the Drupal website data.

In Drupal, themes are created by front-end developers or often referred to as themesrs, or theme developers. The theme consists of standard web assets such as JavaScript, PHP, CSS and images combined with custom Drupal templates to generate HTML markup, and YAML files.

Themes can be created from scratch and can also be downloaded from the official Drupal repository or you can purchase from third-party vendors. Before the theme is activated, the theme file must be placed in the themes folder. Drupal also includes a number of pre-installed themes, located in the core/themes folder of your installation.

At the end of this tutorial you will understand the Drush commands for installing Drupal modules and themes. This article was written using the FreeBSD 13.2 Stable server. You can also apply the entire contents of this article to Linux or other systems.

1. Install the Drupal module

Drush comes with a set of commands built around extension management and usually Drush commands start with the pm prefix. In previous versions of Drush, before Drupal adopted Composer, the list of drush pm commands was longer. Now Composer is recommended for managing dependencies. In older versions of drush, the download command typically uses "drush pm:download" or "drush dl" to download contributed modules from You should now use "composer require" instead.

Before you start installing modules, look at the list of available modules.
root@ns3:~ # drush pm:list
Run the command "drush pm:list --type module" to see a list of all the modules available on your site.
root@ns3:~ # drush pm:list --type module
To activate one or many modules in Drupal commands with Drush, run the following command for many modules "drush pm:enable module_1, module_2", whereas if you want to activate one module, run the command "drush pm:enable module_1".

The Drush command above is very widely used by web developers. You can also write an alias in the command above, such as "drush en module_1".

You can run the command above if the module is available in the "/usr/local/www/drupal10/core/modules" directory. What if the module does not exist in that directory. You must first run the installation command, so that the module is available in that directory. Run the command "composer require".

For example, we are going to install the "devel" module and it is not available in the "/usr/local/www/drupal10/core/modules" directory. Follow the steps below.
root@ns3:~ # cd /usr/local/www/drupal10
root@ns3:/usr/local/www/drupal10 # composer require drupal/devel
root@ns3:/usr/local/www/drupal10 # drush en devel -y
To see the results, whether the "devel" module is active or not, you can run the following command.
root@ns3:~ # drush pm:list --type module
In this article we will demonstrate how to install and activate the following Drupal modules:
Admin Toolbar

a. Enable the Admin Toolbar Module
root@ns3:~ # cd /usr/local/www/drupal10
root@ns3:/usr/local/www/drupal10 # composer require drupal/admin_toolbar
root@ns3:/usr/local/www/drupal10 # drush pm:enable admin_toolbar

b. Enable the IMCE Module
root@ns3:/usr/local/www/drupal10 # composer require drupal/imce
root@ns3:/usr/local/www/drupal10 # drush pm:enable imce

c. Enable the PathAuto Module
root@ns3:/usr/local/www/drupal10 # composer require drupal/pathauto
root@ns3:/usr/local/www/drupal10 # drush pm:enable pathauto

d. Enable the Google Analytics Module
root@ns3:/usr/local/www/drupal10 # composer require drupal/google_analytics
root@ns3:/usr/local/www/drupal10 # drush en google_analytics

e. Enable the Chaos Tool Suite Module
root@ns3:/usr/local/www/drupal10 # composer require drupal/ctools
root@ns3:/usr/local/www/drupal10 # drush en ctools
In the command above "drush en" is the alias of "drush pm:enable". All the modules installed above are saved in the directory "/usr/local/www/drupal10/modules/contrib".

f. Drupal Module From Github

If the Drupal module you want to activate comes from the Github repository. Follow the steps below to activate it.
root@ns3:~ # cd /usr/local/www/drupal10/modules/contrib
root@ns3:/usr/local/www/drupal10/modules/contrib # git clone
root@ns3:/usr/local/www/drupal10/modules/contrib # cd /usr/local/www/drupal10
root@ns3:/usr/local/www/drupal10 # composer require contrib/drupal-libraries-installer
root@ns3:/usr/local/www/drupal10 # drush en libraries

2. Uninstall the Drupal module

How to uninstall Drupal modules with drush is the easiest method to uninstall a module. Drush allows users to perform administrative activities in a series of simple commands, one of which is the delete module command. The following is how to delete a Drupal module.
root@ns3:/usr/local/www/drupal10 # composer remove drupal/admin_toolbar
root@ns3:/usr/local/www/drupal10 # composer remove drupal/google_analytics
root@ns3:/usr/local/www/drupal10 # composer remove drupal/devel
The command above deletes the "admin_toolbar, google_analytics, devel" module and also deletes the entire directory contents of that module in the "/usr/local/www/drupal10/modules/contrib" directory.

Next, you delete or clear the cache using the Drush command.
root@ns3:/usr/local/www/drupal10 # drush cr
With the "drush cr" command, the uninstalled module will no longer be displayed in the module list and the module functionality will be removed from the site.

3. Install the Drupal Themes

Before your website is displayed or seen by many people, first, you must determine the theme as the default appearance of your website. This applies whether it's a custom theme you wrote yourself, a theme you downloaded from or a theme you purchased from a third party. Installing themes can be done through the user interface, or using Drush. Once the theme is installed, your site users will see all public pages rendered using the theme.

Follow the steps below to start installing and activating the theme by default.
root@ns3:~ # cd /usr/local/www/drupal10
root@ns3:/usr/local/www/drupal10 # composer require drupal/bootstrap
root@ns3:/usr/local/www/drupal10 # chmod 775 /usr/local/www/drupal10/themes/contrib
The above command is used to download the theme with the name bootstrap and provide file permissions. After that, you activate the bootstrap theme with the following command.
root@ns3:/usr/local/www/drupal10 # drush theme:enable bootstrap
root@ns3:/usr/local/www/drupal10 # drush config-set system.theme default bootstrap
In Google Chrome, open your website, and the new theme will appear on your Drupal website.

To complete the content of this article, we will demonstrate how to install and activate a theme from the Github repository. You can open the website at "".
root@ns3:~ # cd /usr/local/www/drupal10/themes/contrib
root@ns3:/usr/local/www/drupal10/themes/contrib # git clone
After completing cloning/downloading, activate the theme with the following command.
root@ns3:/usr/local/www/drupal10/themes/contrib # cd /usr/local/www/drupal10
root@ns3:/usr/local/www/drupal10 # composer require drupal/design-drupal-theme
root@ns3:/usr/local/www/drupal10 # drush theme:enable adminimal_theme
root@ns3:/usr/local/www/drupal10 # drush config-set system.theme default adminimal_theme
To see the results of the theme that you have activated, open Google Chrome and type in the URL of your Drupal website.

If you understand how to install and activate a theme, we continue with deleting the theme. The command to delete a theme is very easy, you just use the "composer remove" command, look at the example below to delete the bootstrap theme.
root@ns3:/usr/local/www/drupal10 # composer remove drupal/bootstrap
The discussion in this article is only part of the use of basic Drupal commands. There are still many discussions that we have not discussed. You can continue following this article to better understand the use of Drupal.
    Iwan Setiawan

    I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

    Post a Comment

    Previous Post Next Post