How to change permission of shellscript in databricks - azure

I am having a shell script in the DBFS. When I am executing it, it gives permission error 13.
I tried to change the permission using 'chmod 755 name.sh'. But, no changes actually take place.
Could anyone help on the same?
Tried Code:
%cd /dbfs/FileStore/tables/
%sh chmod 775 wrapper.sh
%sh chmod +x wrapper.sh
%sh ls -ltr
-rw-r--r-- 1 root root 2819 Oct 28 12:01 wrapper.sh

Unfortunately, you cannot change permissions of files located in databricks filesystem (DBFS).
I have tried all the possibilities to change the file permissions located in dbfs and finally result in no success. Then, I have checked with product team for the solution. An d they have confirmed that, you cannot change the permissions of any files located in dbfs and asked ro run the script with following cmdlet "bash /dbfs/script.sh".
Hope this helps.

Related

Lost permission after chmod command

I accidentally executed the following command:
chmod -rwxr-xr-x folder_name
And after the command, I was not able to access the folder folder_name. I'm wondering if there is any way that I could recover the full permission to the folder.

Tomcat not starting in linux ---permission denied to run startup.sh

I pasted tomcat folder in Linux machine. User is root . When I go to bin folder and execute ./startup.sh I'm getting an error:permission denied. [This is what I got]
How to rectify this issue.
give:
chmod -R 777 startup.sh
Then error will come as:Cannot find ./catalina.sh
then give:
chmod -R 777 catalina.sh
Tomcat will start.
the problem was because there was no permission for executing. u can see if permission is there or not by giving:
ls -l
As color of file name is white, I suppose file is not executable; try the following command
ls -l
It gives you file list with its permission. Try using command
chmod a+x startup.sh
If still permission denied. Try
sudo chmod a+x startup.sh
Then try using
./startup.sh
If still permission denied. Then try
sudo ./startup.sh
Hope it will be helpful.
Verify, that your filesystem with the new tomcat folder isn't mounted with "noexec". Please run a "ls -l", "file start.sh" and a "head start.sh" .
Tom
It is also worthwhile to check which bash you are using with
which bash
This is because you might see the error
Cannot find ./catalina.sh
when your bash is /usr/bin/bash but is working perfectly fine when bash is /usr/bash

Though user HDFS is owner of a Dir, I'm unable to view all the directories

As HDFS user (owner of a Dir), I'm unable to view all the directories
Here is a command sample:
[ec2-user#ip-172-31-33-161 ~]$ ls -ltr
drwxrwxrwx 2 hdfs hadoop 4096 Oct 7 22:39 cards2
[ec2-user#ip-172-31-33-161 ~]$ sudo su - hdfs
[hdfs#ip-172-31-33-161 ec2-user]$ ls -ltr
ls: cannot open directory .: Permission denied
The command
sudo su - hduser
will take change the user, and take you to the home folder of hduser.
The command
sudo su hduser
can be used to remain in the current working directory even after the user is switched.
Login to ec2 machine as you previously logged in with ec2-user, change the permissions of /home/ec2-user , atleast give read permissions to other users.
chmod 777 /home/ec2-user
It is not the issue with the folder you are trying to access from the HDFS user.
ls -ltr will read the current working directory and will list the files in it.
you switched the user and you are accessing the ec2-user directory (The directory path is same as we required).
After changing the permissions, you are able to see the sub folders in ec2-user aswell.
I hope it will work for you. Please let me know for additional help.

frequent-cron: always permission denied, even after chmod 777

I've installed frequent-cron, according to the installation instructions on https://github.com/homer6/frequent-cron.
I've changed /etc/init.d/frequent_service/init_script.tpl for my own needs:
# This is arbitrary. Change it to whatever you'd like.
SERVICE_NAME="frequent_service"
# Frequent cron must exist at this path. Optionally, you can change it to a path where it does exist.
EXEC=/usr/bin/frequent-cron
# Change this to the path of your choice.
#PIDFILE=/var/run/${SERVICE_NAME}.pid
PIDFILE=/var/run/${Odoo_OPC}.pid
# Point this to the shell (or program) that you'd like to run. /tmp/myshell.sh is just an example.
#COMMAND=/tmp/myshell.sh
COMMAND=python /usr/bin/OPCConnectie/OdooNaarOPC.py
# Frequency is in milliseconds. The command will be invoked every frequency interval.
FREQUENCY=1000
But when I want to start frequent-cron with:
sudo /etc/init.d/frequent_service start
It gives these errors:
hew#hew-VirtualBox:~$ sudo /etc/init.d/frequent_service start
/usr/bin/OPCConnectie/OdooNaarOPC.py: 1: /usr/bin/OPCConnectie/OdooNaarOPC.py: import: not found
/usr/bin/OPCConnectie/OdooNaarOPC.py: 2: /usr/bin/OPCConnectie/OdooNaarOPC.py: Syntax error: "(" unexpected
Starting frequent_service frequent cron...
/etc/init.d/frequent_service: 32: /etc/init.d/frequent_service: /usr/bin/frequent-cron: Permission denied
frequent_service started.
Even after:
sudo chmod -R 777 /usr/bin/OPCConnectie/
sudo chmod -R 777 /etc/init.d/frequent_service
It gives the same errors.
I think I can split this problem in 2 problems.
1) Error about the python script:
I don't know what's wrong because it runs fine in a normal cronjob.
Is there anything wrong with how I want to start the script in init_script.tpl?
2) Error Permission denied:
I always thought chmod -R 777 gives the folder + all subfolders and files ALL permissions? So why permission is still denied?
Edit: Checked the permissions as exussum recommended:
hew#hew-VirtualBox:~$ namei -m /etc/init.d/frequent_service
f: /etc/init.d/frequent_service
drwxr-xr-x /
drwxr-xr-x etc
drwxr-xr-x init.d
-rwxrwxrwx frequent_service
hew#hew-VirtualBox:~$ namei -m /usr/bin/OPCConnectie/
f: /usr/bin/OPCConnectie/
drwxr-xr-x /
drwxr-xr-x usr
drwxr-xr-x bin
drwxrwxrwx OPCConnectie
Are these correct? Or, should these permissions be enough?
Edit 2: Answer to problem 1 (python)
Had to put the following line on top of the python script:
#!/usr/bin/env python
Found here: Crontab wont run python script
Still need permissions for /usr/bin/frequent-cron though.
It's likely you don't have permission (x) on one of the paths leading to it.
namei -m /your/path/here
will show all permissions of the path to that point.
Edit
On second look looks like your missing a shebang line
#!/usr/bin/python
at the top of the file.

ant Permission Denied problem

After extracting and saving the ant files into an opt/ directory and setting the path variable
to $ANT_HOME/bin
I ran the following command on a CentOS 5
ant -version
and I am getting the following error
-bash:/path/opt/apache-ant-1.8.2/bin/ant: Permission denied
Is there some permission I am supposed to set or some typical source of this problem?
Thanks!
If you own the file, try
chmod u+x /path/opt/apache-ant-1.8.2/bin/ant
If someone else owns it, either sudo or become root then
chmod 755 /path/opt/apache-ant-1.8.2/bin/ant
You need to have execute permissions on the file; the first gives execute permissions to the owner only and is probably preferable if you own the file and are the only one that uses it. The second requires root privileges and gives execute and read permission to everyone, plus write permission to the owner.
You can view the current permissions and ownership of the file by running ls -l /path/opt/apache-ant-1.8.2/bin/ant.

Resources