linux入门每日一题

[oldboy@oldboy-blog www]$ ls -l /root/
ls: cannot open directory /root/: Permission denied
答案:对目录没有rx权限
过滤出/etc/passwd中包含root或oldboy的行
egrep 'root|oldboy' /etc/passwd

创建一个叫mysql的虚拟用户,uid为888(如果mysql存在用mysql01)
#useradd -u 888 -s /sbin/nologin   -M  mysql01
在/etc/passwd过滤出以root开头的行
#grep '^root' /etc/passwd
#sed  -n  '/^root/p'   /etc/passwd
#sed  '/^root/!d'   /etc/passwd 
#awk  '/^root/'   /etc/passwd
在/etc/passwd中过滤出以bash结尾的行
#grep 'bash$' /etc/passwd
#sed  -n '/bash$/p'  /etc/passwd
#sed  '/bash$/!d'  /etc/paswd
#awk  '/bash$/'   /etc/passwd 
#awk  '!/bash$/{next}1'   /etc/passwd

grep -o '. ' /etc/passwd可以取出文件中每个字符,过滤后统计每个字符出现次数,取出出现次数最多的前10名
#grep -o '. ' /etc/passwd|sort|uniq -c |sort -rn|head
找出/tmp目录下,属主不是root,且文件名不以f开头的文件
# ll /tmp/|awk '$3!="root"{print $NF}'|awk '/^[^f]/{print $0}'
# ll  |awk '$3!="root" && $NF!~/^f/'
#find /tmp/ -type f ! -name "f*" ! -user root
# find /tmp/ -type f ! -name "f*" ! -uid 0

找出/etc和usr中以.sh结尾的文件且大于10kb
#find /etc/ /usr -type -f -name "*.sh" -size +10k  (k小写)
当前系统中没有任何的文本编辑器,如何过滤掉/etc/ssh/ssh_config的注释行和空行
#egrep -v '^$|#' /etc/ssh/ssh_config
#sed -r '/^$|#/p' /etc/ssh/ssh_config
#awk '!/^$|#/' /etc/ssh/ssh_config
取出/etc/passwd中uid 大于200小于1000的用户信息
awk -F:'$3>200&&$3<1000' /etc/passwd
压缩/etc目录下的所有内容,存放在/data/0319/etc.zip
#tar -czvf  /data/0319/etc.zip  /etc/*
以/etc/passwd uid 进行逆序排序,给出命令
#sort -t: -rnk3 /etc/passwd
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bessssss

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值