Im creating a script file and I want to add the permission via chmod -R 777 myApp/*
I add to the script the following line
cd /home/abc/aa_tmp chmod -R 777 myApp/*
which doesnt work , when I try to update/edit file I got permission denied, any idea what I miss here?
you can use this;
#!/bin/bash
chmod -R 777 /home/abc/aa_tmp/myApp/*
if the user has enough privileges above script works. But if permissions is as below, throw permission denied
user#host:/tmp/$ ls -arlt
..
d--------- 2 user user 4096 Aug 25 16:38 myApp
..
Either you are not root, or the user does not own myApp.
and you don't need the *, since it goes recursively.
#su
#chmod -R 777 myApp/
Related
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.
My application is hosted on ubuntu in public_html folder. When I run the command git add . it gives me the error:
warning: could not open directory 'public_html/': Permission denied
Entire code is in public_html folder
How can I solve it?
You should make sure so that your user has access or is the owner of the folder and it content. You can check the current owner and permissions by running:
ls -l public_html
Here I list all non-hidden files in a test folder:
who:test who$ ls -l
total 0
-rwxrwxrwx 1 root admin 0 Oct 3 18:04 test1
-rwxrwxrwx 1 root admin 0 Oct 3 18:04 test2
The output shows that both files are owned by the root user and belongs to a group named admin. The first column also shows the access permission, which in this case is set to read and write access to everyone.
If you would like to change the owner you can do:
sudo chown -R <user>:<group> public_html
The above will set the owner of the folder and all its content to the specified user and group; you might need sudo privileges to do this.
There is possible to only change the owner or group with the same command:
sudo chown -R <user> public_html
sudo chown -R :<group> public_html
To change the permission you would use:
sudo chmod -R <mode> public_html
Where mode is the permission, for instance 0777 for full read and write access to everyone. You can also use letters instead of an octal number when setting permissions, for instance:
sudo chmod -R a+rwx public_html
gives the same result as the first chmod command.
References
The chown command: https://ss64.com/bash/chown.html
The chmod command: https://ss64.com/bash/chmod.html
I followed this instructions to be able to host files outside of the htdocs directory, but I alwyas get 'Access Forbidden' (https://gyazo.com/af49cb00720fa4bd80e969320bd51042).
The file those permissions: $ ls -l ~/Documents/code/xampp/
total 4
-rw-r--r-- 1 julian users 3337 Apr 10 2017 test.php
How do i fix this issue ?
Aache is not able to execute the php file, because apache don't have permission to execute the test.php file.
Try giving permission to the file.
sudo chmod +x test.php
Any user can execute the file.So change the file group to www-data and give executable permission.
sudo chown root:www-data test.php
sudo chmod 775 test.php
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
when I'm trying to make shell script that error is shown ,what i must do ??
[rehamadel#localhost bin]$ sudo vi my_script.sh
[sudo] password for rehamadel:
[rehamadel#localhost bin]$ ls -l my_script.sh
-rw-r--r--. 1 root root 52 Jul 30 19:25 my_script.sh
[rehamadel#localhost bin]$ chmod u+x my_script.sh
chmod: changing permissions of ‘my_script.sh’: Operation not permitted
Resolving the operation not permitted error:
sudo chmod u+x my_script.sh
You created the file via:
sudo vi my_script.sh
# editing
This means, the owner and group of the file is root. You are not allowed to change files of it by default. You need to change permission (chmod does it) or change the owner:
sudo chown you:yourgroup my_script.sh
This should do it. Save the trouble, without creating the file via sudo.
You've created file my_script.sh with the root user as the owner (because you used sudo), which is why you're not permitted to change the permissions as yourself.
Thus, use sudo chmod u+x my_script.sh, but note that that will make the file only executable for the root user.
To make the file executable by everyone, use sudo chmod a+x my_script.sh.
I faced this error because I uploaded the files via winscp and was trying to change permission on Linux window.
I was able to change permissions via winscp.