How to give permissions for specific commands in linux

440 views Asked by At

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

2

There are 2 answers

1
Divaker Soni On

Add "sudo" in the beginning of the directory creation command i.e

sudo mkdir dir_name
0
Farhad Bharucha On

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