How to Change Permission of File And Directory
The command used to change permissions from the command line is chmod, short for “change mode” (permissions are also called the mode of a file). The chmod command takes a permission instruction followed by a list of files or directories to change. The permission instruction can be issued either symbolically (the symbolic method) or numerically (the numeric method).
How to Change Permission Using Symbolic Method
chmod WhoWhatWhich file|directory
Who is u, g, o a (for user, group, other all)
What is +, -, = (for add, remove, set exactly)
Which is r, w, x (for read, write, execute)
Ex. 1. Add read and write permission for group and other on FILE1
chmod go+rw FILE1
What is +, -, = (for add, remove, set exactly)
Which is r, w, x (for read, write, execute)
Ex. 1. Add read and write permission for group and other on FILE1
chmod go+rw FILE1
Ex. 2. Add execute permission for everyone on file2
chmod a+x file2
Ex. 3. Remove read permission for user on file3
chmod r-u file3
chmod a+x file2
Ex. 3. Remove read permission for user on file3
chmod r-u file3
How to Change Permission of File and Directory using Numeric Method
Each digit represents an access level: user, group, other.
Syntax: chmod ### file|directory
# is sum of r=4, w=2 and x=1
Ex. chmod 750 filename
Syntax: chmod ### file|directory
# is sum of r=4, w=2 and x=1
Ex. chmod 750 filename
In above example, set read, write and execute permission for user, read and execute permission for group and no permission for other on file.