马哥linux 0801作业

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

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

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

  3. Hello,I am 用户名,the system version is here,please help me to check it,thanks!

  4. 操作系统版本信息

    3.png

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

    4.png

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

6.删除Windows文本中的'^M'字符6.png

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

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

9.删除指定文件的空行

9.png

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

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


[root@centos6 ~]# useradd -G bin,root -s /bin/csh -c "Genttoo Distribution" gentoo  

[root@centos6 ~]# id gentoo

uid=501(gentoo) gid=501(gentoo) groups=501(gentoo),0(root),1(bin)

[root@centos6 ~]# finger gentoo

Login: gentoo                           Name: Genttoo Distribution

Directory: /home/gentoo                 Shell: /bin/csh

Never logged in.

No mail.

No Plan.



12.创建下面的用户,组和组成员的关系

名字为admins的组

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

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

用户sarah,不可交互登录系统,且不是adminis的成员

natasha,harry,sarah密码都是centos



[root@centos6 ~]# groupadd admins

[root@centos6 ~]# useradd -G admins natasha

[root@centos6 ~]# useradd -G admins harry

[root@centos6 ~]# useradd -s /sbin/nologin sarah 

[root@centos6 ~]# echo "centos" | passwd –stdin natasha

Changing password for user natasha.

passwd: all authentication tokens updated successfully.

[root@centos6 ~]# echo "centos" | passwd –stdin harry

Changing password for user harry.

passwd: all authentication tokens updated successfully.

[root@centos6 ~]# echo "centos" | passwd –stdin sarah

Changing password for user sarah.

passwd: all authentication tokens updated successfully.

[root@centos6 ~]# getent group admins  

admins:x:502:natasha,harry



13.批量创建用户,修改密码


"user.txt" [New File]                                                           0,0-1         All

mage1:x:2501:2501::/home/mage1:/bin/bash

mage2:x:2502:2502::/home/mage2:/bin/bash

mage3:x:2503:2503::/home/mage3:/bin/bash

mage4:x:2504:2504::/home/mage4:/bin/bash

mage5:x:2505:2505::/home/mage5:/bin/bash

mage6:x:2506:2506::/home/mage6:/bin/bash

mage7:x:2507:2507::/home/mage7:/bin/bash

~                                               

"user.txt" [New] 7L, 287C written                                               

[root@localhost ~]# newusers user.txt

[root@localhost ~]# vim pass.txt

"pass.txt" [New File]                                                           0,0-1         All


mage1:centos

mage2:centos

mage3:centos

mage4:centos

mage5:centos

mage6:centos

mage7:centos

"pass.txt" [New] 7L, 91C written                                                

[root@localhost ~]# cat pass.txt|chpasswd


