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).
Related
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
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
may I know a command for root to change the mode to make the user able to create files.
I tried multiple times but I can seem to solve it.
[root#master ~]# useradd -d /opt/hadoop hadoop
useradd: cannot create directory /opt/hadoop
What are the permissions on /opt/hadoop? If you created the directory manually as root then it's probably owned by root and the user has no access to it - you'd need to chown -R it to the correct ownership.
chmod 755 /opt
chown root /opt
chmod 755 /opt/hadoop
chown -R user:user /opt/hadoop
I'm trying to run mongod with its defaults so it's using the /data/db directory. I changed the owner of the data directory
sudo chown mongodb:mongodb /data -R
Like so many others i got the following error when first running mongod.:
2017-04-11T12:32:25.932-0500 I STORAGE [initandlisten] exception in initAndListen: 28596 Unable to determine status of lock file in the data directory /data/db: boost::filesystem::status: Permission denied: "/data/db/mongod.lock", terminating
Which makes sense but what doesn't make sense is the only way i can actually run it mongod is if i:
chmod 777 /data -R
If i
chmod 666 /data -R
i get the same error. Since this is supposed to be the data directory why does it require execute permission.
i added my user to the mongodb group
sudo usermod -g mongodb myuser
and then i tried
chmod 770 /data -R
and its still failing even through i'm a member of the mongodb group.
Why am i messing with all this? Because i want to secure the data directory appropriately and don't want to have to run with 777 security.
So the questions are:
Why is execute permission required
Why am i unable to run it when i was a member of the mongodb group?
Directories need to have execute permission, but the files within the directories do not need execute permission. Also, as noted by #franklinsijo, -R should be the first parameter to chmod.
To fix things I would do the following:
$ sudo chmod -R 770 /data
$ sudo find /data -type f -exec chmod 660 {} \;
This will first give everything under /data execute permission, and then return all the normal files to having only read and write, but not execute.
I have the directory /var/app which I've set to be the home directory for the user 'isapp'. The owner of the folder is 'isapp' and the group is 'isapp'. I'm using Amazon's EC2 service, so when you login to SSH you use the user 'ec2-user'. How can I make it so I can access the contents of that directory via SSH? At the moment I get permission denied with and without sudo.
You can
Create a group for the users that should be able to access this folder
Add isapp and ec2-user to this group
chgrp the /var/app folder to this group
chmod the /var/app folder and allow read and execute access for the group chmod g+rx /var/app
The fact that you cannot access this folder with sudo is more strange, sudo cd /var/app is not expected to work but sudo ls /var/app should.
usermod -G ec2-user isapp
chmod g+rwx /var/app