Linux File & Folder permissions. File Permissions. In Ubuntu, files and folders can be set up so that only specific users can view , modify, or run them. For instance, you might wish to share an important file with other users, but do not want those users to be able to edit the file .
[email protected] me$ls -l /bin/bash
-rwxr-xr-x 1 root root 316848 Feb 27 2000 /bin/bash
rwxrwxrwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000
[email protected] me$chmod 600 some_file
r- Allows the contents of the directory to be listed if the x attribute is also set.
w - Allows files within the directory to be created, deleted, or renamed if the x attribute is also set.
x - Allows a directory to be entered (i.e. cd dir).
Anytime a user creates a new file or directory, his or her user account is assigned as that file or directory’s “owner.” For example, suppose the ken user logs in to her Linux system and creates a file named linux_introduction.odt using OpenOffice.org in home directory. Because she created this file, ken is automatically assigned ownership of linux_introduction.odt.
[email protected] me$ su
[email protected] me# chown you some_file
[email protected] me# exit
Syntaxchownuser.group file or directory.
Example: If I wanted to change the file’s owner to theken1user, I would enter
Notice that I used a period (.) before the group name to tell chown that the entity specified is a group, not a user account.
Note: You can use the –R option with chown to change ownership on many files at once recursively.