1

I have renamed a shell script on my linux server and uploaded a new file through FTP tool like WinScp.

Now, I am trying to execute this file through Terminal but I am getting Permission Denied Error.

To fix this issue, I executed touch command but still have the same issue. I am using the same user account to login into Terminal as well as upload the file.

Is this the permission issue like my user account hasn't access to upload the file?

1

You need to make the file excutable. The touch command doesn't do that, the chmod command does:

chmod a+x some_new_file.sh

Or use your GUI to set the excutable permissions on the file.

Don't forget, if you're uploading a script, that you must transfer the file in TEXT mode and not in BINARY mode. Otherwise it'll fail at the next step (when you run it).

  • Thank you @roaima. Should I choose Text mode for all types of file like - XML, .pip, .php or only for shell scripts? – ursitesion Dec 10 '15 at 22:31
  • Hi roaima, can you please confirm about what is the difference between TEXT mode and ASCII mode transfer? – ursitesion Dec 11 '15 at 17:52
1

To see the permissions on your file run:

ls -l yourfile

You should see output like:

$ ls -l newfile
-rw-rw-r--. 1 ira ira 0 Dec 11 09:41 newfile

Where the "-rw-rw-r--." part is read/write/execute permissions for the user, group and everybody else. The 'ira ira' part is the user and then the group that the user belongs to.

From more info on chown and chmod see this how-to article

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.