HomeManualTopicsTypesSymbols

std::chmod

changes the mode of the specified file

Parameters

filename
the name of the file for which the mode is to be changed
mode
the new mode

Results

None

Description

This function needs I/O-access rights.

The mode is written as an ASCII-string like it is displayed by the ls command.

The first three letters specify the permissions for the owner of the file, the next three letters specify the permissions for the group of the file, and the last three letters specify the permissions for all other users.

Each letter group is interpreted as follows:

The first letter specifies the read permission. It can be one of the following characters:

r: read permission is granted -: read permission is not granted

The second letter specifies the write permission. It can be one of the following characters:

w: write permission is granted -: write permission is not granted

The third letter specifies the execute permission. It can be one of the following characters:

x: execute permission is granted -: execute permission is not granted

Instead of 'x' the following letters can be used:

s (owner and group): additionally sets the SUID respektively SGID bit S (owner and group): only sets the SUID respektively SGID bit t (other): additionally sets the sticky bit T (other): only sets the sticky bit

Example

# make a file readable and executable for everyone chmod! "myfile.txt" "r-xr-xr-x"

Topic

POSIX

See also

std::chown changes the owner and group of the specified file