Skip to content

Chmod

linux commands


chmod

Changes permissions for a file.

There are three types of users in linux: - current user - current users group - all other users

The ll command (or ls -a) gives 10 chars, some examples: - -rwxr-xr-x - drwxr--r--

First char: - - means file - d meant directory

The next nine are in groups of three: - r means read access - w means write access - x means execute access - - means it is switch off

The nine are bundled in the following order: - user (u) - group (g) - others (o)

You can do one of the following commands: - + add permissions - - remove permissions - = set permissions

Example 1 - set current user to have read, write and execute rights, group users to be able to read and other to have no access.

chmod u=rwx,g=r,o= filename

Example 2 - remove read, write and execution writes for the group users and other users.

chmod og-rwx filename

Example 3 - change folder and subfolders

chmod -R 755 folder_name

See also