Session saved when sudo. How to when not sudo?


#1

When I run Atom via “sudo Atom” my previous files are restored. When I run atom without sudo privileges, previous files are not restored.

My preference would be that Atom shows two different sets of files depending on whether it is running with super user privileges or not but …

I’d just love to have my session restored when not using sudo.


#2

Atom stores the previous session information in a combination of IndexedDb and the ~/.atom directory. If your ~/.atom directory was created under sudo then when you launch Atom without sudo, Atom won’t be able to update the information. You should check the permissions of the ~/.atom directory and correct them if this is the case.


Atom needs root access to remember my session
#3

I speculate (given what I have just gone through) if any file in the subdirectory tree has the wrong file permissions, Atom will not bring up the prior session.

I thank you, leedohm,for your answer.Atom is now behaving.


#5

Let me add a bit.

To fix ~/.atom consider doing:
sudo chown -R user:group ~/.config/Atom
where
user is whom you are (i.e. “whoami”).
group is the group you want the files to be chown’d to.

Then DON’T do
sudo atom
as you’ll just create more files as root and you’ll be back to square one.

You may wish to, instead, do
su - $USER
atom
exit

Atom will come up asynchronously so that you can exit the superuser command shell so that you do not accidentally remain a superuser in that command shell.

Comments welcome.


#6

Good advice, @RalphShnelvar. Perhaps we should add an enhancement request: when atom is run under su/sudo, it should not save files to the real user’s .atom directory. Not sure how much effort that would be.
Probably also it should warn the user that they’re running as somebody else and it won’t update their local configuration. (Optionally, it could update the effective user’s configuration?)