Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to resolve the "Permission Denied" error in Linux

Educative Answers Team

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

  • flags are the additional options users can set.
  • permissions define if the user can read, write, or execute the file. They can be represented using symbolic or octal numbers.
  • filename is 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:

Flag--help--version-R, --recursive--reference=file--preserve-root--no-preserve-root-v, --verbose-f, --silent, --quiet-c, --changesDescriptionopen the help menuoutput the version numberchange permisssions recursivelyset permissions similar to filedo not open recursively on '/'open recursively on '/', defaultoutput a message for every filedo not output error messagesgives verbose output when a change is made


Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring