Tuesday, April 1, 2008

Execution Permission in Macintosh/Unix

Today I have downloaded a latest tomcat and tried to install it. But surprisingly I cannot get the tomcat run. The error messages are shown as followed:
delia:ambienthackystat ZsxKiNG$ startup.sh
-bash: /Applications/Develop/apache-tomcat-6.0.16/bin/startup.sh: Permission denied
delia:ambienthackystat ZsxKiNG$ catalina.sh
-bash: /Applications/Develop/apache-tomcat-6.0.16/bin/catalina.sh: Permission denied
delia:ambienthackystat ZsxKiNG$ sudo /Applications/Develop/apache-tomcat-6.0.16/bin/catalina.sh
Password:
sudo: /Applications/Develop/apache-tomcat-6.0.16/bin/catalina.sh: command not found
delia:ambienthackystat ZsxKiNG$ 
That's quite weird to me because I used to install tomcat before my last system reinstallation and it worked just fine. It seems to be some permission issue in Unix like OS. 

After some google searching, I finally got the answer: I need to change the binary files' mode to executable for me. It is done by calling chmod a+x catalina.sh . Chmod is a Unix command that change files' mode, such as r(read), w(write) and x(execute). Users are only able to perform these action when the file is set to permit them to do so.
After this command, I did not get the permission denied error any more. Instead, I got a error from tomcat saying BASEDIR variable is not set correctly. This variable come out to should be set by default equal to CATALINA_HOME, but something seems prevent it from doing so. As there are lots of files in bin directory, it is reasonable to guess it is because tomcat need to execute some other file that does not have execution permission. So I just type in chmod a+x *.* and try again, tomcat ran. 

That is a very important experience to me, a new comer to Macintosh from Windows. In windows, authorization is poor and trivial, but in Mac, it becomes dominating. Even the administrator/power user will not be allow to read, write or execute a file if they have not the permission to that file.  It need a lot of practice before get used to it. Knowing how to change files' permission is an essential step. 

2 comments:

kraja283 said...

bash: ./catalina.sh: Permission denied

kraja283 said...

bash: ./catalina.sh: Permission denied