domingo, 24 de junio de 2012

chmod - change file mode bits

If we do ls on a GNU/linux box we will obtain permission on files. 



u+g+o u = user g = group  o = others


The octal method for setting the permissions makes use of the octal value for each permission:

    r = 4 or 0
    w = 2 or 0
    x = 1 or 0
    s = 4 (for user) or 0 (or unspecified)
    s = 2 (for group) or 0 (or unspecified)
    t = 1 or 0 (or unspecified)

The summation of each permission, values 0-7, represent the permission for each of the “ugo.” The following examples show how to represent the permission values in octal format:

    rwx = 7 (r+w+x = 4+2+1)
    r-x = 5 (r+0+x = 4+0+1)
    rw- = 6 (r+w+0 = 4+2+)
    r– =  4 (r+0+0 = 4+0+0)

When specifying in octal you must explicitly set the values for all three otherwise you results apply to the right most group and work towards the left:

    chmod 7 file = ——rwx on file
    chmod 27 file = —-w-rwx on file


No hay comentarios:

Publicar un comentario