Controlling M2 via command line – when and why to use each command

Magento 2 Upgrade Command:

php -d set_time_limit=3600 -d memory_limit=1024M bin/magento setup:upgrade

Magento 2 reindex Command:

php bin/magento indexer:reindex

Magento 2 flush cache Command:

php bin/magento cache:flush

Magento 2 static content deploy Command:

php bin/magento setup:static-content:deploy

Magento 2 check developer mode Command:

php bin/magento deploy:mode:show

Magento 2 set developer mode Command:

php bin/magento deploy:mode:set developer
php bin/magento deploy:mode:set production

Magento 2 static content deploy Command if get memory error:

php -dmemory_limit=6G bin/magento setup:static-content:deploy

Magento 2 Disable module command:

php bin/magento module:disable Module_Name

Magento 2 enable module command:

php bin/magento module:enable Module_Name

Magento 2 command to find the all disabled/enabled module command:

php bin/magento module:status

How to Start/Stop/Restart the Datadog Agent

Mac OS X

To manually start the Agent:

/usr/local/bin/datadog-agent start

To stop the Agent:

/usr/local/bin/datadog-agent stop

To restart the Agent

/usr/local/bin/datadog-agent restart


To manually start the Agent:

sudo /etc/init.d/datadog-agent start

To stop the Agent:

sudo /etc/init.d/datadog-agent stop

To restart the Agent

sudo /etc/init.d/datadog-agent restart


Windows service



How to Setup Git on Windows & Mac

Step 1: Add your PC/Mac ssh key to your account.
1. If you are using Mac run following commands in Terminal window or if you are using Windows install GitBash command utility ( ) to run following commands.

Step 2. Create your SSH Keys:
2.1.Before generating an SSH key in your shell, check if your system already has
one by running the following command:

 cat ~/.ssh/

2.2.if keys are not there then generate a new SSH key, use the following

ssh keygen -t rsa -C"$your_email"

Note:This command will prompt you for a location and filename to store the
key pair and for a password. When prompted for the location and filename,
just press enter to use the default.
2.3. To copy your public key to the clipboard, use the code below. Depending on
your OS you’ll need to use a different command:

 For Windows: clip < ~/.ssh/
 For Mac: pbcopy < ~/.ssh/

Step 3. Open Git repository from you credentials and Add your SSH Key
3.1. On the left side menu, click on “profile settings” and then click on “SSH Keys”:

Screen Shot 2016-08-31 at 11.43.36 AM

3.2. Then click on the green button “Add SSH Key”

3.3. There, you should paste the SSH Key which you copied from command line.

Screen Shot 2016-08-31 at 11.43.52 AM

Note:Now, you’ll be able to use Git over SSH

