Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So, let's say I have a file named FILE. Whenever someone wants to edit or read it (for example cat FILE in terminal), it should ask for root password.

How to do this? I suppose there's a chmod command, but I can't figure out, even on the internet.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

If you want that a file could be edited only by root, you should make root the owner of it:

chown root FILE

and then change permissions so that just the owner can write/read it:

chmod 600 FILE

Your solution simply make the file unreadable by everyone. Check permission, owner etc with

ls -l FILE

Consider, too, that the right to delete the file depends on the owner and permission of the directory where it is located, so that if FILE is in directory owned by you, where you have the permission to write to, you can delete FILE.

And again, this will not simply ask for a root password --- it will spew a "permission denied" error, and then you'll have to use sudoto read/edit it.

share|improve this answer
    
Best, thank you! :) –  Vlad Oct 11 '13 at 17:23
add comment

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.