chmod <octal-mode> files... chmod octal-mode files...
chmod <references><operator><modes> files.. chmod [references][[operator][modes]] files...
referencesreferences is a combination of the letters ugoa, which which specify which user's access to the filesfiles will be modified:
uthe user who owns itgother users in thefile'sfile's groupoother users not in the file's groupaall users
If the omitted, it defaults to all users, but but only permissions allowed by the umask are modified.
operatoroperator is one of the characters +-=:
+add the specified file mode bits to to the existing file mode bits of eachfilefile-removes the specified file mode bits to from the existing file mode bits of eachfilefile=adds the specified bits and removes unspecified bits, except thesetuidandsetgidbits set for directories, unless explicitly specified.
modemode consists of a combination of the letters rwxXst, which specify which permission bit isbits are to be modified:
rreadwwritex(lower caseX) execute (or search for directories)X(capital) execute/searchtraverse only if the file is a directory or or already has an execute bit set for some user categoryssetuid or setgid (depending on the specifiedreferencesreferences)trestricted deletion flag or sticky bit
Alternatively, the modemode can consist of one of the letters ugo, in in which case case the mode corresponds to the permissions currently currently granted to the owner (u), member'smembers of the file'sfile's group (g) or permissions of users or users in neither of the preceding categories (o).
- Access control (see also
setfacl)rwx— read (rr), write (ww), and execute/crosstraverse (xx) permissions.- Read (r) affects if a file can be read, or if a directory can be listed.
- Write (w) affects if a file can be written to, or if or if a directory directory can be editedmodified (files added, deleted, renamed).
- Execute (x) affects if a file can be run, use use for scripts (see
#!), and other executable files. - CrossTraverse (x) affects if, also known as "search", affects whether a directory can be traversedtraversed; i.e., whether a process can access (or try to access) file system objects through entries in this directory.
sandt— sticky bit (tt), and setgid (ss) on directories- The sticky bit only affects directories. Will prevent any oneanyone except file owner, and root, from deleting files in the directory.
- theThe setgid bit on directories, will cause new files and directories to to have the group set to the same group, and and new directories to have theretheir setgid bit set (see also defaults in setfacl
setfacl).
s— setuid, setgid, on executable files.- This can affect security in a bad way, if you don't know what you are doing.
- When an executable is run, if one of these bits is set, then then the effective user/group of the executable will will become thatthe effective user/group of the fileprocess. Thus Thus the program runs asas that user. see See
setcapfor a more modern way to do this.
chattr <operator><attribute> files... chattr operator[attribute] files...
operatoroperator is one of the characters +-=:
+adds the selected attributes to be to the existingattributesattributesof thefilesfiles-removes the selectedattributesattributes=overwrites the current set of attributes the files have with the specifiedattributesattributes.
attributeattribute is a combination of the letters acdeijstuADSTacdeijmstuxACDFPST, which which correspond to the attributes:
aappend onlyccompresseddno dumpeextent formatiimmutablejdata journallingjournalingmdon't compressssecure deletiontno tail-merginguundeletablexdirect access for filesAnoatimeupdatesCno copy on writeDsynchronous directory updatesFcase-insensitive directory lookupsPproject hierarchySsynchronous updatesTtop of directory hierarchy
There are restrictions on the use of many of these attributes. For example, many of them can be set or cleared only by the superuser (i.e., root) or an otherwise privileged process.
setfattr -n <name> -v <value> files... setfattr -n name -v value files...
setfattr -x <name> files... setfattr -x name files...
namename is the name of the extended attribute to set or remove
valuevalue is the new value of the extended attribute
setfacl <option> [default:][<target>:][<param>][:<perms>] files... setfacl option [default:][target:][param][:perms] files...
optionoption must include one of the following:
targettarget is one of the letters ugmo (or the longer formforms shown below):
u,userspermission of a named user identified byparam, defaultsparam, defaults to file owneruidUID if omittedg,grouppermission of a named group identified byparam, defaultparam, default to owning groupuidGID if omitted omittedm,maskeffective rights masko,otherpermissions of others
permsperms is a combination of the letters rwxX, which correspond to the permissions:
Alternatively, permsperms may be an octal digit (0-7) indicating the set of permissions.
setcap <capability-clause> file setcap capability-clause file
A capability-clausecapability-clause consists of a comma-separated list of capability names followed by a list of operator-flag pairs.
chcon [-u <user>] [-r <role>] [-t <type>] files... chcon [-u user] [-r role] [-t type] files...
useruser is the SELinux user, such as user_u, system_u or root.
rolerole is the SELinux role (always object_r for files)
typetype is the SELinux subject type
SMACK is Simplified Mandatory Access Control Kernel.
chsmack -a <value> file chsmack -a value file
valuevalue is the SMACK label to be set for the SMACK64 extended file attribute