For no known reason I suddenly have to execute most terminal commands using sudo. For example, I have always been able to run "git pull/push" etc. without any trouble. Now, I get "permission denied". Is there any way of resetting the permissions to default? I'm using OS X Yosemite.
As in the first answer you have run various commands with the elevated command,
sudo, in your personal space. Now you have directories in your personal space that are owned, not by you, but by root. If you type
cd with no parameters you'll be taken to the bottom of your personal space (where it starts) and be able to see it with the
On many system by default your personal space will be /home/[your username].
You can fix this
have to execute most terminal commands using sudo by recovering access to your whole home directory.
Do this by first going to your home directory, then back out a level with
Now execute this command:
$ sudo chown -R [your username] [your username]
If your username is ljames you can do this with this sequence:
$ cd ~ljames $ cd .. $ sudo chown -R ljames ljames
There are a number of ways to do this. I went thought those details to help you to see where the changes are taking place. You can effectively do this in one command line with:
$ sudo chown -R ljames ~ljames
Now when you are working in your own personal space you shouldn't get the
permission denied errors. You should only be denied permission when you're working outside your personal area in what is called
system wide. You'll have to use the elevated command
sudo to make changes in those areas.
This will depend on the permissions of the folders/files you are trying to modify and not on the commands themselves. You probably ran a git command as
sudo once and that changed the ownership to root. I could give you a more specific answer if you posted the output of
ls -l on your
Assuming the problem is what I described above, you can fix it by changing the ownership back to your user (replace
UserFoo with your actual user name):
chown -R UserFoo /path/to/git/folder