linux

how do i set permissions to a folder for 1 user in linux to read the files within the folder?
Jack_son_Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

comfortjeaniusCommented:
You read this link: How to Manage File and Folder Permissions in Linux and Linux Permissions  This will give you a better understanding.

sudo chmod 400

Open in new window

0
omarfaridCommented:
A user might be:

- owner: owns a folder or a file
- from same group of users of the owner of folder or file
- others: none of above

perms are: read (r), write (w), or execute (x).

when folders or files are created, in general, gives read to all.

if you want to restrict perms to a particular user, then change ownership to that user and revoke perms:

e.g.

chown user1 /path/to/folder

chmod 700 /path/to/folder
0
omarfaridCommented:
by the way giving perms on folder on folder does not mean giving perms on files under it.

you may need to change ownership and perms of files as well
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

SandyCommented:
Would be great if you will explain what exactly you need.. for the answer of your question

1. Add user to folder as owner

#chown user folder

2. Provide read access by remoing other access.

#chmod u+r,go-rwx folder

TY/SA
0
Jack_son_Author Commented:
okay thanks; also what is the command just to add the user to a group?
0
SandyCommented:
usermod -g <primary_group_name> -G <secondary_group_name> user

-g == whenever you want to assign primary group membership
-G == to add a user as a member of more than one group.

TY/SA
0
serialbandCommented:
Those are the old standard POSIX permissions that don't easily allow fine tuning down to a single user.  Newer linux has more versatile ACLs with getfacl and setfacl to better fine tune permissions.  If your linux supports it, it's a bit easier to assign individual permissions without assigning entire groups.

https://wiki.archlinux.org/index.php/Access_Control_Lists

getfacl /Path/to/FolderOrFile

setfacl -m "u:USER_ACCOUNT_NAME:rw-" /PATH/or/File
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.