How to install Tomcat-8.5.3 on mac/linux

  1. Download a binary distribution of the core module: apache-tomcat-8.5.3.tar.gz from here. I picked the tar.gz in Binary Distributions / Core section.
  2. Opening/unarchiving the archive will create a folder structure in your Downloads folder: (btw, this free Unarchiver app is perfect for all kinds of compressed files and superior to the built-in Archive ~/Downloads/apache-tomcat-8.5.3
  3. Open to Terminal app to move the unarchived distribution to /usr/local
    sudo mkdir -p /usr/local
    sudo mv ~/Downloads/apache-tomcat-8.5.3 /usr/local
  4. To make it easy to replace this release with future releases, we are going to create a symbolic link that we are going to use when referring to Tomcat (after removing the old link, you might have from installing a previous version):
     sudo rm -f /Library/Tomcat
     sudo ln -s /usr/local/apache-tomcat-8.5.3 /Library/Tomcat
  5. Change ownership of the /Library/Tomcat folder hierarchy:
     sudo chown -R <your_username> /Library/Tomcat
  6. Make all scripts executable:
 sudo chmod +x /Library/Tomcat/bin/*.sh

Instead of using the start and stop scripts, like so:

$ /Library/Tomcat/bin/
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar
Tomcat started.

$ /Library/Tomcat/bin/
Using CATALINA_BASE: /Library/Tomcat
Using CATALINA_HOME: /Library/Tomcat
Using CATALINA_TMPDIR: /Library/Tomcat/temp
Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
Using CLASSPATH: /Library/Tomcat/bin/bootstrap.jar:/Library/Tomcat/bin/tomcat-juli.jar

Finally, after your started Tomcat, open your Mac’s Web browser and take a look at the default page:http://localhost:8080

How to install SSL certificate on ubuntu(Magento)

Step1) Change to the Apache SSL Certificate directory:

cd /etc/apache2/ssl


If it doesn’t exist then create it:

sudo mkdir /etc/apache2/ssl

Step2). You need three files:

– The public key provided by the Certificate Authority
– The Private key from your server which you created and submitted to the Certificate Authority
– The Intermediate or Chain Certificate provided from your Certificate Authority

Move them all to the /etc/apache2/ssl directory and name them appropriately

Step3) . Modify your virtual hosts file and add the config to listen on port 443:

<VirtualHost *:443>

DocumentRoot /var/www/html/path_to_your_site
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/your_domain_public.crt // The Public Key provided from the Certificate Autority
SSLCertificateKeyFile /etc/apache2/ssl/your_domain_private.key // The key you created initially (probably using OpenSSL and submitted to the Certificate Authority)
SSLCertificateChainFile /etc/apache2/ssl/your_domain_intermediate.crt // The Intermediate Certificate provided from the Certificate Autority

<Directory /var/www/html/path_to_your_site/>
AllowOverride All


Step4) Restart the Apache service using

Now you should be able to navigate to load your site using HTTPS but depending on your CMS or Shopping Cart platform you may need to make a config change in the admin area to force it to use HTTPS.


To change this in Magento navigate to:

System->Configuration->General->Web->Unsecure and System->Configuration->General->Web->Secure



Browser Cache Cleaning of Chrome & Safari

Cache Cleaning for Chrome

Step 1 ) Click on the settings icon that appears to the right of the address bar. In the newest versions of Chrome, this appears as three horizontal lines and in older versions will be a wrench icon .

Step 2) From the menu, select Tools > Clear browsing data….


Step 3) Check the following:

  • Empty the cache
  • Delete cookies and other site and plug-in data

Select the beginning of time in the drop down box and click on the Clear browsing data button.


Cache Cleaning for Safari

Step 1)  Click Safari in the upper left hand side of your screen. In the menu that appears, click Preferences.


  1. Step 2) In the window that appears, click the Privacy tab. Click the button Remove All Website Data….


  1. Step 3) Click Remove Now in the pop up window that appears.


How to Import/Export a Products in Magento

Step 1) Click on System –> Import/Export–>Dataflow-Profiles and you will see this


Step 2) Now After Click on Dataflow-Profiles you will see this


Step 3) Now Click on Add New Profile & it will take you on a new window


Step 4) Now fill all the details in the Columns which i fill below image.


Step 5) Now After Filling all the details click on Save and Continue Edit button


Step 6) Now if you want to Export Product just click on Run Profile in Popup button.It will take a time to download your file so just relax for a 5 minute.

Step 7 ) After All If you want to Import your Product just Follow Above step only change the Import option which i show you in a image


Twilio Test Application in Node js

First things first – if you have not yet installed Node.js on your system, you can download an installer for your platform from

Next, install the Twilio module using npm, in the same directory as “Twilio.js”

[sudo] npm install twilio
var twilio = require('twilio');
var client = new twilio.RestClient('TWILIO_ACCOUNT_SID', 'TWILIO_AUTH_TOKEN');
// REST client will handle authentication and response serialzation for you.
 body:'Hello World'
}, function(error, message) {
 if (!error) {
 // information about the text messsage you just sent:
 console.log('Success! The SID for this SMS message is:');
 console.log('Message sent on:');
 } else {
 console.log('Oops!This number is invalid.');

To run this code, return to the terminal and run

node Twilio.js


Setup a Mosquitto Password

sudo service mosquitto stop
cd /usr/local/bin
If you already Created a Password & want to change that then using below Command
mosquitto_passwd -D /etc/mosquitto/passwd username
Below Command is for New Password Creation
mosquitto_passwd -c /etc/mosquitto/passwd username
sudo nano /etc/mosquitto/mosquitto.conf
allow anonymous false
#Default authentication and topic access control

#password_file /etc/mosquitto/passwd
 sudo service mosqquitto start
 sudo service mosquitto status

How to Create a Proxy Layer Between MQTT Broker & AWS IOT Broker

Create Proxylayer.js file and paste the following code into it:

var mqtt = require('mqtt'), url = require('url');
var client = mqtt.connect('mqtt://localhost:1883',
username: '<username>',
password: '<password>'

console.log("Connected to MQTT Broker:- localhost” + client.toString());
var awsIot = require('aws-iot-device-sdk');
var device = awsIot.device({

keyPath:  Certificate key file path,
certPath: Certificate file path,
caPath:   Certificate root file path,
clientId: AWS Thing Name,
region:   AWS IoT Broker region,

device.on('connect', function ()
console.log("Connected to AWS IoT Broker:- " + device.toString());

client.on('connect', function()
//subscribe to a topic (#)
client.subscribe('#', function ()
client.on('message', function (topic, message, packet) {
console.log("Received :-" + message + " on " + topic);
device.publish(topic, message);
console.log("Sent :-" + message + " on " + topic);