LINUX Permission issues - linux

Can anyone help me in fixing the permission issues in Linux.
I am new to Linux and i am trying to run a script called buildAll.sh
by moving to that specific directory and i typed ./buildAll.sh the response i got was
./buildAll.sh: 16: ./buildAll.sh: ./buildJS.sh: Permission denied
i tried to run using sudo ./buildAll.sh , but that didn't work.
Then i tried with chmod -r 777 buildAll.sh and again i tried to run that script but no change.
I have a folder called build which has some dependency can be seen a folder with locked picture.
Can anyone help me to run the script without having the permission issues please

in line 16 your script seems to call buildJS.sh and the permissions OF THAT seem to be incorrect

You obviously have a pervasive permissions problem. Why don't you just start again, unpack the files into a new directory without using sudo or su, and then use chmod +x on the files that need to be executable?

sudo chmod +x buildAll.sh
Should do the trick

It seems by the error message the issue is with buildJS.sh. If buildJS.sh is not in your current directory (it might not be as buildAll.sh might be changing directories), find buildJS.sh and then:
chmod +x ${directory_where_found}/buildJS.sh

Since .sh files should have executable permissions by default you can do this:
cd $YOUR_DIRECTORY
find . -name '*.sh' -exec chmod +x {} \;

I tried with sudo chmod +x buildAll.sh
rm: cannot remove ‘build’: Permission denied
cp: cannot stat ‘./build/.svn’: Permission denied
cp: cannot stat ‘./build/compiler.jar’: Permission denied
cp: cannot stat ‘./build/buildJS.sh’: Permission denied
touch: setting times of ‘build’: Permission denied
./buildAll.sh: line 14: cd: build: Permission denied
./buildAll.sh: line 16: ./buildJS.sh: No such file or directory
You have given permission only to run your script. However, this doesn't mean that you have permission for all of instructions launched by the script. The error message is there to prove it ;) .

Related

How to give permissions for specific commands in linux

I am new to linux. I have a build.sh file which consists of a lot of mkdir commands and some rm commands. But as I have installed this new in my VB, each time I run the .sh file, it says "Permission Denied for creating directory" and fails.
So is there any way that I grant directory privileges to all users.
Can anyone help me with this
Add "sudo" in the beginning of the directory creation command i.e
sudo mkdir dir_name
The issue might be with the directory in which the mkdir command is being run.
Use the command ll or ls -l to check the directory permissions.
If your directory doesn't have write privilege for the current user, you can run
chmod -R u+w /path/to/directory
This might require you to use sudo if permission is denied.
If you want to enable it for all users, run
chmod -R ugo+w /path/to/directory
Alternatively, a quick fix would be to run the build.sh file as root
sudo /path/to/build.sh
However, this approach is not advised unless you always run it as root

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

Enable write permission for directory in Linux

I keep trying to move files from a directory on Linux- but I keep getting permission errors.
Initially I was told
sudo chmod -R r+w /directory/*
But this only applies it to the directory folder (and not the files inside)
Trick is- you need to "select all" to apply the file permissions to:
sudo chmod -R a+rwx,go-w /directory/
And that's it
Or you could do sudo chmod 777 /dir/
and that's just a simple way to do the answer stated above.

Permission denied for root shrc

Whenever I open the terminal on my Centos5.1, I always get this error
/root/.cshrc Permission denied
and then I can't use networking commands (ip,ifconfig,...) because they are reported as unknown commands.
Verify that you have permissions to read .cshrc To do that issue:
ls -l /root/.cshrc
If the output begins with to dashes it means that you don't. To give yourself read permission to this file issue:
chmod +r /root/.cshrc
Now if you run ls -l /root/.cshrc the output should start with -r.

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