Knowledge about linux permissions and ntfs file system permissions

Source: Internet
Author: User
Tags ntfs permissions
About ntfs permission problems file permissions: [-dcbps] [u: rwx] [g: rwx] [a: rwx] Where: r = 4, w = 2, file permissions for ntfs 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:

  
   
            
           
      
      
       /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: permission to view the current directory maskumask
 
  
Set 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 idOr fingerView 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
    
     
                         
                     
        
        
         /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

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.