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`**
Cleaning a cache type deletes all items from enabled Magento cache types only. In other words, this option does not affect other processes or applications because it cleans only the cache that Magento uses.
Disabled cache types are not cleaned.

if your cache are enable in admin that time, if you **edit xml** file you must required this command to see chagnes.

For **.phtml** file case, Your cache are enable in admin this command is used for see changes.
If you have disable only full\_page\_cache from admin and all others are enable that time you doesn't required to call this command. 

**`php magento/bin cache:flush`**
Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage.

**`php magento/bin setup:static-content:deploy`**

This is used for deployment of your theme. Using this command if you have create new theme and want to deploy new theme then its useful.
Ex. If you want to override base module **web/template/\*.htm**l file into your theme, Its must run this command to affect the chagnes on frontend.

If you are changing **Frontend Development workflow** from admin,

```
Stores -> Configuration -> Advanced -> Frontend Development workflow

```

Changes type from server side to client side less compilation in develoer mode.
This command is useful for above schenario. 

**`php magento/bin setup:upgrade`**,
This command is used for updates the Magento sites. its required when you add a new module to update the database schema or upgrade already installed module to see changes.

**`php magento/bin setup:di:deploy:`**
This command is used for compiler generation code and dependancy injections.