https://linuxroutes.com/avoid-permission-denied-linux-error
This article will teach you quickly what is permission denied Linux error. And also what ways you can avoid permission denied error in Linux.
One
way to avoid such error is to switch to root user using su – command.
However this solution is not recommended since it will gain unnecessary
access to all the root file system.
Now to avoid such case you need to add execute permission “x” to the file myshell.sh using chmod command as below:
In
the last output you can see that there is “x” (execution) permission
added after chmod command. So next time when you try to execute the
shell script , it will execute without any error.
If you look at the permissions of the “myfolder” directory using ls -l command you will come to know about the permissions.
As
per the permission given in above output only owner of the directory
who is root can have all permission that is read, write and execute. So
in such case you need to change the permission of the directory to read
using below chmod command:
Now this time when normal user manmohan try to list directory he will not get the permission denied error.
In case you want to have write permission on this directory you need to specify w flag as well in chmod command as below:
Same is applicable to file level permission as well.
One more way is to changing the ownership of the directory using chown command. Since in our example we are getting error for user manmohan we will change ownership of the directory “myfolder” using below command.
Since
manmohan user is now the owner of the directory he can able to do any
operation on the directory. In case you want to recursive permission do
not forget to add -r while chown command as below:
This article will teach you quickly what is permission denied Linux error. And also what ways you can avoid permission denied error in Linux.
What is permission denied Linux error?
This error comes when you try to list files or try execute the file inside the directory where you don’t have sufficient permission. Since Linux operating system is very particular about its security aspect.Example of Permission denied Linux error
Let’s say you are a normal user who is trying to list or trying change the directory inside the /root file-system. Since you do not have sufficient permissions system will respond with permission denied error message as below:How to resolve Permission denied Error
Resolving Permission denied error related to script execution:
Resolving permission denied Linux error while listing or writing to a file
In this type of permission denied error you try to list or write the file in which you do not have sufficient permission to do so as below:One more way is to changing the ownership of the directory using chown command. Since in our example we are getting error for user manmohan we will change ownership of the directory “myfolder” using below command.
Resolving permission denied Linux error for specific user
No comments:
Post a Comment