• linux实验-基本指令1


    1、root帐号登录,查看/tmp目录,如果/tmp目录下没有子目录myshare,则建立该目录。
    2、创建帐号testuser。
    3、把myshare目录及其目录下的所有文件和子目录的拥有者该为testuser,工作组改为users。
    4、切换至testuser帐号。进入/tmp/myshare目录,采用vim编辑器编写以上程序,程序名称为hello.sh:
    #!/bin/bash
    echo "app start"
    echo -e
    func (){
      echo "hello world!"
    }
    func
    echo -e
    echo "app end"
     
    5、保存hello.sh后,给予hello.sh拥有者可读、可写和可执行的权限,同组可读可执行,其他人可执行权限。
    6、输入./hello.sh,观察程序输出的效果。
    7、进入testuser的用户主目录,在这个目录下创建hello.sh的软链接,同时拷贝hello.sh到该目录下并改名为hello.sh.bak,要求拷贝时保留文件属性值。
    8、退出testuser帐号,回到root帐号,从/开始查找后缀名为.conf的所有文件,把输出结果重定向到testuser帐号的主目录下的output.txt文件。
    9、在上一步操作的.conf文件中找出文件容量最大的和最小那个,并把这两个文件的容量大小输出到output.txt文件中。
    10、统计出系统中有多少个用户帐号,把数量输出到output.txt文件中。
    11、把output.txt文件转换为windows记事本可正规打开的格式。
    12、tar打包压缩testuser帐号主目录下的所有文件。
    13、用U盘把上一步打包压缩文件拷贝到U盘上。
    14、执行userdel -r testuser,执行rm -fr myshare
     
     
    我的做法

    刚开始就用root账号登进去
    1 进入tmp目录 cd /tmp
    2 创建目录 mkdir myshare
    创建用户 useradd testuser
    设置密码 passwd testuser
    3 修改文件权限 chown -R testuser:users myshare
    4 切换账号 su testuser
    进入myshare目录 cd /tmp/myshare
    vi hello.sh

    5 保存文件后,赋予权限 chmod 751 hello.sh
    6 ./hello.sh

    7 cd ~
    ln -s /tmp/myshare/hello.sh myhello.sh
    cp -p /tmp/myshare/hello.sh hello.sh.bak

    8 回到root账号 su root
    find / -name "*.conf" >output.txt

    9 find / -name "*.conf" |xargs du -h |sort -n | tail -1 >> output.txt
    find / -name "*.conf" |xargs du -h |sort -n | tail -1 >> output.txt
    再vi output.txt把文件里面后面两行的文件名删掉。

    10 who -a | wc -l >>output.txt
    11 unix2dos -n output.txt.dos output.txt
    12 tar -zcvf double.tar.gz testuser

     
     
     
     
     
  • 相关阅读:
    Java流关闭总结
    Too many open files 问题
    oracle数据库表被锁的解锁方法
    中文转换成字节数组
    java接口理解
    最小的K个数
    数组中出现次数超过一半的数字
    复杂链表的复制
    二叉树中和为某一值的路径
    二叉搜索树的后序遍历序列
  • 原文地址:https://www.cnblogs.com/double891/p/8776256.html
Copyright © 2020-2023  润新知