Linux users, groups, permissions, combination exercises

Source: Internet
Author: User

1, create user Gentoo, additional group is bin and root, the default shell is/BIN/CSH, the annotated message is "Gentoo distribution"
Useradd-c "Gentoo distribution"-s/bin/csh-g Bin,root Gentoo
2, create the following user, group and group membership, named Admins group, user Natasha, use admins as a subordinate group, user Harry, also use admins as a subordinate group, user Sarah, not interactive login system, and is not a member of admins, Natasha,harry,,sarah passwords are CentOS.
Idea: groupadd Admins
USERADD-G Admins Natasha
Useradd-g Admins Harry
Useradd-s/sbin/nologin Sarah
3. Echo "CentOS" |stdin–stdin Natasha
echo "CentOS" |stdin–stdin Harry
echo "CentOS" |stdin–stdin Sarah
3, copy the/etc/fstab file to/var/tmp, set the file owner to Wangcai read and write permissions, the group has read and write permissions for the SysAdmins group, other people do not have permission
Groupadd sysadmins;usermod-g sysadmins wangcai;cp/etc/fstab/ /var/tmp/chmod 660/var/tmp; Chown-r wangcai:sysadmins/var/tmp/
4, mistakenly deleted the user Wangcai home directory, please rebuild and restore the user home directory and the corresponding permission attributes
Mkdir/home/magetest
Cp-r/etc/skel/. [^.]
/home/magetest/ a bit of a head, a file that ends at any character, does not contain. and../
Chown-r Magetest.magetest/home/magetest
Chmod-r 700/home/matgtest
5, the new files created in/testdir/dir automatically belong to the G1 Group, group G2 members such as: Alice can have read and write access to these new files, group G3 members such as: Tom can only have read access to the new file, other users (not belonging to G1,G2,G3) cannot access this folder.
1) mkdir-p Testdir/dir;groupadd g1;chgrp g1/app/testdir/dir;chmod 2750/app/testdir/dir/
2) Create directory SGID create user Alice belongs to G2 Tom belongs to G3
6. Back up ACL permissions for all files in/testdir/dir to/root/acl.txt, clear all ACL permissions in/testdir/dir, and finally restore ACL permissions
Directories containing ACL permissions backup and restore using the packaging tool
Solution Ideas:
1) Backup
TAR-CVF House.tar House
Getfacl-r House > Acl.txt
2) Restore
TAR-XVF house.tar-c/var/tmp
CP acl.txt/var/tmp
Setfacl--restore Acl.txt

Linux users, groups, permissions, combination exercises

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.