0

I cannot do anything in ubuntu without being root all of a sudden. When I run emacs it says it cannot access files (and will run in sudo and works fine). firefox throws security issues until im root etc. and have no idea how to fix this.

I dropped down into su and purged sudo and reinstalled thinking this would fix it (bc at one point i edited my sudoers file with emacs vs visudo) but to no avail. any ideas? this is a very annoying experience

edit: for more information. prior to this I was trying to run Virtualbox as sudo (the gui version) and was having issues with it saying it could not access a given machine. So i wanted to ensure ALL my commands were ran as root so i added myself into sudoers file (username (ALL) = (All) etc. syntax) and everything was ok for some time. then these issues came about with firefox and emacs etc. so I am guessing somehow I have unknowingly removed myself from groups that did have access to these files in the past

edit no.2: for the specific error when emacs start it says "cannot open load file :/home/path.../.emacs.d/elpa/asynch-20151104.2113/async-pkg ... now this ONLY happens when I do not run as sudo from terminal. could it be I messed with the pkg permission? The firefox error was similar to this (Error code: sec_error_bad_signature) however I cannot replicate the issue after deleting my ~/.modzilla folder. any ideas?

  • 1
    Did you undo changes to the sudoers file ? Have you recently done any task that could potentially alter permissions or ownership of files ? sudo isn't the problem here, that what you have to keep in mind. – Sergiy Kolodyazhnyy Mar 2 '16 at 1:27
  • Can you provide us with clues as to what you might have been doing prior to "I cannot do anything in ubuntu without being root all of a sudden." All I can guess from your question as written is that you've somehow screwed up permissions. Please edit any pertinent info into your question. Thank you for helping us help you. Also please review askubuntu.com/help/how-to-ask – Elder Geek Mar 2 '16 at 1:27
  • You've run something as root, and changed some ownership. sudo find $HOME \! -user $USER -ls will detect them – waltinator Mar 2 '16 at 1:31
  • When I run emacs it says it cannot access files - which files? I cannot do anything in ubuntu without it being root - what are some more examples of things you cannot do, and what are the error messages you are getting? – thomasrutter Mar 2 '16 at 5:26
  • @thomasrutter I have updated the question with more info. thanks for the help! – Maximus12793 Mar 2 '16 at 20:32
0

It sounds like you have root-owned files in your home directory.

This may have been caused by running applications with sudo in the past, and those applications saving files to your home directory.

To find a list of root-owned files in your home directory, try

find /home/ -uid 0

You can then chown them back to your user as appropriate.

chown myuser:myuser -R [files]

Where files is the particular files or subdirectory. It's usually not a good idea to run a command like this across your whole home directory, on the off chance that some file ownerships are deliberate or necessary for something.

As to what caused the problem, certain applications will store files in your home directory during their normal operation, such as configuration or cache files. This is very common with graphical applications, but some non-graphical applications may still do this. Now, if you use sudo, and an application does this, it will create root-owned files in your home directory. Then, future attempts to run this application without root may fail, because now there are files that can only be opened by root.

The solution is to change the owner of those files back to your user, or to delete them if you don't think they are vital.

To avoid this problem in future, when using sudo, you could use

sudo -H [command]

If it's a graphical application you could alternatively use

gksudo [command]

This tells the application to use the root user's home directory instead of your own home directory.

  • thank you! this worked perfectly. I was thinking since my user was admin level it would have no issues working with root files. – Maximus12793 Mar 3 '16 at 22:38
  • Ah I see. Your user being "admin level" only allows it to be granted superuser (root) privileges eg through sudo, but during normal operation it's still limited to the privileges of a normal user. – thomasrutter Mar 3 '16 at 23:44
  • I had one question about that, if I edit the sudoers file will my user be able to access those files all the same as if I were root? I don't know if that is bad practice but is sometimes a hassle to run things with sudo all the time when it is a personal machine. – Maximus12793 Mar 4 '16 at 2:44
  • sudoers file affects what permissions you can get with sudo, not what you can do without sudo. You probably already have full permissions with sudo. – thomasrutter Mar 4 '16 at 3:38

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.