The chmod command is used to change the file permissions in a Unix-like operating system. It allows you to specify who can read, write, or execute a file. The permissions can be set for three categories of users:
- User (u): The owner of the file.
- Group (g): Users who are part of the file's group.
- Others (o): All other users.
You can use symbolic or numeric modes to set permissions. For example:
-
To add execute permission for the user:
chmod u+x filename -
To remove write permission for others:
chmod o-w filename -
To set permissions using numeric mode (e.g., 755):
chmod 755 filename
In this case, 7 gives read, write, and execute permissions to the user, 5 gives read and execute permissions to the group, and 5 gives read and execute permissions to others.
