zoukankan      html  css  js  c++  java
  • day 2 Linux基础

    6、用户、群组和权限

    1) 新建用户natasha,uid为1000,gid为555,备注信息为“master”

      useradd natasha

      usermod -u1000 natasha     usermod -g500 natasha   usermod -cmaster 

    2) 修改natasha用户的家目录为/Natasha

      usermod –d /Natasha natasha
    3) 查看用户信息配置文件的最后一行

      tail -1 /etc/passwd

    4) 为natasha用户设置密码“123”

      passwd natasha

    5) 查看用户密码配置文件的最后一行

      tail -1 /etc/shadow 

    6) 将natasha用户账户锁定

      usermod –L natasha
    7) 将natasha用户账户解锁

      usermod –U natasha
    8) 新建组police,gid为999

      groupadd police   groupadd -g 999 police
    9) 查看组配置文件的最后一行

    tail -1 /etc/
    10) 将natasha用户加入police组

    usermod -aG police natasha
    11) 修改police组的组名为jingcha
    12) 删除natasha用户,连家目录和邮箱一起删除

    userdel -r natasha
    13) 删除jingcha组

    groupdel jingcha

    7、用户、群组和权限的深入讨论 

    1) 在用户的主目录下创建目录test,进入test创建空文件file1

    [root@bogon ~]# mkdir test
    [root@bogon ~]# cd /test
    [root@bogon test]# touch file1.text


    2) 以长格式形式显示文件信息,注意文件的权限和所属用户和组

    [root@bogon test]# ll file1.text
    -rw-r--r--. 1 root root 0 11月 11 23:07 file1.text

    3) 为文件file1设置权限,使其他用户可以对此文件进行写操作。

    -rw-r--r--. 1 root root 0 11月 11 23:07 file1.text
    [root@bogon test]# chmod o+w file1.text
    [root@bogon test]# ll
    总用量 4
    ----r--rwx. 1 root root 27 11月 11 22:28 a.text
    -rw-r--rw-. 1 root root 0 11月 11 23:07 file1.text

    4) 查看设置结果,

    [root@bogon test]# ll
    总用量 4
    ----r--rwx. 1 root root 27 11月 11 22:28 a.text
    -rw-r--rw-. 1 root root 0 11月 11 23:07 file1.text

    5) 取消同组用户对文件file1的读取权限,并查看设置结果。

    [root@bogon test]# chmod g-w file1.text
    [root@bogon test]# ll
    总用量 4
    -rw-r--rw-. 1 root root 0 11月 11 23:07 file1.text

    6) 用数字表示法为文件file设置权限,所有者可读、可写、可执行,所属组用户和其他用户只具有读和执行的权限。设置完成后查看设置结果。

    [root@bogon test]# chmod 755 file1.text
    [root@bogon test]# ll
    总用量 4
    -rwxr-xr-x. 1 root root 0 11月 11 23:07 file1.text

    7) 用数字形式更改文件file1的权限,使所有者只能读取此文件。其他任何用户都没有权限。查看设置结果。

    [root@bogon test]# chmod 700 file1.text
    [root@bogon test]# ll
    总用量 4
    -rwx------. 1 root root 0 11月 11 23:07 file1.text

    8) 回到上层目录,查看test的权限

    [root@bogon test]# cd ..
    [root@bogon /]# ll -d /test
    drwxr-xr-x. 2 root root 4096 11月 11 23:07 /test

    9) 为其他用户添加对此目录的写权限

    [root@bogon /]# ll -d /test
    drwxr-xr-x. 2 root root 4096 11月 11 23:07 /test

    [root@bogon ~]# chomd o+w /test

    [root@bogon ~]# ll -d /test
    drwxr-xrwx. 2 root root 4096 11月 11 23:07 /test

  • 相关阅读:
    合并两个排序的链表
    C#中调用C++的DLL文件
    C#获取进程的主窗口句柄
    在VS2008中编译纯c/c++程序并由c#调用过程 及 C++引用c#dll 模拟登陆实现
    C#多屏幕显示器编程
    Windows系统下的多显示器模式开发日记
    在 C# 中调用 C++
    C# 中调用C++ DLL (P/Invoke)
    C#多屏时控制窗体显示在哪个显示器上
    c# Winform 开发分屏显示应用程序
  • 原文地址:https://www.cnblogs.com/sunkai1993/p/6052072.html
Copyright © 2011-2022 走看看