My hosting provider says my python script must be made to be executable(chmod755). What does this mean & how do I do it?
Cheers!
My hosting provider says my python script must be made to be executable(chmod755). What does this mean & how do I do it?
Cheers!
on the shell (such as bash), just type
chmod 755 file.py
to make it executable. You can use
ls -l file.py
to verify the execution permission is set (the "x" in "rwxr-xr-x")
Unix-like systems have "file modes" that say who can read/write/execute a file. The mode 755 means owner can read/write/execute, and everyone else can read/execute but not write. To make your Python script have this mode, you type
chmod 0755 script.py
You also need a shebang like
#!/usr/bin/python
on the very first line of the file to tell the operating system what kind of script it is.
If you have ssh access to your web space, connect and issue
chmod 755 nameofyourscript.py
If you do not have ssh access but rather connect by FTP, check your FTP application to see whether it supports setting the permissions.
As to the meaning of 755:
The digits are constructed by adding the permision values. 1 = executable, 2 = writable and 4 = readable. I.e. 755 means that you yourself can read, write and execute the file and everybody else can read and execute it.
In addition to the other fine answers here, you should be aware that most FTP clients have a chmod
command to allow you to set permissions on files at the server. You may not need this if permissions come across properly, but there's a good chance they do not.
It means, that somebody (the user, a group or everybody) has the right so execute (or read or write) the script (or a file in general).
The permissions are expressed in different ways:
$ chmod +x file.py # makes it executable by anyone
$ chmod +w file.py # makes it writeabel by anyone
$ chmod +r file.py # makes it readably by anyone
$ chmod u+x file.py # makes it executable for the owner (user) of the file
$ chmod g+x file.py # makes it executable for the group (of the file)
$ chmod o+x file.py # makes it executable for the others (everybody)
You can take away permissions in the same way, just substitute the +
by a -
$ chmod o-x file.py # makes a file non-executable for the others (everybody)
$ ...
Octal numbers express the same in a different way. 4 is reading, 2 writing, 1 execution.
simple math:
read + execute = 5
read + write + execute = 7
execute + write = 3
...
packed all in one short and sweet command:
# 1st digit: user permissions
# 2nd digit: group permissions
# 3rd digit: 'other' permissions
# add the owner all perms.,
# the group and other only write and execution
$ chmod 755 file.py