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
How to Install and Use n98-magerun2 to Manage Magento 2 Websites

Share:

Grow Your eCommerce

Tell us a little about yourself and we’ll guide you through.


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.

 

Table of Contents

Grow Your eCommerce

Tell us a little about yourself and we’ll guide you through.

authorimage

About the Author

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

US Christmas Market Booms: Online Holiday Spending Hits Record $240.8B

It’s Christmas morning, and the Johnson family is gathered around the tree for the gift-opening tradition. Amidst the pile of wrapped presents, Emily has a special announcement that adds to the festive cheer. She reveals that the family’s online boutique, after a recent upgrade to an advanced eCommerce platform, has achieved record sales this holiday […]

WooCommerce Releases Latest Version 9.4.2: Enhancements You Can’t Miss

As a leading open-source eCommerce platform and the go-to eCommerce platform for WordPress, WooCommerce continues to evolve with regular updates designed to enhance user experience, improve performance, and address security vulnerabilities. The latest minor release, WooCommerce 9.4.2, builds upon the robust foundation laid by WooCommerce 9.4.0 and 9.4.1, introducing refinements that eCommerce store owners should […]

Featured image of blog Drive Efficiency, Cut Costs: Hyvä for Magento 2 Outdoor Retail Success

Drive Efficiency, Cut Costs: Hyvä for Magento 2 Outdoor Retail Success

The world of outdoor retail across the globe is evolving and quite rapidly at that. Today, customers want, nay expect, a seamless shopping experience. And this is true no matter if they are browsing online, visiting a physical store, or engaging with the brand on social media. Suffice it to say that an omnichannel approach […]

Talk to a Wagento
Expert Today

Talk to a Wagento
Expert Today