how do i change mac folder permission? - linux

If I Enter ls -al in the Mac terminal, The results are as follows. Like the first line, I want to change _mysql to chowon but I don't know how to do that.
In fact, several attempts were made through chmod commands but were unsuccessful.

In order to change the permission, you should first have the permission to do that. Mostly those are administrators or root users. Please show us the result of who am i or try to start the chmod command with a sudo: sudo chmod .... You'll be asked for a password in order to do this.

Can you try changing the owner and group from _mysql and admin to chowon and staff like this :
chown chowon .. # To change the owner
chown chowon:staff .. # To change the owner and group
You need to add sudo in front of these commands if you get Operation not permitted.

Related

Give access to my application to read/write a file on var/www

In my application, I need to write a file.json in /myserver/home/www/var/myApplicationFolder/file.json but it does not work. (there is no problem in the code as it has already been tested)
I think it because of the root permission .
What should I do?
If you'd like any account on the server to be able to write to this folder then run:
sudo chmod 777 /myserver/home/www/var/myApplicationFolder/
or if you'd just like it to be able to write to that specific file:
sudo chmod 777 /myserver/home/www/var/myApplicationFolder/file.json
The chmod command takes 3 numbers which correspond to the permissions that the owner, people in the group, and everyone else gets respectively. The issue with the older answer was that they where giving the owner all the permissions (the first 7), but no giving any permissions to anyone else (the second and third 5).
In the terminal run the command:
sudo chmod 755 /myserver/home/www/var/myApplicationFolder/
it should work.

Add permission to two users (my apache server and myself)

I want my php script to be able to create file, edit, and delete it, so I need to give it permissions to do so in Linux.
I've done this with one of the stackoverflow answers with this code:
sudo chown -R www-data:www-data .
But when I do so, I lose my user access to files - so I can't open them with gedit for example until I change permissions back like so:
sudo chown -R igor /var/www/html/demo/myDir
I think I need to give permission to Apache, but leave my access as well. I feel there is some easy answer to make it work, but I can't find one. Any suggestions?
You are changing the owner of the files, if you want to change the permission of the files without changing the owner you need to use : chmod.
For example if you want to read write and execute on the current folder you can use: chmod 777 .
If what you want is the two users have the same permissions over the folder you could add your user to the group www-data (assuming that you are in the files folder):
sudo usermod -a -G www-data youruser
sudo chgrp -R www-data .
sudo chmod -R 770 .

How to let a program can be run by a specific user with owner's privilege on linux

I want a program can be run by a specific user (let's say tony) and the owner (root). I thought I could use setuid on the program:
chmod u+s program1.sh
But it returns out all other users can run program1.sh with owner's privilege. Instead of using setuid, change the group program1.sh so that the group contains tony could be good to allow only tony and the owner can run the program, but tony cannot run with owner's privilege.
So I don't know how to archive this requirement. Hope guys can give me some advice.
you chmod u+s program1.sh just like you did, then chmod o-x program1.sh to prevent 'other' users from running that file. Now create a new group, and use chown to give that group ownership of the file. Finally add any users you would like to be able to execute the file, to the newly created group. Don't forget to chmod g+x to allow users of the new group to execute the file.

Can create / edit groups file but can't change permission

my scenario is:
2 users : firstUser and secondUser in developers group.
This user connect to server with sftp;
if firstUser create a file, this file was 775 , ownered by firstUser, group developers;
with secondUser i can edit and write this file but if i try:
chmod 777 testfile.txt
I can't do that!
Could you provide the results of 'ls -l testfile.txt'. There are two ways you can try to resolve this. I am unsure if they would be the best approach but here they are. Add a sudo prior to the chmod, e.g., 'sudo chmod 777 testfile.txt' and supply the root password. Or you could change the owner, e.g., 'chown secondUser:developersgroup testfile.txt' then chmod.
only root or the owner can do that.

how to only allow sudo on specify path?

in Linux:
I want to limited user only can do sudo on specify path.
sudo chmod works on /home/Krome/revA
but sudo chmod failed on /home/Krome
Thanks!
Restricting a user or process to a certain path can be done with chroot - the problem here is that after the chroot the commands in $PATH and dynamically loaded objects would no longer be accessible, so you'd need a statically linked shell which executes the chroot as well as the built-in commands that the user shall be able to issue.
I don't think it possible, and am pretty sure it's not reasonable.
chmod would work inside /home/Krome if it's the user's home folder.
I think you need a regular user (without sudo), and everything else can be managed by adding that user to groups and sharing some folders to those groups.
Add to /etc/sudoers something like the following line:
%users ALL = NOPASSWD: /bin/chmod [ugoa][-+=][rwxXst] /home/Krome/*
It basically says that all group users members can invoke sudo chmod in symbolic mode on anything under /home/Krome/ path.
See man sudo for more details.

Resources