Question: When making changes to my Magento 2 site, I usually run a few of the command line commands to 'refresh' my site to see the changes I've made. The problem is, I'm not too sure what each command really does and when to use a particular one... Meaning I usually run a lot of them 'just to make sure' the site's refreshed and my changes will take effect.

When I make changes to the template `layout.xml` files I just use 

```
php bin/magento cache:clean

```

If I make changes to the `.phtml` files or `.php` files, I usually run:

```
php bin/magento setup:static-content:deploy
php bin/magento setup:upgrade
php bin/magento cache:clean

```

and `php bin/magento cache:flush` – just to make sure!

I have no doubt this is overkill and I'm using some commands unnecessarily.

Could someone explain what each command actually does and when (and why) it would be correct to use each one? 

Here's a list of commands which I think would be useful to know the reasons for using each of them:

1. `php bin/magento cache:clean`
2. `php bin/magento cache:flush`
3. `php bin/magento setup:static-content:deploy`
4. `php bin/magento setup:upgrade`
5. `php bin/magento setup:di:deploy`

For example, if I were to update a `.phtml` file, which commands should I run to make sure I see my changes? A `.php` file? `layout.xml` files?

Thank you!

Answer: 
I am sharing some magento 2 useful commands here:

Magento 2 Upgrade Command:

```
php 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

```
* `php magento/bin cache:clean` : It cleans a cache type = deletes all items from enabled Magento cache types only. This option does not affect other processed or applications because it cleans only the cache that Magento uses. Disabled cache types are not cleaned. Equivalent of clicking the **Flush Magento Cache** button in the backend.

***To use when a modification in a file does not show up.***

* `php magento/bin cache:flush` : it flushes a cache type = purges the cache storage, which might affect other processes applications that are using the same storage. Equivalent of clicking the **Flush Cache Storage** button in the backend.

***To use when a modification in a file does not show up and the cache cleaning did not help.***

Extra information regarding caching: <http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-cache.html>

* `php magento/bin setup:static-content:deploy` : it writes the static files to the Magento file system when Magento is set for production mode. Static files are located under the `pub/static` directory and some are cached in the `var/view_preprocessed` directory.

***To use to deploy static view files when using the production mode***

Extra information regarding static file deployment: <http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-static-view.html>

* `php magento/bin setup:upgrade` : it updates the Magento software. Useful when you add a new module to update the database schema.

***To use after installing/updating a module or after installing/upgrading Magento***

Extra information regarding magento setup script: <http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-subcommands.html>

* `php magento/bin setup:di:deploy` : it runs the compiler to generate code and dependency injection

***To use to compile the code***

Extra information regarding the compiler: <http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-compiler.html>