linux基础练习题

linux基础练习题

 

1.    显示三个用户root、peng、wang的UID和默认shelllinux

[root@CentOS7 ~]# getent passwd root peng wang |cut -d: -f3,7正则表达式

 

2.    找出/etc/rc.d/init.d/functions文件中行首为某单词(包括下划线)后面跟一个小括号的行shell

[root@CentOS7 ~]# grep "^\<[_[:alnum:]]\+\>(" /etc/rc.d/init.d/functionscentos

 

三、使用egrep取出/etc/rc.d/init.d/functions中其基名centos7

[root@CentOS7 ~]# echo /etc/rc.d/init.d/functions|egrep -o "\<[[:lower:]]+$"spa

 

四、使用egrep取出上面路径的目录名.net

[root@CentOS7 ~]# echo /etc/rc.d/init.d/functions |egrep -o "[^/]+$"排序

 

五、统计last命令中以root登陆的每一个主机IP地址登陆次数字符串

[root@CentOS7 ~]# last|grep ^root|grep "still"|tr -s ' '|cut -d ' ' -f3|sort|uniq -cget

 

六、利用扩展正则表达式分别表示0-九、10-9九、100-19九、200-24九、250-255

\<25[0-5]\>

\<2[0-4][0-9]\>

\<1[0-9][0-9]\>

\<[1-9][0-9]\>

\<[0-9]\>

七、显示ifconfig命令结果中全部IPv4地址

[root@CentOS7 ~]# ifconfig |egrep -o "\<([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>"

 

八、将此字符串:welcome to magedu linux 中的每一个字符去重并排序,重复次数多的排到前面

[root@CentOS7 ~]# echo "welcome to magedu linux"|grep -o "."|grep -v ' '|sort|uniq -c|sort -nr

相关文章
相关标签/搜索