Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Recently I've noticed that every time I try to use a command like "mkdir", I get "permission denied" when used without "sudo". I guess that's because I am not connected as an admin, only as far as I am concerned (and the System Preferences "Accounts" window) I am.

This happens only after certain time that I do not use the computer.

Any idea why this could happen?

Thanks.

EDIT: The problem happens only with a specific folder, which is used by MAMP PRO. MAMP has its own settings page for the permissions, but when I change owner control to admin, PHP uploads doesn't work. When I change it to _www, everything related to this folder requires authentication.

share|improve this question
    
You forgot to ask a question. –  David Schwartz Aug 3 '12 at 21:39
1  
Well I described a problem and looked for a solution, anyway edited so it's clearer now. Thanks. –  AdamGold Aug 3 '12 at 21:45

1 Answer 1

up vote 3 down vote accepted

If you don't use sudo, you have the privileges of your own user account. If you do use sudo, you have root privileges.

Whether you can do a mkdir without sudo depends on the ownership and permissions of the current directory. If you're in a directory that you own (such as your home directory), you should be able to mkdir without any problem.

Note that sudo mkdir has effects other than increasing your privilege level. It runs the mkdir command under the root account -- which means that the newly created directory will be owned by root, not by you. If you've been habitually using sudo mkdir, you'll have created directories that you don' have permission to modify from your own user account.

Run ls -ld DIRNAME to see the ownership and permissions of any directory.

It rarely makes sense to have root-owned files or directories anywhere under your own home directory (~, $HOME). If you've accidentally created such files or directories, you can use

sudo chmod $USER ...

to change their ownership back to your own account.

And don't use sudo unless you really need to.

share|improve this answer
    
I am the administrator, the thing is that I am required to input a password to verify each action I do, not only in the terminal - Also when I move files and rename. This happens only after a certain time (1-2 hours) that I don't use the computer. –  AdamGold Aug 3 '12 at 21:55
2  
I think being the "adminstrator" just means you're able to use sudo. When you run sudo ... and enter your password, it remembers it for 15 minutes (unless it's configured differently). Are these files you're manipulating under your home directory or elsewhere? –  Keith Thompson Aug 3 '12 at 22:08
    
They're under my home directory. –  AdamGold Aug 3 '12 at 22:09
    
@AdamGold: Normally, you should never need to use sudo to manipulate files under your home directory; they should all be owned by your user account. If they're owned by root, it's probably because you've used sudo unnecessarily. –  Keith Thompson Aug 3 '12 at 22:13
    
Okay, I will delete the folder I've created with sudo and will manually create it. How do I fix the problem with the permissions? –  AdamGold Aug 3 '12 at 22:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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