马哥教育网络班第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的网络配置方法有多种,而且随发行版及版本而略微不同。我目前的测试环境为CentOS6和CentOS7。     常用的网络配置命令或方法有:ifconfig,route,netstat,ip,ss,nmcli,配置文件。 一、简介   &nb…

    Linux干货 2015-12-15
  • 马哥教育网络21期+第十二周练习博客中

    4、建立httpd服务器(基于编译的方式进行),要求:  提供两个基于名称的虚拟主机: (a)www1.stuX.com,页面文件目录为/web/vhosts/www1;错误日志为/var/log/httpd/www1.err,访问日志为/var/log/httpd/www1.access; (b)www2.stuX.com,页面文件目录为/web…

    Linux干货 2016-10-17
  • 文件系统的挂载使用总结

    文件系统使用 除根文件系统以外的文件系统创建后要使用需要先挂载至挂载点后才可以被访问,挂载点即分区设备文件关联的某个目录文件,挂载命令mount和 卸载命令umount; 挂载点: mount_point,作为被挂载的文件系统的访问入口; 作为挂载点需要满足三个条件:  (1)这个目录事先存在  (2)使用未被或不会被其他进程使用到的目录…

    系统运维 2016-11-19
  • 马哥教育网络班21期+第7周课程练习

    1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@CentOS7 ~]# fdisk /dev/sdb Command (m for help): n Select…

    Linux干货 2016-08-22
  • iptables 从入门到进阶

    Linux的防火墙体系主要工作在网络层,针对TCP/IP数据包实施过滤和限制,属于典型的包过滤防火墙(或网络层防火墙)。在Linux中netfilter和iptables都是指Linux防火墙。区别在于: netfilter:指的是Linux内核中实现包过滤防火墙的内部结构,不以程序或文件的形式存在,属于“内核态”的防火墙功能体系。 iptables:指的是…

    Linux干货 2017-01-10
  • Linux的文件压缩、解压之tar的使用

    文件的压缩   一、压缩、解压缩及归档工具 压缩 解压 后缀(压缩后) file-roller 图形操作界面上的使用(略) compress 解压一:uncompress 或compress -d (注:使用上面的解压命令,实际上是在屏幕上打印解压的文件信息,并不是真正上解压到文件,所以需要在命令后面加上“重定向到指定的文件中”,方可完成解压。如:…

    Linux干货 2016-08-18