Undo close tab (Ctrl+Shift+T) not working in Firefox

It's been some time that the Undo Close tab or Ctrl+Shift+T does not work and I am not able to recover even the tab I just closed. I have to manually open it again from history!

How can this problem be solved?


Solution 1:

I noticed that by running Firefox as root (sudo firefox) I am able to do this, but once I come back to normal mode, it does not work again. So it occurred to me that the original problem may have been started when once in the past I executed Firefox as root.

It seems Firefox creates some temporary files and uses them to do these jobs like reopening closed tabs. Since in root mode, the owner of these temporary files is root, in normal mode it cannot overwrite those files and so the related features are disabled!

To fix this I ran this command to change all of the Firefox's config files' ownership to my user using this command:

sudo chown $USER:$USER ~/.mozilla/firefox/ -R

and then I restarted Firefox and it worked.