Important Commands in Magento 2

To complete magento 2 project it’s really important to have command line understanding. This is not a blog which going to teach you command line from scratch but we’ll cover important commands which we use in magento2 and how you can use in your projects.

  1. Check command log history log
    With the help of this command you can check all command run on that server. You just need to press “up arrow” key check history commands.
  2. Clean and flush cache
    You need to manually refresh cache like magento 1 in magento 2. This easily can be done via command line.
    php bin/magento cache:clean
    php bin/magento cache:flush
    php bin/magento cache:status
    php bin/magento cache:disable
    php bin/magento cache:enable
  3. Re-indexing
    php bin/magento indxer:reindex
    php bin/magento indexer:reset
    php bin/magento indexer:status
    php bin/magento indexer:info
  4. Check site information like admin URL, dependencies etc
    php bin/magento info:adminuri
    php bin/magento info:dependencies:show-modules
    php bin/magento info:language:list
    php bin/magento info:timezone:list

  5. Check deployment mode
    php bin/magento deploy:mode:set production
    php bin/magento deploy:mode:set dev
    php bin/magento deploy:mode:show
  6. Deploy, remove and reset sample data
    php bin/magento sampledata:deploy
    php bin/magento sampledata:remove
    php bin/magento sampledata:reset
  7. Setup upgrade and deploy
    php bin/magento setup:upgrade
    php bin/magento setup:static-content:deploy
    php bin/magento setup:static-content:deploy en_US (You can use this command if you want to do language specific deploment).
    php bin/magento setup:static-content:deploy –theme Vendor/firsttheme(Theme specific deployment)

  8. Create admin user
    php bin/magento admin:user:create –admin-user=’test’ –admin-password=’!admin123!’ –admin-email=’test@test.com’ –admin-firstname=’test’ –admin-lastname=’test’