8.1_Linux习题和作业

7.28 作业

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

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


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

1
# who am i | tr 'a-z' 'A-Z' > /tmp/who.out

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

Hello, I am 用户名,the system version is here,pleasehelp me to check it ,thanks!

操作系统版本信息

1
2
3
4
5
6
[w@centos6 ~]$ mail -s help root <<eof
> Hellp, I am `whoami`
> the system version is here
> please help me to check it,thanks!
> `lsb_release`
> eof
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@centos6 ~]# mail
Heirloom Mail version 12.4 7/29/08.  Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N  1 [email protected]  Mon Aug  1 20:13  21/799   "help"
& 1
Message  1:
From [email protected]  Mon Aug  1 20:13:18 2016
Return-Path: <[email protected]>
X-Original-To: root
Delivered-To: [email protected]
Date: Mon, 01 Aug 2016 20:13:17 +0800
Subject: help
User-Agent: Heirloom mailx 12.4 7/29/08
Content-Type: text/plain; charset=us-ascii
Status: R
 
Hellp, I am w
the system version is here
please help me to check it,thanks!
LSB Version:   :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.
0-noarch
 
&


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

1
# cat /root | tr '\n' ' '


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

1
# echo "1 2 3 4 5 6 7 8 9 10" | tr ' ' '+' |bc


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

1
2
3
# cat a.txt |tr -d '^M'
# cat a.txt |tr -d '\015'
# cat a.txt |tr -d '\r'


7、处理字符串“xt.,l 1 jr#!$mn2 c*/fe3 uz4”,只保留其中的数字和空格

1
# echo 'xt.,l 1 jr#!$mn2 c*/fe3 uz4' | tr -d '[:punct:]' | tr -d 'a-z'


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

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


9、删除指定文件的空行

1
2
# cat a.txt |tr -d '\n'  #不是正确答案 
# cat a.txt |tr -s '\n'  #不是正确答案


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

1
# cat /etc/init.d/functions | tr -cs '[:alpha:]' '\n'


8.1习题

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

1
# useradd -s /bin/csh -c "Gentoo Distribution" -G bin,root gentoo

2、创建下面的用户、组和组成员关系

名字为admins 的组

用户natasha,使用admins 作为附属组

用户harry,也使用admins 作为附属组

用户sarah,不可交互登录系统,且不是admins 的成员,natasha,harry,sarah密码都是centos

1
2
3
4
5
6
7
# groupadd admins
# useradd -G admins natasha
# useradd -G admin harry
# useradd -s /sbin/nologin sarah
# echo "centos" | passwd --stdin sarah
# echo "centos" | passwd --stdin harry
# echo "centos" | passwd --stdin natasha

8.1 作业

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

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

2、修改testuser uid:4321,主组:root,辅助组:nobody,loginname:test,home:/home/test 家数据迁移注意家目录相关配置,使用户正常登录

1
# usermod -u 4321 -g root -G nobody -l test -d /home/test -m testuser

3、批量创建帐号:user1…user10 ,uid:3000-3009,shell:/bin/csh,home:/testdir/username

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

1
# vim userfile

wKiom1efSSzSmuawAABLR1XVsBM522.png

1
# vim passfile

wKioL1efSVSRPCbMAAAN9V5wOAo301.png 

1
2
3
4
5
6
7
8
9
10
11
12
# newusers userfile
# cat passfile |chpasswd
# \cp -r /etc/skel/.[^.]* /testdir/user1
# \cp -r /etc/skel/.[^.]* /testdir/user2
# \cp -r /etc/skel/.[^.]* /testdir/user3
# \cp -r /etc/skel/.[^.]* /testdir/user4
# \cp -r /etc/skel/.[^.]* /testdir/user5
# \cp -r /etc/skel/.[^.]* /testdir/user6
# \cp -r /etc/skel/.[^.]* /testdir/user7
# \cp -r /etc/skel/.[^.]* /testdir/user8
# \cp -r /etc/skel/.[^.]* /testdir/user9
# \cp -r /etc/skel/.[^.]* /testdir/user10

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

(0)
~微风~~微风~
上一篇 2016-08-04 14:41
下一篇 2016-08-04 14:41

相关推荐

  • 正则表达式

    grep:Global search REgular expression and Print out the line         文本搜索工具,根据用户指定的”模式“对目标文本逐行进行匹配检查;打印匹配到的行        模式:由正则表达式字符及文本字符所编写的过滤条件…

    Linux干货 2016-08-08
  • N25_第二周博客作业:

    N25_第二周博客作业: 1、linux上的文件管理命令都有哪些,其常用的使用方法及其相关示例演示。 Linux上常见的文件管理类命令有mkdir、touch、cp、mv、rm、stat。 mkdir:创建新目录 SYNOPSIS   mkdir [OPTION]… DIRECTORY… 常用: 1、直接建目录 [root@…

    Linux干货 2016-12-09
  • linux挂载的基本使用

    挂载   挂载是指将一个设备(通常是存储设备)挂接到一个已存在的目录上。 我们要访问存储设备中的文件,必须将文件所在的分区(已有文件系统)挂载到一个已存在的目录上, 然后通过访问这个目录来访问存储设备。 挂载条件 1、挂载点必须是一个目录。 2、一个分区挂载在一个已存在的目录上,这个目录可以不为空,但挂载后这个目录下以前的内容将隐藏不可用。对于其他…

    Linux干货 2016-09-07
  • 构建一个高可用的Nginx集群

    实验目的: 构建一个高可用的Nginx集群。 实验要求: 1、基于nat结构实现; 2、实现高可用; 实验拓扑图形: 实验步骤: 1、  按图配置各个网卡地址; 2、  设置Nginx主机(下面带#的部分为从所需要的配置,其他则一样) Yum install httpd nginx Vim /etc/httpd/conf/httpd.co…

    2017-05-15
  • Linux简单命令说明(date、clock、echo 、Tab键、screen)

    Linux简单命令说明 1、如何查询命令的帮助文档 外部命令:是系统用应用程序的一部分,在系统启动时不会被加载到内存,而在服务或进程启用时 才执行它。 查看 COMMAND –help man COMMAND 内部命令:是简小的命令,开机就已加载到shell中。 查看 help COMMAND 2、date和clock命令 date #显示当前系统时间 […

    Linux干货 2017-07-12
  • KVM基本功能

    前言:本来想写出关于KVM的精品文章,然而学的时间不够长,理解也不够透彻。所以有关KVM的高级功能只能等下一次在写。本次只涉及到KVM的基础核心功能,平时经常会使用的功能.。 一、环境准备: 1、BIOS启用Virtualication。 2、在linux系统上查看系统是否支持硬件虚拟化。Intel系列CPU支持虚拟化标识为vmx,AMD系列CPU标识为sv…

    Linux干货 2015-10-27