User file management operations related (1)

1. Document related

  1. Create a soft link [ln -s file name after linking the source file]
ln -s /data/index.html index.html   #创建一个文件index.html链接到/data/index.html上
  1. Add content to the end of the file [echo "content added" >> index.html]
  2. Replace the string in the file: [sed's/original string/replacement string/g' file path] Special characters need to be escaped with a backslash "\" and replace them all. Delete g to replace only the first one in each line
  3. Quickly view the content of the configuration file, filter and display [grep'^[aZ]' file path]
grep '^[a-Z]' /etc/sysconfig/memcached
  1. Configuration file filtering comment information only displays configuration content [grep -Ev'^$|^#' file path]
grep -Ev '^$|^#' /etc/sudoers
  1. File transfer within LAN
scp 要拷贝的文件路径 用户名@远程主机ip:远程主机存放目录     #拷贝单个文件
scp -r  要拷贝的文件路径 用户名@远程主机ip:远程主机存放目录 #拷贝文件夹

Two, file permissions

  1. What is the difference between file permission bit x (execution permission) for directories and files?
    ①For a file, it means it has the permission to be executed by the system
    ②For a directory, it means whether the user has the permission to enter the directory

  2. Create a new empty file exer1 under /tmp and check its access permissions. Now you need to increase the write permissions of users in the same group.
    Insert picture description here

  3. Create a new directory /tmp/tony and set the following permissions. Set the owner of this directory to tony, and set read, write, and execute permissions. Set the group to which this directory belongs to sales, and set read and execute permissions. Other users do not have any permissions.
    Insert picture description here

  4. User group and profile access control list FACL

  • Create a new user group named manager, create two user accounts: shelly and harry, and set the manager group as an additional group of these two users.
    Insert picture description here

  • Copy the file /etc/fstab to the /var/bmp directory, and set the permissions for the file /ar/tmp/fstab.
      -①Add a FACL entry to enable the manager group to have read permissions.
    Insert picture description here
      -②Add ACL entries so that user harry has read and write permissions.
    Insert picture description here
      -③Add ACL entries so that the user shelly does not have any permissions.
    Insert picture description here
      -④Delete the ACL entry of the manager group.
    Insert picture description here
    Insert picture description here

  1. Assuming that the group belonging to the /var/test directory is marketing, permission settings for the /var/test directory are required, so that any file created in the directory or the group belonging to the directory will automatically use the marketing group.
    Insert picture description here
  2. Set the /var/log/messaqes file to only append data to it, but not delete the original data.
    Insert picture description here
  3. Check the absolute path of gpasswd, passwd, useradd, usermod, userdel, and specify an ordinary user named amy in the system, so that it has the authority to execute these root users. [Use the which command to view the absolute path, and follow (user name)]
使用which查看命令绝对路径 --> 修改配置文件/etc/sudoers
添加样例【用户名 ALL=命令绝对路径1,命令绝对路径2,命令绝对路径3....

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43161762/article/details/113200597