-1

In my Unix system, there is a user which has access to multiple (but not all) subdirectories of /home/. How can I remove access to most directories for this user? I've looked in /etc/groups, but didn't find much useful info in there. The system is CentOS 6.7.

Would appreciate a clue. I've looked up online, but have so far not found particularly useful information for my case, in spite of having spent a good deal of time.

1

User Directory Permissions ?

Solution:

Let's assume that you have this directory:

/home/office/files

Of course you would wanted only Staff to have access to it.

On your *nix box, you've created staff as group, and assigned staff to staff group.

To know which group a user belong to, you don't need to expose your /etc/passwd file, just issue this command:

root@Hosts:~# id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data),2001(ftpgroup)

id username, gives information about the user in question or finger username gives more information about a user such as login name, directory etc.

However, the following commands ensure that any user not in staff group will not have access to /home/office/files

chown -R myuser:staff /home/office
chmod 750 /home/office

Replace myuser with username to have access and staff with groupname to have access to the folder.

NJOY

0

Well you can check in /etc/group and check the group that the user belongs to.

Accordingly, you can change the folder you want to restrict's ownership to either root so only root can access the folder, or to a different user. Using sudo chown -R root:root <directory name> or sudo chown -R user:group <directory name> and change the folder's permissions to 750 using the command sudo chmod 750 <folder name>.

The chmod command will make sure only the user and group owner of the folder have access to the file's inside the folder.

EDIT:

Your /etc/group shows that you only have the root user on your system.

The root user has access to all files and folders in your entire system. You cannot restrict access to the root user.

You can create a normal user using the command adduser <username>. This user will have access only to the files and folders that user owns.

  • Unfortunately, there is no information in /etc/passwd or /etc/group to which group a user belongs. The format is like this: user:x:500:500::/home/user:/bin/bash – sequence Aug 28 '17 at 21:11
  • Care to add your /etc/group to your question? – Hunter.S.Thompson Aug 28 '17 at 21:13
  • There should be a Group list after user:x:500:500::/home/user:/bin/bash, ... – Hunter.S.Thompson Aug 28 '17 at 21:15
  • root:x:0:root bin:x:1:root,bin,daemon daemon:x:2:root,bin,daemon sys:x:3:root,bin,adm adm:x:4:root,adm,daemon tty:x:5: disk:x:6:root lp:x:7:daemon,lp mem:x:8: kmem:x:9: wheel:x:10:root mail:x:12:mail,postfix,opendkim – sequence Aug 28 '17 at 21:16
  • It looks like you have no user on your system except root. can you show me the output of who – Hunter.S.Thompson Aug 28 '17 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.