Linux experiment report (1) - file permissions and management - 2021.5.22

1. Configuration requirements:

  • Virtual machine VM15.0 and above
  • centos7.0 version
  • windows7 or windows10 host

2. The purpose of the experiment

  • Proficient in the related methods of files and directories, file permissions and management
  • Learn how to modify file permissions and how to assign permissions during configuration

3. Experimental requirements: (all the following operations should be completed under the root user)

  1. Create a new user named 180xname (x is the class number, name is your own name), and meet the following requirements: the user id is 2000, and the password is redhat123.
useradd -u 2000 1802huangjie
echo redhat123 |passwd --stdin 1802huangjie
  1. Create a new user named zhangsan with class as its subgroup.
groupadd class
useradd -G class zhangsan
  1. Create a new user named lisi with class as its subgroup.
useradd -G class lisi
  1. Create a new user named wangwu, which does not belong to the class group, and set its shell as a non-loginable shell.
useradd -s /sbin/nologin wangwu
  1. The passwords of the three users zhangsan, lisi, and wangwu are all set to 123456 by the echo announcement.
echo 123456 | passwd --stdin zhangsan
echo 123456 | passwd --stdin lisi
echo 123456 | passwd --stdin wangwu
  1. Copy the file /etc/hosts to the /var/tmp directory and configure the permissions of the /var/tmp/hosts file as follows:
cp -p /etc/hosts /var/tmp
  • The owner of the file is 180xname, and the group to which the file belongs is 180xname.
chown 1802huangjie:1802huangjie /var/tmp/hosts
  • This file has no execute permission for anyone.
chmod a-x /var/tmp/hosts
  • User zhangsan has read and write permissions on this file.
setfacl -m user:zhangsan:rw /var/tmp/hosts
  • User lisi can neither read nor write to this file.
setfacl -m user:lisi:--- /var/tmp/hosts
  • All other users (including existing users and users created in the future) have read access to the file.
setfacl -m m::r /var/tmp/hosts

4. Next: Linux Experiment Report (2) - Disk Storage Management

Linux Experiment Report (2) - Disk Storage Management

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325717440&siteId=291194637