Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 Tarniceru Oct 11 '13 at 17:23

Your Answer


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.