1、显示当前系统上root、fedora或user1用户的默认shell;grep-E"^root|^fedora|^user1\>"/etc/passwd|cut-d:-f1,72、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();grep-o"[[:alpha:]]\+()"/etc/rc.d/init.d/functions3、使用echo命令输..
分类:
其他好文 时间:
2016-09-05 09:19:41
阅读次数:
150
1、显示当前系统上root、fedora或user1用户的默认shell;#!/bin/bash
foruserinrootfedorauser1
do
id$user&>/dev/null
if[$?-eq0]
then
cat/etc/passwd|grep^$user|cut-d:-f7
fi
done
//输出:
//下面是或的输出
/bin/bash
#!/bin/bash
foruserinrootmysql
do
id$user&..
分类:
其他好文 时间:
2016-09-04 17:53:04
阅读次数:
228
1、显示当前系统上root、fedora或user1用户的默认shell;#useraddfedora#useradduser1#grep-E"^(root|fedora|user1)\>"/etc/passwd|cut-d:-f1,7(注意是使用扩展正则表达式)^:行首|:或者():将一个或多个字符捆绑在一起,当作一个整体进行处理cut-d分隔符-fN,M:指定分隔..
分类:
其他好文 时间:
2016-09-04 17:48:12
阅读次数:
193
1、显示当前系统上root、fedora或user1用户的默认shell;#grep--color-E"^(root|fedora|user1).*‘/etc/passwd|cut-d:-f1,72、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();grep--color-E"[[:alnum:]]+\(\)"/etc/rc.d/init.d/functionsgrep..
分类:
其他好文 时间:
2016-09-04 17:47:10
阅读次数:
197
本周作业内容:1、显示当前系统上root、fedora或user1用户的默认shell;答:[root@localhost~]#cat/etc/passwd|egrep‘^(root|fedora|user1)‘
root:x:0:0:root:/root:/bin/bash
[root@localhost~]#2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:he..
分类:
其他好文 时间:
2016-09-04 17:46:47
阅读次数:
210
1、显示当前系统上root、fedora或user1用户的默认shell;答:需要找到3个字符串,需要用到“或”命令,所以使用egrep。找到后cut再次筛选出我们需要显示的用户默认的shell。2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();答:3、使用ech..
分类:
编程语言 时间:
2016-09-04 00:18:51
阅读次数:
351
第五周作业1、显示当前系统上root、fedora或user1用户的默认shell;[root@STCO6~]#grep-E‘^(root|fedora|user1)\>‘/etc/passwd|cut-d:-f1,7
root:/bin/bash
fedora:/bin/bash
user1:/bin/bash2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hel..
分类:
其他好文 时间:
2016-09-03 07:31:17
阅读次数:
158
1、显示当前系统上root、fedora或user1用户的默认shell;PS:第一眼看到问题可能会有点头疼,那就把问题拆分完成,组合多个简单命令完成复杂工作
第一步,查找到这些用户并显示:使用|或衔接多个过滤条件:
[root@CentOS7~]#grep-E"^root\>|^fedora\>|^user1\>"/etc/..
分类:
系统相关 时间:
2016-09-02 23:37:06
阅读次数:
415
本周作业内容:1、显示当前系统上root、fedora或user1用户的默认shell;#没有fedora、user1用户,添加fadora,user1模拟环境
[root@localhost~]#useradd-s/sbin/nologinfedora&&useradd-s/bin/shuser1
#添加fadora、user1用户,并指定不同的默认shell
[root@localhost~]#..
分类:
编程语言 时间:
2016-09-02 16:09:07
阅读次数:
228
1、显示当前系统上root、fedora或user1用户的默认shell;#grep"^\(root\|fedora\|user1\)"/etc/passwd2、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello();#grep"[[:alpha:]].*()"/etc/rc.d/init.d/functions3、使用echo命令输出一个绝对路径,..
分类:
其他好文 时间:
2016-09-01 00:19:35
阅读次数:
171