How to give permissions for specific commands in linux - 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

Related

How to change directory permissions like made with 'sudo mkdir' in linux

I created the directory with "mkdir" command, after that I need to change permissions as if I made it with "sudo mkdir".
I've searched for the chmod command, but it doesn't seem to be what I'm looking for.
Is it possible to do this with a single command in terminal?
you can use the chown command to change the owner and group of the directory, and the chmod command to set the permissions.
sudo chown root:root /path/to/directory && sudo chmod 755 /path/to/directory

Cannot create file on ubuntu bash shell in my window machine

when I was try to use touch command on my ubuntu bash shell and in my Desktop folder /mnt/c/Users/Public/Desktop$ it give me this touch: cannot touch 'test.txt': Permission denied error.
You may not have access to the /mnt/c/Users/Public/Desktop directory as default
Run:
ls -ld /c/mnt/Users/Public/Desktop
to see whether you have write permissions as default. If you don't run:
sudo chmod +w /mnt/c/Users/Public/Desktop
This will then allow you write permissions to the directory and allow you to create files.
NOTE - Please ensure that the initial bash executable is run as administrator at Windows level

How to create a directory without root permission?

I am trying to create a directory on the server through a mina-deployer script but the shell shows Permission denied.
The command is:
mkdir -p /monit && chown ubuntu: /monit && chmod u+w . /monit
And the error is:
Mkdir: unable to create directory "/ monit": Permission denied
queue 'echo "-----> Create Monit dir"'
queue echo_cmd "mkdir -p #{config_path}/monit && chown #{user}:#{group} #{config_path}/monit && chmod u+w . #{config_path}/monit"
If you don’t have permission then you don’t have permission. You can either:
Create the file elsewhere.
Run the command as a different user (via sudo, su, or logging in as them) who does have the appropriate permission.
Adjust the permissions of the enclosing directory (but take care doing so, as / and other places have their permissions as-is for good reason).

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.

LINUX Permission issues

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 ;) .

Resources