ADVERTISEMENT

Linux Commands ❯ chmod

chmod

Change file mode bits
syntax:

chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...

In simplified term

chmod [OPTION] [PERMISSIONS] filename
  • chmod o=r my_file1
    set the permission to access the file my_file1 to read-only for other users. Permission for owner and groups will be unchanged.
  • chmod 764 my_file1
    Set the permission to my_file1 as below.

    -the user can read, write, and execute it.
    -members of the user group can read and execute it.
    -others may only read it.
  • chmod u=rwx,g=rx,o=r my_file1
    Set the permission to my_file1 as below.

    -the user can read, write, and execute it.
    -members of the user group can read and execute it.
    -others may only read it.
  • chmod -f 764 my_file1
    Set the permission to my_file1 as below and suppress any error message(Quiet Mode )

    -the user can read, write, and execute it.
    -members of the user group can read and execute it.
    -others may only read it.
  • chmod -R 764 my_dir1
    Set the below permission to my_dir1 and all the files and directories under it recursively.

    -the user can read, write, and execute it.
    -members of the user group can read and execute it.
    -others may only read it.
  • chmod -v 764 my_file1
    Set the permission to my_file1 as below and shows a diagnostic message( Verbose Mode)

    -the user can read, write, and execute it.
    -members of the user group can read and execute it.
    -others may only read it.