马哥教育网络班第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

相关推荐

  • Linux文件系统管理

    Linux文件系统: ext2, ext3, ext4, xfs, btrfs, reiserfs, jfs, swap swap: 交换分区(虚拟内存) 光盘: iso9660       windows: fat32, NTFS       Unix: FFS, U…

    Linux干货 2016-08-15
  • systemd管理

    centos7:systemdSystemd :系统启动和服务器守护进程管理器,负责在系统启动或运行时,          激活系统资源,服务器进程和其它进程Systemd 新特性:        系统引导时实现服务并行启动      &n…

    Linux干货 2017-04-10
  • 第五周练习

    1、显示当前系统上root、fedora或user1用户的默认shell; egrep “^(root|fedora|user1)” /etc/passwd | cut -d: -f7 2、找出/etc/rc.d/init.d/functions文件中某单词后边跟一组小括号的行,形如:hello(); grep “\<.*\>()” /etc/r…

    Linux干货 2017-08-04
  • Linux中正则表达式及find指令的使用

    1、显示当前系统上root、Fedora或user1用户的默认shell [root@centos6 ~]# grep -E "^\<(root|fedora|user1)\>" /etc/passwd root:x:0:0:root:/root:/bin/bash fedor…

    Linux干货 2016-10-24
  • 高可用集群部署文档

    同学们都很活跃,自己好久没写了,也动动笔,下面文章写着玩的,如有错误请联系(NET7-粤-义薄云天) 高可用集群部署文档   目录: 目录: 1 项目需求: 2 实现方式: 2 拓扑图: 3 系统及软件版本: 3 安装步骤: 4 IP分配: 4 LVS和keepalived的安装和配置: 4 LVS主配置: 4 LVS2备 配置: 7 w…

    Linux干货 2015-08-11
  • Jerry的学习计划/目标/宣言

    学习计划 按照班主任给的计划进度来,多动手做实验。 目标 勇敢做自己,做更好的自己 宣言 能不能成为高富帅,日后是否能愉快地装逼,就看这半年!

    Linux干货 2016-10-24