马哥教育网络班第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
下一篇 2016-07-26

相关推荐

  • 网络管理及任务进程解析

     网络管理————————————— 一.IP 地址 与路由  1.首先说的是IP地址:       它们可唯一标识IP 网络中的设备,每台主机必须具有唯…

    2017-07-02
  • 2016/10/14作业

    操作类: 1、设置自己的终端提示符,要求终端登陆时:     a> 需要带颜色      b> 需要显示当前执行到了第几条命令      c> 显示当前登录终端,主机名和当前时间 首先我们要了解一个环境…

    Linux干货 2016-10-19
  • 软件包管理 — rpm & yum

    软件包管理 包管理器     二进制应用程序的组成部分:         二进制文件、库文件、配置文件、帮助文件     程序包管理器:      &…

    Linux干货 2016-08-24
  • CentOS启动流程排错

    grub legacy配置文件:/boot/grub/grub.conf     default=#: 设定默认启动的菜单项;落单项(title)编号从0开始      timeout=#:指定菜单项等待选项选择的时长     &…

    Linux干货 2016-09-13
  • 基于lvs调度的web应用——Discuz程序

    实验环境: 前端主机:10.1.43.101 后端主机1:172.16.0.9   作为lvs-dr的调度器,并且提供mysql和nfs文件共享 后端主机2:172.16.0.2   作为ap服务器之一 后端主机3:172.16.0.3   作为ap服务器之一 实验拓扑: 后端主机1: [root@node3…

    Linux干货 2016-10-26
  • N25-第七周作业

    第七周作业 — 1、创建一个10G分区,并格式为ext4文件系统; fdisk /dev/sdanp2enter+10Gwpartx -a /dev/sda(1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;mke2fs -t ext4 -b 2018 -m 2 -L “MYDATA” /…

    Linux干货 2017-02-25