How allow folder permission for another user in Linux - linux

Consider two user accounts user1 and user2 on one Linux machine. I want user2 to be able to have read and write access to a folder in user1 home directory.
So far created a group for both users and added both users
groupadd twousers
usermod -a -G twousers user1
usermod -a -G twousers user2
then changed the group and the path and changed the permission
chgrp twousers /home/user1/folder
chmod g+rwx /home/user1/folder
Unfortunately user2 is still unable to access the folder /home/user1/folder. It seems to be quite simple but somehow I am lost. What am I missing?

chown user1.twousers /home/user1/folder
chmod 775 /home/user1/folder

Just try this until you get the permission and make sure you don't mess up the path or name of the file or folder:
chmod u+rwX,g+rwX,o+rwX

Related

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 SSH in EC2 as root with cyberduck?

I have an EC2 instance with some php scripts running on Amazon. The folder with the files has permission 755 (chmod 755 folder).
Everytime I login I have to change the folder permissions to change anything to files.
Question: Is it possible to login as root with cyberduck?
Note: I found this link How to use sudo over SFTP with CyberDuck? , but it is from 2010 and I don't know if that info is accurate or not.
If it is a folder that your user should be able to read and write. Give your user account permissions to it...
1) Create a group
sudo groupadd mygroup
2) Add your user account to that group
sudo usermod -a -G mygroup myuser
3) Change the permissions of the folder such that group has execute/modify
sudo chown -R current_owner:mygroup myfolder
sudo chmod 776 myfolder
It is odd you have to change permissions every time. If this folder is deleted and re-created by another process or user, you will need to set the environment variable umask to 776 before creating the files and folders in your script.

Linux Ubuntu 14.04.1 File Permissions

im really new to Linux permissions so I would appreciate help with this simple query.
Ubuntu 14.04.1
I have 2 users root and user1
I have a directory /var/www/html/gallery
The directory is empty
I would like to create a new group add root and user1 to that group and make that group have read, write and delete permissions(FULL PERMISSIONS), to the directory, /var/www/html/gallery
Can someone please help me ?
Thank you.
Root is usually not added to any group because root is allowed to do everything he or she wants.
So you have multiple options now:
1) you don't create a group and give the permissons to user1 (simplest solution)
chown -R user1:user1 /var/www/html/gallery
chmod -R 700 /var/www/html/gallery
2) you create the group anyways and just add one user. that just makes sense when you want to add some more users to the group later
you can use acl for permissions,
sudo apt-get install acl
sudo groupadd connoisseurs
sudo usermod -a -G connoisseurs Teddy
sudo setfacl -m g:connoisseurs:rwx /var/www/html/gallery
you can vary permissions with r,w,x combinations.

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.

Linux folder permissions for multiple users

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

Resources