chmod changes the access permissions or modes of the specified files or directories. Modes determine who can read, change or execute a file.
does not issue error messages concerning file access permissions, even if chmod encounters such errors.
changes the access permissions of all files and subdirectories under a directory if one is specified as a path name on the command line.
You can specify the mode value on the command line in either symbolic form or as an octal value.
A symbolic mode has the form
[who] op permission [op permission ...]
The who value is any combination of the following:
sets user (individual) permissions.g sets group permissions. o sets other permissions. a sets all permissions; this is the default.
On Windows file systems, there are no group or other permissions. Therefore, they always match the individual permissions.
The op part of a symbolic mode is an operator that tells chmod to turn the permissions on or off. The possible values are:
turns on a permission.- turns off a permission. = turns on the specified permissions and turns off all others.
The permission part of a symbolic mode is any combination of the following:
read permission. If this is off, you cannot read the file. The extended FAT and NTFS file systems ignore this permission since all files are always readable.
Execute permission. If this is off, you cannot execute the file. The extended FAT and NTFS file systems ignore this permission since they consider all files executable.
Execute/search permission for a directory; or execute permission for a file only when the current mode has at least one of the execute bits set. The extended FAT and NTFS file systems ignore this permission since they consider all files executable and all directories searchable.
Write permission. If this is off, you cannot write to the file.
Hidden attribute. Only the extended FAT and NTFS file systems recognize this attribute.
Archive bit. Only the extended FAT and NTFS file systems recognize this attribute.
On POSIX-compliant and UNIX systems, this stands for setuid on execution or setgid on execution permission. On Windows systems, this stands for a system file.
On NTFS 5.0 (and up) file systems (available only on Vista/7/2008/8/2012/10 system), this is the sparse file bit. Due to limitations in the file system, once you have set this attribute, you cannot turn it off without recreating the file.
On UNIX systems, this stands for the sticky bit. On Vista/7/2008/8/2012/10, it refers to the temporary file bit.
Compressed file attribute.
You can specify multiple symbolic modes if you separate them with commas.
Absolute modes are octal numbers specifying the complete list of attributes for the files; you specify attributes by OR'ing together these bits.
01000000 temporary file 02000000 compressed file 04000000 sparse file 4000 Hidden file (setuid bit) 2000 System file (setgid bit) 1000 Archive bit (sticky bit) 0400 Individual read 0200 Individual write 0100 Individual execute (or list directory) 0040 Group read 0020 Group write 0010 Group execute 0004 Other read 0002 Other write 0001 Other execute
This list shows the first three bits with their meanings on Windows systems and with their meanings on UNIX and POSIX-compliant systems in parentheses. The MKS version of chmod tries to handle options in a way that parallels the POSIX approach. In the following list, each line shows a group of calls that are equivalent.
chmod 0000 chmod o=s chmod 2000 chmod g=s chmod =s chmod 4000 chmod u=s chmod =h chmod 6000 chmod a=s chmod ug=s chmod =hs
=s is equivalent to 2000 on Windows systems; on UNIX and POSIX-compliant systems, =s is equivalent to 6000. MKS intends these equivalences to support commands ported to Windows from UNIX or POSIX-compliant systems. Such ported commands do not do the same thing that they do on UNIX or POSIX-compliant systems, (since Windows systems do not have the same file attributes as UNIX and POSIX), but the commands work in a consistent manner.
To get a read-only file on Windows systems, you must turn off all three write permission bits; if any of the three is on, Windows considers the file to be writable.
On Windows systems, the lc and ls commands both indicate the mode settings of files. The Windows dir command does not show these attributes, and the attrib command may only work with the read-only attribute, depending on the version of your operating system.
chmod -w nowrite
makes file nowrite read-only.
chmod +hrs sysfile
sets the hidden, read-only, and system attributes for sysfile.
chmod a=rwx file
turns on read, write, and execute permissions, and turns off the hidden, archive, and system attributes. This is equivalent to
chmod 0777 file
On Vista/7/2008/8/2012/10, the command
chmod -R +c d:/
compresses the D: drive.
Possible exit status values are:
Failure due to any of the following:
Failure due to any of the following:
- fatal error during "-R" option
You specified the
-Roption but some file or directory in the directory structure was inaccessible. This may happen because of permissions or because you have removed a removable disk unit.
- read directory "name"
You do not have read permissions on the specified directory.
chmod is provided as both an external utility and a built-in MKS KornShell utility.
POSIX.2. x/OPEN Portability Guide 4.0. Windows Vista. Windows 7. Windows Server 2008. Windows 8. Windows Server 2012. Windows 10.
Different systems interpret some mode bits in different ways.
PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC MKS Toolkit 10.0 Documentation Build 6.