[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage1

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage2

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage3

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage4

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage5

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage6

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/mage7

[root@localhost ~]# su – mage1

Last login: Tue Aug  2 21:19:43 CST 2016 on pts/1

[mage1@localhost ~]$ 


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


[root@localhost ~]# useradd testuser -u 123 -g bin -G root,ftp -s /bin/csh -b /testdir/testuser   useradd: cannot create directory /testdir/testuser/testuser

[root@localhost ~]# id testuser

uid=123(testuser) gid=1(bin) groups=1(bin),0(root),50(ftp)

[root@localhost ~]# finger testuser

Login: testuser                         Name: 

Directory: /testdir/testuser/testuser   Shell: /bin/csh

Never logged in.

No mail.

No Plan.


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


[root@localhost ~]# groupadd testuser

[root@localhost ~]# usermod -u 4321 -g root -G nobody,testuser -d /home/test testuser

[root@localhost ~]# finger testuser

Login: testuser                         Name: 

Directory: /home/test                   Shell: /bin/csh

Never logged in.

No mail.

No Plan.

[root@localhost ~]# cp -r /etc/skel/.[^.]* /home/test

[root@localhost ~]# su – testuser

[testuser@localhost ~]$ 


16.

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

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

passwd:usernamepass

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


[root@localhost ~]# vim user.txt

"user.txt" [New File]                                                           0,0-1         All

user1:x:3000:3000::/testdir/user1:/bin/csh

user2:x:3001:3001::/testdir/user2:/bin/csh

user3:x:3002:3002::/testdir/user3:/bin/csh

  er4:x:3003:3003::/testdir/user4:/bin/csh

▽er5:x:3004:3004::/testdir/user5:/bin/csh

user6:x:3005:3005::/testdir/user6:/bin/csh

user7:x:3006:3006::/testdir/user7:/bin/csh

user8:x:3007:3007::/testdir/user8:/bin/csh

user9:x:3008:3008::/testdir/user9:/bin/csh

user10:x:3009:3009::/testdir/user10:/bin/csh

"user.txt" [New] 10L, 432C written                                              

[root@localhost ~]# newusers user.txt

[root@localhost ~]# vim pass.txt

"pass.txt" [New File]                                                           0,0-1         All

user1:user1pass

user2:user2pass

user3:user3pass

user4:user4pass

user5:user5pass

user6:user6pass

user7:user7pass

user8:user8pass

user9:user9pass

user10:user10pass

"pass.txt" [New] 10L, 162C written                                              

[root@localhost ~]# cat pass.txt|chpasswd

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user1

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user2

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user3

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user4

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user5

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user6

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user7

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user8

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user9

[root@localhost ~]# cp -r /etc/skel/.[^.]* /testdir/user10

[root@localhost ~]# su – user1

[root@localhost ~]# grtent passwd

user1:x:3000:3000::/testdir/user1:/bin/csh

user2:x:3001:3001::/testdir/user2:/bin/csh

user3:x:3002:3002::/testdir/user3:/bin/csh

user4:x:3003:3003::/testdir/user4:/bin/csh

user5:x:3004:3004::/testdir/user5:/bin/csh

user6:x:3005:3005::/testdir/user6:/bin/csh

user7:x:3006:3006::/testdir/user7:/bin/csh

user8:x:3007:3007::/testdir/user8:/bin/csh

user9:x:3008:3008::/testdir/user9:/bin/csh

user10:x:3009:3009::/testdir/user10:/bin/csh

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

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

相关推荐

  • Linux 作业

    1.       描述计算机的组成及其功能。 答:CPU、I/O、存储器; CPU:由运算器和控制器组成;运算器主要功能是对数据进行各种运算,除了进行常规计算外还能进行逻辑运算以及数据的比较、移位等操作。控制器是整个计算机系统的控制中心,它指挥计算机各部分协调地工作,保证计算机按照预先规定的目标和步…

    Linux干货 2016-10-29
  • Hadoop Hive sql语法详解

    Hive 是基于Hadoop 构建的一套数据仓库分析系统,它提供了丰富的SQL查询方式来分析存储在Hadoop 分布式文件系统中的数据,可以将结构 化的数据文件映射为一张数据库表,并提供完整的SQL查询功能,可以将SQL语句转换为MapReduce任务进行运行,通过自己的SQL 去查询分析需 要的内容,这套SQL 简称Hive SQL,使不熟悉mapredu…

    Linux干货 2015-04-13
  • class13 shell编程(五)软件包管理(三)

    一、shell编程(五) 位置变量补充 shift (踢掉参数) shift                #! /bin/bashecho "1st arg …

    Linux干货 2016-08-24
  • Linux安全与加密基础(一)

    Linux安全与加密基础(一) 常见的加密算法 SSL: Openssl与CA认证 ssh服务 dropbear AIDE sudo 常见的加密算法 密码学古以有之,尤其是在中国古代的战争中,在现在科技中,密码学不得不说是一门高深的学问,普通人知其一二足矣;本文要讨论的是关于加密与解密的基本原理与应用,以及关于Linux系统中的一些安全管理问题,如ssh服务…

    Linux干货 2016-10-06
  • Linux基本操作:关机 重启

        Linux系统安装完成以后,就要学会一些Linux的基本操作命令,首先是关机和重启命令,如果进入Linux系统之后连关机重启都不会是不是太不应该了,总不能关机或重启的时候直接关闭电源在开机吧,这就显得太不专业了,这样也会对Linux系统主机不太好,一些进程还没有关闭就直接断电,会导致Linux系统的不稳定出现问题,何况也…

    Linux干货 2016-08-04
  • raid,lvm,及sed命令的相关使用总结

    raid0 条带化 chunk最小写入单位 至少2块盘 空间大小 单块磁盘大小*nraid1 镜像  1/n   读性能提升,写入比单块盘慢  空间始终是一块盘的大小   容错率高  可以坏  n-1块盘raid10 容错高于raid01 但空间损失更多,读写性能 提升 造价高。raid4&nbsp…

    2017-08-26