• Linux操作系统作业


    1. 使用cat命令加行号显示文件/etc/issue的内容。

    [root@localhost example]# cat -n /etc/issue

         1  \S

         2  Kernel \r on an \m

          3 

    2.使用more命令查看文件/etc/man_db.conf的内容。

    [root@localhost example]# more /etc/man_db.conf\

    3使用less命令查看文件/etc/man_db.conf的内容。

    [root@localhost example]# less /etc/man_db.conf(进入文件查看)

    4使用head命令查看文件/etc/man_db.conf前15行的内容。

    [root@localhost example]# head -n -15 /etc/man_db.conf

    5将/usr/bin/passwd中的内容使用ASCII方式输出。

    [root@localhost example]# od -t c /usr/bin/passwd

    6将当前目录设为/root.

    [root@localhost example]# cd

    7执行 echo pwd>>pwd.sh命令,了解命令产生的结果。

    将内容(pwd)追加到文件末尾

    8查看文件pwd.sh的权限。

    [root@localhost ~]# ls -l pwd.sh

    -rw-r--r--. 1 root root 4 9月  25 21:06 pwd.sh

    9执行./pwd.sh,能否执行,为什么?

    [root@localhost ~]# ./pwd.sh

    bash: ./pwd.sh: 权限不够

    10将pwd.sh文件权限为可执行,再重新执行./pwd.sh。

    [root@localhost ~]# chmod u+x pwd.sh

    [root@localhost ~]# ./pwd.sh

    /root

    11新建用户user1,user2,user3。

    [root@localhost ~]# useradd user1

    [root@localhost ~]# useradd user2

    [root@localhost ~]# useradd user3

    12在/tmp下新建文件夹test。

    [root@localhost ~]# mkdir /tmp/test

    13查看test文件夹的权限是多少?

    [root@localhost ~]# cd /tmp

    [root@localhost tmp]# ls -l test

    总用量 0

    14修改test文件夹的权限为777。

    [root@localhost tmp]# chmod 777 test

    15分别使用user1、user2和user3在/tmp/test下新建文件:用户名.txt

    [root@localhost ~]# su user1

    [user1@localhost root]$ touch  /tmp/test/user1.txt

    [user1@localhost root]$ exit

    exit

    [root@localhost ~]# su user2

    [user2@localhost root]$ touch  /tmp/test/user2.txt

    [user2@localhost root]$ exit

    exit

    [root@localhost ~]# su user3

    [user3@localhost root]$ touch  /tmp/test/user3.txt

    [user3@localhost root]$ exit

    Exit

    16以user1身份看能否删除user2和user3的文件?

    [user1@localhost root]$ rm  /tmp/test/user2.txt  /tmp/test/user3.txt

    rm:是否删除有写保护的普通空文件 "/tmp/test/user2.txt"?y

    17如何保证每个用户都可以在/tmp/test中新建文件,但只能删除自己的文件而不能删除别人的文件?

    只需要设置其他用户对此目录具有rwxt的权限即可。设置方法为: chmod o+rwxt test

    18修改/tmp/test的权限为1777

    [root@localhost ~]# chmod 1777 /tmp/test

    19验证user1、user2和user3都可以在/tmp/test下新建、修改、删除自己的文件

    [root@localhost ~]# su user2

    [user2@localhost root]$ touch  /tmp/test/user2.txt

    [user2@localhost root]$ exit

    exit

    [root@localhost ~]# su user3

    [user3@localhost root]$ touch  /tmp/test/user3.txt

    [user3@localhost root]$ exit

    Exit

    20以user1身份看能否删除user2和user3的文件?

    [user1@localhost root]$ rm  /tmp/test/user2.txt  /tmp/test/user3.txt

    rm:是否删除有写保护的普通空文件 "/tmp/test/user2.txt"?y

    rm: 无法删除"/tmp/test/user2.txt": 不允许的操作

    rm:是否删除有写保护的普通空文件 "/tmp/test/user3.txt"?y

    rm: 无法删除"/tmp/test/user3.txt": 不允许的操作

  • 相关阅读:
    《Unix 网络编程》15:Unix 域协议
    WPF控件10
    Android面试冲刺:2022全新面试题——剑指Offer(备战金九银十)
    错误处理函数 / 模板上下文处理函数
    Python常用标准库(pickle序列化和JSON序列化)
    搭建深度学习环境(Pytorch)
    linux配置免密登陆
    vue项目 (element-ui + vue-cropper) 创建一个实用的图片尺寸调整 角度调整 图片上传工具
    【历史上的今天】7 月 5 日:Google 之母出生;同一天诞生的两位图灵奖先驱
    Camunda工作流平台与Keycloak的集成
  • 原文地址:https://blog.csdn.net/qq_69749315/article/details/133363013