Magento – magento 2 | Categories not showing in Admin Product Edit Page

backendcategoryproduct

I have started working with magento earlier this year, I am running magento CE 2.2.2

I have noticed that when I go back to edit a product from the catalog I have noticed that the categories are not listed.

I have checked the frontend and item visible in the category, the problem is in the backend, you can see the attachment image below.

Does anyone encounter the problem or know a solution that can be applied?

here you can see the categories I chose during product setup:
enter image description here
image url

but it is showing like this when I go to edit, which makes it impossible to edit categories:
enter image description here
image url

Best Answer

Solution is following sequence of commands:

sudo chmod -R 777 var/ generated/ pub/static/ app/etc/ pub/media/
php bin/magento indexer:reindex
sudo chmod -R 777 var/ generated/ pub/static/ app/etc/ pub/media/
php bin/magento cache:flush