How can I check and set who can view or open a given folder or file?

link|improve this question

44% accept rate
feedback

1 Answer

up vote 7 down vote accepted

To check:

ls -l /path/to/folder/or/file

or for more verbose output:

stat /path/to/folder/or/file

To change owner:

chown someuser:somegroup /path/to/folder/or/file

To change permissions:

chmod 755 /path/to/folder/or/file

man chown and man chmod will give you explanation about the various options.

Or, if you are using some graphical environment, such as Gnome, you can just right-click the files/folders and set the permissions there.

EDIT: Changed file -> stat. Thanks for correction!

link|improve this answer
2  
This suffices 99% of the time. The other 1% of the time (when access control lists are in use) you need getfacl filename. – Marius Gedminas Jul 30 '10 at 11:21
1  
Marius: And for the 0.01% of the time (when SELinux security contexts are in use) you need to use -Z flag for various commands, such as ls, to see the SELinux flags. – Janne Pikkarainen Jul 30 '10 at 11:24
file doesn't show anything about permissions. Perhaps you meant stat. Also, some people find symbolic permissions to be more intuitive: chmod u+x,g=rx,o-w abc or chmod ugo=r abc – Dennis Williamson Jul 30 '10 at 14:20
feedback

Your Answer

 
or
required, but never shown

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