Change file/files permissions (LINUX)

Change the permissions of one or more files. Only the owner of a file or a privileged user may change the mode.

chmod [options] mode files chmod [options] --reference=filename files

Options

-c, --changes Print information about files that are changed.
-f, --silent, --quiet Do not notify user of files that chmod cannot change.
--help Print help message and then exit.
-R, --recursive Traverse subdirectories recursively, applying changes.
--reference=filename Change permissions to match those associated with filename.
-v, --verbose Print information about each file, whether changed or not.
--version Print version information and then exit.

Who
u User.
g Group.
o Other.
a All (default).

Opcode
+ Add permission.
- Remove permission.
= Assign permission (and remove permission of the unspecified fields).

Permissions
--- No Permissions(0)
r-- Read only.(4)
rw-Read and Write.(6)
rwx - Read, Write, and Execute.(7)
r-x Read and Execute.(5)
--x Execute Only.

s Set user (or group) ID.
t used on directories to prevent removal of files by non-owners.
u User's present permission.
g Group's present permission.
o Other's present permission.

-rw------- 600 Owner has read and write permissions.
-rw-r--r-- 644 Owner has read and write permissions; group and world have read-only permission.
-rw-rw-rw- 666 Everyone has read and write permissions.
-rwx------- 700 Owner has read, write, and execute permissions.
-rwxr-xr-x 755 Owner has read, write and execute permissions. Everyone else has read and execute permissions.
-rwxrwxrwx 777 Everyone has read, write, and execute privileges.
-rwx--x--x 711 Everyone has read, write, and execute permissoins; everyone else has execute-only permissions.
drwx------ 700 Only the owner can read and write into this directory.
drwxr-xr-x 755 The directory can be changed only by the owner, but everyone can view the contents.
drwx--x--x 711 Restricted access by the ls command. A file can be read only by someone who knows the filename.

Example:

chmod u+x file.tx
Make file file.tx executable for the owner.

No comments:

Recent Posts