While using Linux, you may encounter the error, “permission denied”. This error occurs when the user does not have the privileges to make edits to a file. Root has access to all files and folders and can make any edits. Other users, however, may not be allowed to make such edits.
Remember that only root or users with Sudo privileges can change permissions for files and folders.
The permissions can be changed using the
chmod keyword. The syntax for the command is:
chmod flags permissions filename
flagsare the additional options users can set.
permissionsdefine if the user can read, write, or execute the file. They can be represented using symbolic or octal numbers.
filenameis the name of the file whose permissions are changed.
Here is an example where users can read, write, and execute a file; whereas, group and others can only read it.
chmod u=rwx,g=r,o=r file
Here, each letter has a meaning:
r gives read permissions
w gives write permissions
x gives execute permissions
The same command can be run using octal notation:
chmod 744 file
Here, each digit represents the sum of the permissions allowed:
4 gives read permissions
2 gives write permissions
1 gives execute permissions
0 gives no permissions
The sum of these permissions is used to represent each type of author.
The following flags can be set:
View all Courses