O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

chmod — stdin  stdout  - file  -- opt  --help  --version

Synopsis

chmod [options] permissions files

The chmod (change mode) command protects files and directories from unauthorized users on the same system, by setting access permissions. Typical permissions are read, write, and execute, and they may be limited to the file owner, the file’s group owner, and/or other users. The permissions argument can take three different forms:

  • --reference= file, to set the same permissions as another given file.

  • An octal number, up to four digits long, that specifies the file’s absolute permissions in bits, as in Figure 1-6. The leftmost digit is special (described later) and the second, third, and fourth represent the file’s owner, the file’s group, and all users.

  • One or more strings specifying absolute or relative permissions (i.e., relative to the file’s existing permissions). For example, a+r makes a file readable by all users.

File permission bits explained

Figure 1-6. File permission bits explained

In the third form, each string consists of three parts: an optional scope, a command, and permissions.

Scope (optional)

u for user, g for group, o for other users not in the group, a for all users. The default is a.

Command

+ to add permissions; to remove permissions; or = to set absolute permissions, ignoring existing ones.

Permissions

r for read, w for write/modify, x for execute (for directories, this is permission to cd into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required