Quick Overview of File/Folder Permission Attributes and chown, chgrp, chmod Commands - Example w/Samba

Mindwatering Incorporated

Author: Tripp W Black

Created: 04/12/2004 at 05:10 AM

 

Category:
Linux
Other

Description of Decimal Permission Attributes and chown, chgrp, and chmod Commands

Decimal code: ex: 0774

0 padding (windows - you may also see this as 777)
7 - owner
7 - group
4 - others

Permission . . . . Binary . . . . . Decimal
----------------- . . . . . . ---------- . . . . ----------------
Full Access . . . . . . . . 111 . . . . . . . . . . .7
Read/Write . . . . . . . . 110 . . . . . . . . . . 6
Read/Execute . . . . . .101 . . . . . . . . . . 5
Read Only . . . . . . . . . 100 . . . . . . . . . .4

In linux there are 9 leading "bits" for permissions.
1. 1st three for owner
2. 2nd three for group
3. 3rd three for others

Each three (e.g. rwx) correspond to the binary code for that triplet.


Full Decimal List:
0 - None
1 - Only Execute, no read or write to
2 - Write-only, cannot read or execute
3 - Write-able and executable
4 - Read-only, cannot write to or execute
5 - Read-only executable, cannot write to
6 - Readable Writeable file, but not executable
7 - Readable Writeable Executable file


To change an owner/group of a file:
chown -R <owner> <file>
chgrp -R <groupname> <file_or_directory>

ex. chgrp -R mygrp /local/myuser
Changes all files/folders in the /local/myuser folder owner to mygrp


To change/fix permissions:
(Note: For Ubuntu: write is w not W, ex: chmod -R mygroup g+rwx /local)
ex. chmod -R u+rWx /path/
This example recursively (down directories) adds read/write/execute access for users

ex. chmod -R g+rWx /path/ or chmod -R g+rwx /path/
This example recursively (down directories) adds read/write/execute access for groups

ex. chmod -R o-rWx /path/
This example recursively (down directories) removes read/write/execute access for others than owner and group to read/access docs/folders.

Tip: Use ls -l (lowercase L) to list in wide format including rights.

Sample samba / smb share for all users of group "users" to have read/write/delete access to share:
[test]
path = /tmp/testshare
valid users = @users
public = no
writable = yes
printable = no
force create mode = 0770
force directory mode = 0770
force group = users



previous page

×