马哥教育网络班第21期+第三周课程作业

1. 列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可。

who | awk  '{print $1}'|uniq

2.列出最后登录到当前系统的用户的相关信息

last | head -1

 

3. 读取当前系统上被用户当做其默认shell最多的那个shell

cat /etc/passwd | awk -F : '{print $7}' | sort -nr |uniq -cd |head -1

 

 

4、将/etc/passwd中的第三个字段数值最大的后10个用户的信息全部改为大写后保存至/tmp/etc.conf文件中

sort -t : -k 3 -n /etc/passwd | tail -10 | tr 'a-z' 'A-Z' > /tmp/etc.conf

 

5. 取出当前主机的ip地址

ifconfig eth0 | head -2 |tail -1 |cut -d: -f2|awk -F' ' '{print $1}'

 

6. 列出/etc目录下所有以.conf结尾的文件的文件名,并将其名字转换为大写后保存至/tmp/etc.conf文件中

ls /etc/*.conf | tr '[:lower:]' '[:upper:]' >> /tmp/etc.conf

 

7. 显示/var目录下一级子目录或文件的总个数。

#ls /var/|wc –l

8. 取出/etc/group文件中第三个字段数值最小的10个组的名字

cut -d: -f1,3 /etc/group | sort -t: -k2 -n | head -10 |cut -d: -f1

9. 将/etc/fstab和/etc/issue文件的内容合并为同一个内容后保存至/tmp/etc.test文件中。

cat /etc/fstab /etc/issue >>/tmp/etc.test

 

10.请总结描述用户和组管理类命令的使用办法并完成练习

 

[root@redhat6 ~]# groupadd distro -g 2016

 

[root@redhat6 ~]# useradd mandriva -u 1005 -g distro

 

[root@redhat6 ~]# useradd mageia -u 1100 -d /home/linux

 

[root@redhat6 ~]# echo "mageedu" |passwd –stdin mageia

Changing password for user mageia.

passwd: all authentication tokens updated successfully.

 

 

[root@redhat6 ~]# userdel mandriva

 

[root@redhat6 ~]# groupadd peguin

[root@redhat6 ~]# useradd slackware -u 2002 -g distro -G peguin

 

 [root@redhat6 ~]# usermod  -s /bin/tcsh slackware

 

[root@redhat6 ~]# groupadd admins

[root@redhat6 ~]# usermod -G admins slackware

 

 

[root@redhat6 ~]# passwd -n 3 -x 180 -w 3 slackware

Adjusting aging data for user slackware.

passwd: Success

 

 

 

[root@redhat6 ~]# groupadd clouds

[root@redhat6 ~]# groupadd nova

[root@redhat6 ~]# useradd openstack -u 3003 -g clouds -G peguin -G nova

 

 

[root@redhat6 ~]# useradd mysql -s /sbin/nologin

 

 

[root@redhat6 ~]#  echo 'redhat' | passwd –stdin openstack

Changing password for user openstack.

passwd: all authentication tokens updated successfully.

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

(0)
LionelLionel
上一篇 2016-07-26 16:43
下一篇 2016-07-26 16:52

相关推荐

  • Bash学习基础知识一“命令”

    Bash 学习基础知识 目录 一、Shell是个啥? 二、BASH的命令     2.1 命令的语法格式     2.2 什么是命令     2.4 命令的类型     …

    Linux干货 2015-04-03
  • 往死里苦练脚本啊啊啊啊啊啊啊~~~~~~~~~~~~~~~~

    1、写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; #脚本内容 [root@centos script]# cat week9_title1.sh  #!/bin/bash #Author …

    Linux干货 2017-02-16
  • iptables 补充本

    浅谈iptables一 什么是iptablesiptables 是工作在内核之上的netfilter框架的前端工具(iptables是netfilter的管理工具这样说也不为过)Firewall:隔离工具,工作于主机或网络的边缘处,对经由的报文根据预先定义的规则(识别标准)进行检测,对于能够被规则匹配到的报文实行某种预定义的处理机制的一套组件; 硬…

    Linux干货 2017-05-15
  • Stream EDitor ( Blog 6)

    文本流编辑器,行编辑器sed详解

    Linux干货 2017-11-27
  • 初识linux

    Linux 是什么?2014年之前我都没有听说过linux。 简单来说,Linux是一种操作系统,我们知道Windows吧,Linux也是一种操作系统。 特性: (1)字符界面(当然现在也有图形界面了) (2)一切皆文件 (3)许多小工具程序组合 Linux脱胎于Unix,Unix是由贝尔实验开发的。符合posix 标准,Unix系统上面的应用程序大部分可以…

    Linux干货 2016-06-01
  • 0801课堂练习与作业

    1、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中      cat /etc/issue | tr 'a-z' 'A-Z' > /tmp/issue.out 2、将当前系统登录用户的信息转换为大写后保存至/tmp/who.out文…

    Linux干货 2016-08-02