How to fix shell script permission denied error in Linux

When attempting to run applications in Linux, one of the most typical issues that arise is the “bash:./program name: permission denied error.” This issue happens most frequently when the script you are attempting to run does not have the appropriate execute permissions. This problem may be fixed by either modifying the permissions assigned to the script or assigning the necessary permissions.

Let’s look at the specifics of the error, as well as the possible solutions to it.

If the directory in which you are working does not have the appropriate rights, you may get an error in Linux that says “permission denied” when you try to list the files in the directory or run a shell script inside the directory. Because the Linux operating system prioritizes its users’ safety, the “root” user has unrestricted access to all folders and files, allowing them to make any desired modifications. As a result, it’s possible that other users won’t be able to make those kinds of adjustments.

Fixing the shell script permission denied error in Linux

For illustration purposes, I have a shell script on my system named “” Now, assuming the role of a regular user, we will attempt to run that infernal script by executing the following line of code:

permission denied error
permission denied error

Note: if you don’t have the file and would like to create one, run the following command on your console:

create fosslinuxscript
create fosslinuxscript

This software generates an error because the script “” lacks execute permission. To examine the permissions given to a file, enter the command –l at the command prompt.

ls -l
check fosslinuxscript permissions
check fosslinuxscript permissions

The result above indicates that the script has only read and write access but no execute privileges (denoted by x). The file cannot thus be run.

When attempting to list the files in a directory or execute a shell script inside of a directory, Linux may give you an error that reads “permission denied” if the directory in which you are working does not have the proper privileges. The “root” user has full access to all directories and files, enabling them to make any necessary changes. This is possible because the Linux operating system emphasizes the security of its users. Other users might not be able to make those kinds of modifications as a result.

Troubleshooting permission denied error

To overcome this “permission denied” error, just add “x” or “execution” permission to this “” file and make it executable.

Check the shell script’s file permissions first.

ls -l
check fosslinuxscript permissions
check fosslinuxscript permissions

To modify the settings, check out the next section.

Using the command chmod

The chmod command permits the modification of a file’s permissions using a reference file, numeric mode, or symbolic mode.

Syntax of command chmod:

chmod u+x flags permissions filename
  1. flags: the user has the ability to specify the extra parameters
  2. permissions: This portion of the chmod command is used to establish the permissions for a file. These permissions include “r” for read, “w” for write, and “x” for making it executable.
  3. filename: You will need to give the filename for which you wish to update the permissions.

In contrast, “u+x” makes the script executable for the current Linux user, even if the group owner or other “users” already have permission to run it.

Now to make our script executable, run the command below:

chmod u+x
make script executable
make script executable

The “” file should be rendered executable upon execution of the preceding chmod command. Execute the “ls” command to verify the modifications made to the shell script’s permissions.

ls -l

Employ the cat command to examine the contents of the script file.

check contents of script
check contents of script

Once you know the contents present in this file, you can proceed and execute the file to check to verify if the files are similar:

i love fosslinux output
I love fosslinux output

The output indicates that the permission denied error of this “” shell script has been successfully resolved.


This article provides a detailed technique for resolving the “permission denied” shell script execution problem. Every Linux user should be familiar with the simple solution for the “permission denied” issue while executing any shell script. The “chmod” tool addresses this problem by modifying the script’s file permissions to make it executable for the current user.


Related Articles


  1. Hi Padwan ..

    tzz… chmod ?
    man chmod
    whatis chmod

    ls -al
    sudo chmod 700
    ls -al

    why “sudo”, because the admin can change the rules of the files
    at foreign files..

    why Numbers.. because it’s works
    knowing is the Force !
    not knowing is Magic
    you have wrote, you make a howto about permissions, the chmod set up the rules of permissions..

    this is a babble/stammering of words and not a howto..

    if you make something, then make it right..
    and if you wana make right, must you have really known about,
    to make it right …



Please enter your comment!
Please enter your name here


More Articles Like This