Knowledge about linux permissions and ntfs file system Permissions

Source: Internet
Author: User
Tags ntfs permissions

About ntfs permissions
File permissions:

[-dcbps][u:rwx][g:rwx][a:rwx] 
Where: r = 4, w = 2, x = 1, u = owner, g = group, a = all user
D = dir,-= file, l = symbolic link, p = pipe,

C = character device, B = block device, d = door, s = socket

In linux, the r directory of the directory can be a column directory, w directory can be written, deleted, or renamed, and x directory can be accessed;

File r -- readable, w -- writeable/deleted/renamed, x -- executed

A combination of permissions can be combined into a number: rwx = 4 + 2 + 1 = 7

Therefore:-rwxrwxrwx = 777,-rw = 666,-rwx-r-x = 755

Generally, you can set the chmod parameters:

Chmod 777/dir/file: Set the file to read/write. Run chmod-x/dir/file to delete the file. Run chmod ga-w/dir/file to delete the writeable permission of the file ga. chmod u = rx/dir/file reset file u to read and execute chmod + x/dir/file add file uga to be executable


Umask & fmask & dmask usage umask -- sets permission Filtering for directories and files
Fmask -- set File Permission Filtering
Dmask -- set permission Filtering for directories
Dmask and fmask are the mount options. For the fat/ntfs file system, they are suitable for fstab configuration.
Unlike the chmod/chown permission values, the three of them mean mask-filtering. The following are their read and write permissions on files:
    0   1   2   3   4   5   6   7r   +   +   +   +   -   -   -   -w   +   +   -   -   +   +   -   -x   +   -   +   -   +   -   +   -

In fact, this result uses the mask = rwx-File Permission

If the file is set to 0755, the mask value must be 0022, that is, 0755 = 0777-0022.

Fstab instance:

<file system> <mount point> <type>         <options>       <dump> <pass>/dev/hda1      /media/win    ntfs  defaults,utf8,umask=111   0      0

Where: umask = 111 ==> (777-111) = 666 = rw-rw, that is, the file has read and write permissions.

You can redesign more strict permission relationships:

Dmask = 022, fmask = 133 that is: f = 755 = rwxr-xr-x, d = 644 = rw-r --

Note: umask can be understood as disabling some permissions. You can use the umask command to change the permissions of a file:
Umask: view the permissions of the current directory. maskumask <mask> sets the current


Advanced file permissions-suid and sgid of the file group and user inheritance relationship when suid is set for the file, the file is run as the owner
Chmod 755 file (owner) chmod u + s file ==>-rwsr-xr-x (user) (that is, when the user is executed, it is executed as the owner) (suid is often used on files, and the Directory generally has no execution permission)

When the sgid is set for the directory, if another user has the r/x/w permission, the subdirectory group created by another user is the current group.

Chmod 757 dir (owner) chmod g + s dir => drwxr-srwx (ower) mkdir dir/newidr (user) (that is, when the user creates a subdirectory, its group is the owner, and its owner is the user) (sgid is often used in directories)

When sticky is set in the directory, prevent others from deleting the directory data.

Chmod 757 dir (owner group) chmod o + t dir => drwxr-srwt (owner) rm-r dir (user) => error (the user cannot be deleted, although the delete permission is enabled, only the owner can delete the permission)

Example:

chmod  u=rwxs,o=rx   filechmod  g+s,o=wrx    test/chmod  o=rwxt   test/ chmod 1775 test/

0755 is 755, and 1 in front of 1755 is related to suid/sgid/sticky. See the following table:

(Suid = 4, sgid = 2, sticky = 1)
Suidsgidsticky mode numeric onononon7onoff6onoffon5onoff4offonon3offonoff2offoffon1offoff0


The object owner is generally set through chown.
View Current logon w or who view current user name whoami view current user group id <u> or finger <u> view User Logon record lastlastb view all user cut-d: -f 1/etc/passwdcat/etc/passwd | awk-F \: '{print $1}' view current group groups view specified group groups change owner chown/dir/file Change Group chgrp/dir/file Change Group and owner chown: /dir/file other groupadd/groupmod/groupdeluseradd/usermod/userdel


Final, advanced understanding of fstab Configuration
<file system> <mount point> <type>                    <options>               <dump> <pass>/dev/hda1 /media/win ntfs defaults,utf8,uid=1000,gid=1000,fmask=133,dmask=022 0 0

References

Http://www.itlearner.com/article/4594

Http://askubuntu.com/questions/429848/dmask-and-fmask-mount-options

Http://blog.sina.com.cn/s/blog_70545bad0100xdnp.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.