To change user permissions in Linux, you can use the chmod command. This command allows you to modify the read, write, and execute permissions for the owner, group, and others. Here's how to use it:
Syntax
chmod [options] mode file
Modes
You can specify permissions using either symbolic notation or numeric (octal) notation.
Symbolic Notation
u: user (owner)g: groupo: othersa: all (user, group, and others)+: adds a permission-: removes a permission=: sets the permission exactly
Example:
To add execute permission for the owner:
chmod u+x filename
To remove write permission for the group:
chmod g-w filename
Numeric Notation
Permissions are represented by numbers:
4: read (r)2: write (w)1: execute (x)
You can combine these numbers to set permissions.
Example:
To set read, write, and execute permissions for the owner, and read and execute for the group and others:
chmod 755 filename
Changing Permissions Recursively
To change permissions for a directory and all its contents, use the -R option:
chmod -R 755 directoryname
Verify Changes
You can verify the changes using:
ls -l filename
This will display the updated permissions. If you have further questions or need examples, feel free to ask!
