CHMOD Unix Command - Unix Commands

This is a discussion on CHMOD Unix Command - Unix Commands ; CHMOD command in Unix and Linux environments helps users or administrators change file and directory permissions and modes. CHMOD is an abbreviation for CHange MODe. Mode specifies the permissions, File specifies the objects to act upon and options help with ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: CHMOD Unix Command

  1. Post CHMOD Unix Command

    CHMOD command in Unix and Linux environments helps users or administrators change file and directory permissions and modes. CHMOD is an abbreviation for CHange MODe. Mode specifies the permissions, File specifies the objects to act upon and options help with special cases including recursion.

    CHMOD Usage
    $ chmod [options] mode[,mode] file1 [[file2 ...]]

    Mode indicates the permission that is to be granted or taken away from the specified files or directories. File indicates the file to be acted upon and options specify some special cases of recursion and other behaviour that CHMOD uses while executing the change.

    CHMOD Options

    CHMOD command line options drive the behaviour of the chmod command. Using these options the user can specify if the command needs to be executed on multiple files, directories or in a verbose mode etc. Some of the options and its explanation is listed below.
    • Recursive Option : -R, –recursive : Recursive option specifies the command should act recursively on the directories and files specified in the command
    • Verbose Option : -v, –verbose : Verbose option lists diagnostics of all files impact during the command processing
    • Silent Option : -f, –silent, –quiet : Silent option supresses most error messaages that the command operation may return
    • Change Option : -c, –changes : Change option is similar to verbose mode but the output is reported for files or directories impacted by the command
    • Help Option : –help : Displays help and exits from the command
    • Version Option : –version : Outpus version information and exits from teh command
    CHMOD Modes

    CHMOD modes are a representation of the permissions and special flags that need to be applied to the file or directory being operated upon. Mode can be specified in a symbolic form or in an Octal form

    Octal Mode represents the permission of a file upto four octal digits as DDDD. Octal value for each digit is calculated by adding up the values of permissions required for each set of users and is passed to the command as needed. Typically the first D is not used by many and CHMOD assumes a 0 as a prefix when ever a value less than 4 digits is specified.
    • First digit represents the value for set userid, set groupid and save text image value.
    • Second digit represents the permission for the owner of the file and is represented by a value of Read(4), Write(2), Execute(1)
    • Third digit represents the permission for the group that the file belongs to and is represented by a value of Read(4), Write(2), Execute(1)
    • Fourth digit represents the permission for other users / everyone else that has access to the file by a value of Read(4), Write(2), Execute(1)
    Octal Mode Examples
    • Read by Owner = 0400 ( 4 Represents Read )
    • Read & Write by Owner = 0600 ( 6 Represents the sum of the values 4 [ Read ] and 2 [ Write ] )
    • Read, Write & Execute by Owner = 0700 ( 7 Represents the sum of values 4 [ Read ] , 2 [ Write ] and 1 [ Execute ] )
    • CHMOD 777 a.txt ( Read, Write, Execute permissions on a.txt for the owner, group and everyone )
    • CHMOD 660 a.txt ( Read and Write permission on a.txt for owner and group ]
    • CHMOD 755 a.txt ( Default permission for most files where Owner has full access and other have read and execute access for the file )
    Symbolic Mode represents the permissions as a string of text. A Symbolic mode is comprised of 3 components reference, operator and mode that form the end mode to be applied to the file. Reference distinguishes the user or user group to which the permission applies. Operator specifies the value to which the permissions should be adjusted. Mode specifies the actual permission value as specified in the table below.


    References :
    • u represents user and specifies the owner of the file or directory
    • g represents group and specifies the group of the file or directory
    • o represents others and specifies users other than owner and group the file belongs to
    • a represents all three of the above [ also referred to as ugo ]
    Operator :
    • + operator adds the mode
    • - operator removes the mode
    • = operator equates the permissions to exactly whats specified and eliminates all old permissions
    Mode :
    • •r : read permission
    • •w : write permission
    • •x : execute permission
    • •X : Special execute mode which is useful in a recursive operation
    • •s : setuid/gid is a special mode.
    • •t : sticky bit is a special mode
    Symbolic Mode Examples :
    • chmod a+r filename : Allows read permission on the file to everyone
    • chmod go+rw filename : Makes the file readable and writeable by group and others
    • chmod rws,g+s filename : Turns on set group-id and also allows everyone to read, write and execute the file specified.

  2. Re: CHMOD Unix Command

    Hello..
    I am just new for Unix and I am learning it. I think this will be very helpful for me as well as everybody who are new for Unix just like me. Thank you very much for this CHMOD Unix Command. You have done a great job for everybody and keep doing good work. I appreciate your good work.
    "Mind games"

+ Reply to Thread