I am new to Ubuntu... I am trying to run my first simple python program "Hello World" ... After running following commands in terminal
1. chmod +x filename.py
2. ./filename.py
terminal is showing following error "bash: ./filename.py: Permission denied
"
what can I do for solve about problem?
Solution to fix the bash: ./program_name: permission denied error. chmod u+x program_name– In this line, the chmod command will change the access mode to execute, denoted by x. only the file's owner will have the permission to execute the file.
To resolve this error, we can use the chmod command, which stands for change mode . The chmod() requires two arguments, the path of the file/folder you want to access and the file mode.
To fix the permission denied error in Linux, one needs to change the file permission of the script. Use the “chmod” (change mode) command for this purpose.
We can provide the executable permission by using the below command, chmod +x filename.sh. chmod (Change Mode) - Using chmod we can change the access permissions to file system objects. +x - It makes the file executable.
Do you have the appropriate incantation at the top of your python file? e.g.,
#!/usr/bin/python
(or alternatively #!/usr/bin/env python
)
Just to clarify, chmod +x
only makes a file executable, it doesn't run it.
And I'm assuming your script looks like nothing more complex than this:
#!/usr/bin/env python
print 'hello world'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With