0801课堂练习与作业

1、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中 

    cat /etc/issue | tr 'a-z' 'A-Z' > /tmp/issue.out

2、将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文件中 

    who am i |tr '[:lower:]' '[:upper:]' > /tmp/who.out

3、一个linux用户给root发邮件,要求邮件标题为”help”,邮件正文如下:
Hello, I am 用户名,the system 

version is here,please help me to
check it ,thanks!
操作系统版本信息

 

    [stu@localhost ~]$ mail -s help root <<end

    >Hello, I am `whoami`.

    >The system version is here.

    >Please help me to check it,thanks

    >`lsb_release`

    >end

4、将/root/下文件列表,显示成一行,并文件名之间用空格隔开 

    ls /root |tr '\n' ' '

5、file1文件的内容为:”1 2 3 4 5 6 7 8 9 10” 计算出所有数字的总和 

    echo $[`echo "1 2 3 4 5 6 7 8 9 10" |tr ' ' '+' `]

6、删除Windows文本文件中的'^M'字符 

    cat ./Desktop/test.txt  |tr -d  '\r' > file.txt

7、处理字符串“xt.,l 1 jr#!$mn 2 c*/fe 3 uz 4”,只保留其中的数字
和空格 

    echo 'xt.,l 1 jr#'\n'mn 2 c*/fe 3 uz 4' |tr -cd '[:digit:] \n'

8、将PATH变量每个目录显示在独立的一行 

    echo $PATH |tr ':' '\n'

9、删除指定文件的空行 

    cat file.txt |tr -s '\n'

10、将文件中每个单词(字母)显示在独立的一行,并无空行

    cat file.txt |tr -cs '[:alpha:]' '\n'

1、创建用户gentoo,附加组为bin和root,默认shell为
/bin/csh,注释信息为"Gentoo Distribution" 

    useradd -G bin,root -c "gentoo Distribution" -s /bin/csh gentoo ; id gentoo

2、创建下面的用户、组和组成员关系
名字为admins 的组
用户natasha,使用admins 作为附属组
用户harry,也使用admins 作为附属组
用户sarah,不可交互登录系统,且不是admins 的成员,
natasha,harry,sarah密码都是centos

    blob.png

4、创建testuser uid 1234,主组:bin,辅助组:root,ftp,shell:/bin/csh home:/testdir/testuser

    useradd -u 1234 -g bin -G root,ftp -s /bin/csh -d /testdir/testuser testuser

5、修改testuser uid:4321,主组:root,辅助组:nobody,loginname:test,home:/home/test 家数据迁移

    usermod -u 4321 -g root -G nobody,loginname,test -m /home/test testuser

6、批量创建帐号:user1…user10

uid:3000-3009,shell:/bin/csh,home:/testdir/username

passwd:usernamepass

注意家目录相关配置,使用户正常登录

  1. 创建用户添加文件

    vi test.txt

    blob.png

2.添加用户

    newusers useradd.txt

3.创建密码文件

    vi pwadd.txt

    blob.png

4.为用户添加密码

    cat pwadd.txt | chpasswd

    

    

原创文章,作者:zhanghuanyu,如若转载,请注明出处:http://www.178linux.com/27150

(0)
上一篇 2016-08-02 10:58
下一篇 2016-08-02 14:44

相关推荐

  • 马哥教育网络班21期-第九周课程练习

    "1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #!/bin/bash # declare -i login_user=0 declare -i nologin_user=0 whil…

    Linux干货 2016-09-15
  • N25期–第十三周作业

    1、 建立samba共享,共享目录为/data,要求:(描述完整的过程)  1)共享名为shared,工作组为magedu;  2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;  3)添加sam…

    Linux干货 2017-04-05
  • liunx初探

    计算机的五大单元: 输出单元、输入单元、cpu内部控制单元、算术逻辑单元和内存。 计算机三大组成部分: 输入单元:键盘、鼠标等等 输出单元:屏幕、打印机等 中央处理器(CPU):含有算术逻辑、控制、记忆等 CPU种类有两种分别是:   精简指令集(RISC):这种cpu微指令比较精简,每个指令的执行时间都很短,完成的操作也很简单。常见的简单指令集C…

    Linux干货 2016-09-14
  • 20160803作业-用户组和权限管理

    http://note.youdao.com/yws/public/redirect/share?id=46f06331b737c6d08a0e8c9c3d49ac9e&type=false

    Linux干货 2016-08-08
  • RAID各级别的特性及使用介绍(8.3博客作业)

    RAID各级别的特性及使用介绍 介绍: 独立硬盘冗余阵列(RAID:Redundant Array of Independent Disks),旧称廉价磁盘冗余阵列,简称磁盘阵列。 组成: 多块磁盘,RAID控制器(硬件RAID、软件RAID)     硬件RAID:自带CPU的RAID卡,不消耗服务器资源,可通过备份…

    Linux干货 2016-07-16
  • ☞{ nfs共享mysql数据;nfs共享web资源 }

    ☞{ nfs共享mysql数据;nfs共享web资源 } MySQL基于NFS共享数据 测试环境 node1安装nfs服务 配置共享目录,设定用户权限 开启nfs服务,添加iptables规则 node2安装mysql-server(yum 安装) node2挂载nfs共享至/mydata目录,拷贝mysql数据 修改mysql-server数据目录 nod…

    Linux干货 2016-10-20

评论列表(1条)

  • 马哥教育
    马哥教育 2016-08-02 14:35

    第5题错了