Linux Permission Denied: 3 Simple Fixes

Reading time icon 2 min. read


Readers help support MSpoweruser. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help MSPoweruser sustain the editorial team Read more

linux permission denied

Have you encountered Linux Permission denied error while installing a package? In this guide, I’ll discuss the solutions and reasons why this error occurs. Let’s go!

Permission Denied on Linux – How To Solve It?

Solution 01: Add “sudo” Privileges

sudo command enables you to execute programs with the security privileges of another user. It asks you to enter your system password and confirms your request by verifying your username entry in the “sudoers” file. 

First, I’ll try to install a package with a simple apt-get command, which will display the Permission denied error.

linux permission denied when executing a command

To resolve this error, I’ll simply add “sudo” at the start of the same command.

adding sudo in command to resolve linux permission denied error

Solution 02: Change File Permissions

There are three types of file permissions on Linux: read “r“, write “w“, and execute “x“. If you don’t have the required permission, you’ll encounter a Permission denied error in Linux.

To resolve it, I’ll type the “chmod +rwx filename” command and hit Enter. In this case, the name of the file is “article.txt”.

changing file permissions to resolve permission denied on linux

This command grants read, write, and execute permissions for the specified file. However, you can also specify any single permission option.

Solution 03: Change File Ownership

In Linux-based OS, if you aren’t the file owner or don’t have the required permission, you can’t perform any file-related operation on it. Additionally, if you try to access it, your terminal will display a Permission denied error.

 

To resolve it:

1. First, type “sudo chown username:groupname filename” to change file ownership.

2. Execute the “ls -l” command for verification.

3. Run “chmod +rwx filename” to grant read, write, and execute permissions.

4. For testing, access the file content with cat.

changing file ownership and permissions to resolve permission denied linux error

When Does the Permission Denied Error Occur?

  • Missing sudo Privileges: Executing a command without “sudo” to perform operations only accessible to a root user.
  • Insufficient File Permissions: Attempting to access a file without having the required permissions, such as read, write, or execute.
  • Incorrect Ownership Issues: Not having proper ownership of a file can also raise the Permission denied error.

You may also be interested in:

That’s all about fixing the Linux Permission denied error. Let me know which of the discussed solutions worked for you.

User forum

0 messages