Home > How to Install and Use n98-magerun2 to Manage Magento 2 Websites

How to Install and Use n98-magerun2 to Manage Magento 2 Websites

authorimage
authorimage

How to Install and Use n98-magerun2 to Manage Magento 2 Websites

Magento 2 default provides a command-line interface to perform some basic operations like installation, modules enable/disable, admin user creation, cache cleaning, etc.

However, as a Magento 2 developer, you have to perform some additional operations during development like dumping database for development, running cron locally, creating dummy customers, etc. There is no such command available in default CLI to perform these jobs.

n98-magerun2 is a command-line tool that provides some handy commands to manage your Magento 2 websites. With the help of commands, you can perform some important operations in Magento 2 without login to your admin panel.

In this tutorial, we will see how to install n98-magerun2 and an overview of some important commands and its use.

How to Install n98-magerun2

  • Step 1: Download the latest version using wget command

wget https://files.magerun.net/n98-magerun2.phar

  • Step 2: Make the phar file executable

chmod +x ./n98-magerun2.phar

  • Step 3: Copy phar file to /usr/local/bin to use the command system wide

sudo cp ./n98-magerun2.phar /usr/local/bin/

  • Step 4: Verify installation

n98-magerun2.phar –version

If it is installed successfully then the above command will show the output like this

n98-magerun2 version 3.2.0 by netz98 GmbH

Basic n98-magerun2 Commands

We will see some basic command which can be useful in day to day Magento 2 development.

System Information

N98-MAGERUN2.PHAR SYS:INFO

This command will display all the important information about your Magento 2 installation like Magento 2 version, edition, Attributes, Products, Categories, Customers, etc.

Create Customer

N98-MAGERUN2.PHAR CUSTOMER:CREATE

Many times while developing, you need to create dummy customers by filling forms either from the frontend or from the admin panel. Using this command, you can quickly create the customer from the terminal.

Run Cron

N98-MAGERUN2.PHAR SYS:CRON:RUN MY_JOB_CODE

Using this command you can easily run a cron job in your local system while developing as well as in server.

DB dump

N98-MAGERUN.PHAR DB:DUMP –COMPRESSION=”GZ” FILENAME

Using this command you can simply dump the Magento database. Sometimes for local development or for staging sites, you do not need all tables. Using this command you can also exclude some tables.

N98-MAGERUN2.PHAR DB:DUMP –STRIP=”@STRIPPED”

The above command will strip logs and sessions from the database. There are many strip options available you can check in this https://github.com/netz98/n98-magerun2#stripped-database-dump link.

Apart from these commands, there are many commands available in n98-magerun2. You can check all available command by running the below command:

N98-MAGERUN2.PHAR LIST

Summary

N98-magerun2 is a really helpful tool for Magento 2 developers. As a Magento 2 developer, you can perform many operations using this tool which is not possible in default Magento 2 CLI.

If you haven’t already tried n98-magerun2, give it a try today.

 

From Browsing to Buying: Put Wagento’s eCommerce Mastery to Work for You

authorimage
Chirag boasts over 9 years of IT expertise, specializing in Magento 1 and Magento 2 E-commerce. With 8 years of hands-on experience, he excels in developing and deploying complex Magento projects, including extensions and Web Services. Chirag is adept at client communication, daily work management, and leading small teams. He’s proficient in project management tools like JIRA, Zoho Projects, Trello, and Basecamp. 

Related Topics

Your products are the heart of your business. Shouldn’t they have a system for data centralization? The decision to implement a Product Information Management (PIM)

In today’s highly competitive business environment, distinguishing your B2B company from competitors is crucial. Personalization, a strategy that tailors marketing messages and experiences to individual

Creating and maintaining a high-quality website is crucial for businesses in today’s digital age. An essential part of this process is the effective use of

Start Selling with Personalized
eCommerce Solutions